简体   繁体   中英

How can I sign a message with a Bitcoin private key from terminal

I'm trying to sign a message with a Bitcoin private key to get a refund from InstaWallet.

Any hints on how to do this from a terminal on OS X?

( page 22, 23 from An Introduction to Bitcoin, Elliptic Curves and the Mathematics of ECDSA )

4.6 ECDSA

A brief outline of how digital signatures work was given in 2.4.2. Bitcoin uses the mathematics of elliptic curves as the underlying basis for its digital signature. Recall elliptic curves are defined by T = (p, a, b, G, n, h), with Bitcoin using parameters prescribed by sep256k1. We also have the private and public key pair (Kpriv, Kpub where Kpub = Kpriv × G, as explained in 4.5. If Alice (A) and Bob (B) wanted to send a message (or transaction) to each other, this is how they would create and verify a digital signature.

4.6.1 Signature Generation [7]

To sign a message m Alice would do the following.

  1. Select a random integer k, 1 ≤ k ≤ n − 1.
  2. Compute kG = (x1, y1) and convert x1 to an integer x1.
  3. Compute r = x1 (mod n). If r = 0 then go to step 1.
  4. Compute k^−1 (mod n). Where k^−1 is the multiplicative inverse and satisfies k−1

[ ... ]

Either follow the link and continue on, to steps five, six, and seven via page 23; or via a python answer here via Jorky10: How to sign and verify signature with ecdsa in python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM