Author

Topic: Simple EC question on multiplying/adding private keys (Read 950 times)

hero member
Activity: 793
Merit: 1016
Excellent, thank you all!  I actually just now subtracted them and found the difference was N... although I didn't know what to make of that.

Thank you all so much for your help!!!
donator
Activity: 1218
Merit: 1079
Gerald Davis
It looks like you are just using the wrong value for the modulus.  It is modulo n not p.  For Secp256k1, n is 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141.   In ECDSA all private keys must be on the interval [1, n-1] where n is from the equation n x G = 0.
legendary
Activity: 2646
Merit: 1136
All paid signature campaigns should be banned.
What is the exact number you are using for the mod operation (p)?

It looks like you are using the wrong value.
hero member
Activity: 793
Merit: 1016
Ahhhhh, I didn't understand that it was just "normal" modular arithmetic.  Thank you very much for the very helpful reply!

Now I just need to figure out why when I add af4afaeb40810e5f8abdbb177c31a2d310913f91cf556f5350bca10cbfe8b9ec and d39758028e201e8edf6d6eec6910ae4038f9b1db3f2d4e2d109ed833be94a026, I get 82e252edcea12cee6a2b2a03e5425113498af16d0e82bd80615b79417e7d5de3 but casascius' utility gets 82e252edcea12cee6a2b2a03e54251148edc14865f3a1d44a1891ab3ae4718d1.

But I'm at least no longer pulling my hair out trying to figure out what I'm supposed to do!  Thank you!!!
sr. member
Activity: 250
Merit: 253
Private keys are integers modulo p (where p = 2^256-2^32-977, as defined in secp256k1). For the sake of an example, let's use a curve where p = 7, and the private keys in question are 4 and 5.

Add private keys:
4 + 5 (mod 7) = 9 (mod 7) = 2 (mod 7)
Multiply private keys:
4 * 5 (mod 7) = 20 (mod 7) = 6 (mod 7)

As you can see, there's really no elliptic curve stuff going on at this point: we're just dealing with adding and multiplying integers in modular arithmetic, which is quite easy.
hero member
Activity: 793
Merit: 1016
I apologize if this is not the right place for this simple question!

I'm just learning Python and practicing some EC stuff with the World Bitcoin Network video and its Python example.

I think I've got the hang of it, but I have a question I can't seem to find the answer to.  In casascius' Bitcoin Address Utility, he has a window for multiplying and for adding two private keys.  As far as I understand it, private keys are scalar integers, not points, and the EC equations in the Python example I have require X and Y coordinates of points in order to do those operations on them.

Given that they are not points...

How do you add two private keys?  How do you multiply two private keys?

Once again, I apologize if this is not the right place for this question, and I thank you all for your help!  I swear I Googled this for hours before resorting to posting.  All the forums I read just seemed to say "yup it's an integer, not a point" without then explaining how you add/multiply them given that they're integers.

Thank you again guys!
Jump to: