Bitcoin Forum
November 05, 2024, 06:40:53 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Simple EC question on multiplying/adding private keys  (Read 971 times)
luv2drnkbr (OP)
Hero Member
*****
Offline Offline

Activity: 793
Merit: 1026



View Profile
July 05, 2014, 08:15:02 PM
 #1

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!

TimS
Sr. Member
****
Offline Offline

Activity: 250
Merit: 253


View Profile WWW
July 05, 2014, 08:32:15 PM
 #2

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.
luv2drnkbr (OP)
Hero Member
*****
Offline Offline

Activity: 793
Merit: 1026



View Profile
July 05, 2014, 08:54:35 PM
 #3

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!!!

BurtW
Legendary
*
Offline Offline

Activity: 2646
Merit: 1137

All paid signature campaigns should be banned.


View Profile WWW
July 05, 2014, 09:01:10 PM
 #4

What is the exact number you are using for the mod operation (p)?

It looks like you are using the wrong value.

Our family was terrorized by Homeland Security.  Read all about it here:  http://www.jmwagner.com/ and http://www.burtw.com/  Any donations to help us recover from the $300,000 in legal fees and forced donations to the Federal Asset Forfeiture slush fund are greatly appreciated!
DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
July 05, 2014, 09:12:22 PM
Last edit: July 05, 2014, 09:30:45 PM by DeathAndTaxes
 #5

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.
luv2drnkbr (OP)
Hero Member
*****
Offline Offline

Activity: 793
Merit: 1026



View Profile
July 05, 2014, 09:15:15 PM
 #6

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!!!

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!