Search content
Sort by

Showing 11 of 11 results by qqq123
Post
Topic
Board Development & Technical Discussion
Re: Elliptic curve point multiplication
by
qqq123
on 01/05/2012, 14:21:06 UTC
Thanks guys, I have taken care of all problems and now have a working ECDSA implementation in php.

As far as it being "impossible to build anything large and maintainable" with php, Wikipedia, Facebook, MediaWiki, Joomla, WordPress, Drupal, Digg, Baidu (I could go on) all use php, so...
Post
Topic
Board Development & Technical Discussion
Re: Elliptic curve point multiplication
by
qqq123
on 29/04/2012, 03:07:22 UTC
I don't suppose anyone here knows php and modular arithmetic well enough to tell me what is wrong with my modular inversion code... It works with positive values, but not negative values.

Code:
function egcd($a, $b){
   $x = 0;
   $y = 1;
   $u = 1;
   $v = 0;
   while($a != 0){
      $q = bcdiv($b, $a);
      $r = bcmod($b, $a);
      $m = bcsub($x, bcmul($u, $q));
      $n = bcsub($y, bcmul($v, $q));
      $b = $a;
      $a = $r;
      $x = $u;
      $y = $v;
      $u = $m;
      $v = $n;
   }
   return array($b, $x, $y);
}
function modinv($a, $m){
   list($g, $x, $y) = egcd($a, $m);
   if($g != 1){
      return "modular inverse doesn't exist";
   }else{
      return bcmod($x, $m);
   }
}

So, modinv(-5, 17) returns "modular inverse doesn't exist".  It should return 10.  (That is the correct answer to -5-1 mod 17.)

Thanks.
Post
Topic
Board Development & Technical Discussion
Re: Elliptic curve point multiplication
by
qqq123
on 28/04/2012, 16:22:50 UTC
Good question.

I want to use php for two reasons.

1.  I will probably use javascript as the first option, but php will be the backup in case the user has javascript disabled.
2.  No one (I think, please tell me if you know otherwise) has ever implemented this in php, so if I do, hopefully someone else will have a use for it.
Post
Topic
Board Development & Technical Discussion
Re: Elliptic curve point multiplication
by
qqq123
on 28/04/2012, 16:10:22 UTC
Well yeah, but I'm having some trouble converting that poorly done and contradictory pseudocode into working code specific to the secp256k1 curve used by Bitcoin...

Thanks for your input.
Post
Topic
Board Altcoin Discussion
Topic OP
Litecoin price?
by
qqq123
on 28/04/2012, 15:55:42 UTC
Litecoin was up around 1LTC/0.001BTC a week or so ago, now it's 1LTC/0.000758BTC and still falling.  Why?  I'm beginning to wonder if it would be more profitable to use my CPU for BTC/NMC merged mining.
Post
Topic
Board Development & Technical Discussion
Topic OP
Elliptic curve point multiplication
by
qqq123
on 28/04/2012, 15:51:30 UTC
First off, I hope this is the right place to post this.

I'm trying to figure out how to implement elliptic curve point multiplication in php, in order to convert a Bitcoin private key to a Bitcoin public key.

If you have any information about how to do this, or if you can help explain the algorithms used, even in pseudocode, that would be most helpful.

If someone knows php, I can show you what I have so far if that would help.

You can reference my post about this topic in the newbie forum here:
https://bitcointalk.org/index.php?topic=78132.0

Thanks for any help.
Post
Topic
Board Beginners & Help
Re: Private key to Public key
by
qqq123
on 28/04/2012, 03:04:44 UTC
If anyone has any test problems I can run for point multiplication on the secp256k1 curve that would be great.  I think I have the implementation down, but the fact that everything is in hex is giving me fits.  I would love to be able to verify that the point multiplication works in decimal before moving on the tackling hex.

Doing the math by hand, I know that 2 * (4, 3) = (56, -419).
But doing large multiplications by hand is impossible.
For example, 100 * (4, 3) = Huh

And for actually doing the point multiplication required by bitcoin...

Let's say privatekey (in hex) = 059E2BF5E2C7A4098C164B29A91CF70508D2FD1A256A60656FD2593BDB980FAA
so privatekey in dec = 2541029483313867478679144795827841690699430215057902992954466247848698056618
Gx (in hex) = 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798
so Gx in dec = 55066263022277343669578718895168534326250603453777594175500187360389116729240
Gy (in hex) = 483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8
so Gy in dec = 32670510020758816978083085130507043184471273380659243275938904335757337482424

so, given that privatekey * (Gx, Gy) = publickey
the math is (in dec): 2541029483313867478679144795827841690699430215057902992954466247848698056618 * (55066263022277343669578718895168534326250603453777594175500187360389116729240, 32670510020758816978083085130507043184471273380659243275938904335757337482424).

Having a real hard time seeing if my function works with numbers that big...
Post
Topic
Board Beginners & Help
Re: Private key to Public key
by
qqq123
on 27/04/2012, 19:09:55 UTC
Thanks for the replies.  From what I've read I've gathered that:

PuK = G * PrK

where PuK is the public key, G is the set of (x, y) coordinates for the secp256k1 elliptic curve, which are, in hex, (x = 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798, y = 483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8), PrK is the private key, and * stands for point multiplication.

I am, however, having trouble implementing point multiplication.  I've read the wiki article here, and understand that it's basically doubling and adding the point, but I can't quite wrap my head around the pseudocode they give.  Can anyone help with that?  I'm working in php, but anything would help really.

Thanks.
Post
Topic
Board Beginners & Help
Re: Private key to Public key
by
qqq123
on 26/04/2012, 14:06:57 UTC
That's from here, and I don't think it can be used to go from a private key to a public key.
Post
Topic
Board Beginners & Help
Re: Private key to Public key
by
qqq123
on 26/04/2012, 13:44:10 UTC
I've read that article more times than I can count.  It still doesn't explain the equation(s) used to go from the private key to the public key.  It just says "1) Have a private ECDSA key. 2) Take the public key generated with it (65 bytes, 1 byte 0x04, 32 bytes corresponding to X coordinate, 32 bytes corresponding to Y coordinate)."  I do not understand how that public key is generated, despite reading several articles on elliptic curve cryptography.
Post
Topic
Board Beginners & Help
Topic OP
Private key to Public key
by
qqq123
on 26/04/2012, 04:52:46 UTC
Hello,

I am here looking for an understanding of the math behind converting a Bitcoin private key to a Bitcoin public key for a website I am creating.  The website will be capable of dynamically creating a private key and the corresponding public key and Bitcoin address (much like bitaddress.org).

If anyone can help with this understanding, I'd appreciate it.

Thanks.