简体   繁体   English

如何使用终端的比特币私钥签署消息

[英]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. 我正在尝试使用比特币私钥签署一条消息,以获得InstaWallet的退款。

Any hints on how to do this from a terminal on OS X? 有关如何从OS X上的终端执行此操作的任何提示?

( page 22, 23 from An Introduction to Bitcoin, Elliptic Curves and the Mathematics of ECDSA ) (第22页,23位来自比特币介绍,椭圆曲线和ECDSA数学

4.6 ECDSA 4.6 ECDSA

A brief outline of how digital signatures work was given in 2.4.2. 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. 召回椭圆曲线由T =(p,a,b,G,n,h)定义,比特币使用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. 我们还有私钥和公钥对(Kpriv,Kpub,其中Kpub = Kpriv×G,如4.5中所述。如果Alice(A)和Bob(B)想要彼此发送消息(或交易),这是他们将如何创建和验证数字签名。

4.6.1 Signature Generation [7] 4.6.1签名生成[7]

To sign a message m Alice would do the following. 要签署消息,Alice会执行以下操作。

  1. Select a random integer k, 1 ≤ k ≤ n − 1. 选择随机整数k,1≤k≤n - 1。
  2. Compute kG = (x1, y1) and convert x1 to an integer x1. 计算kG =(x1,y1)并将x1转换为整数x1。
  3. Compute r = x1 (mod n). 计算r = x1(mod n)。 If r = 0 then go to step 1. 如果r = 0,则转到步骤1。
  4. Compute k^−1 (mod n). 计算k ^ -1(mod n)。 Where k^−1 is the multiplicative inverse and satisfies k−1 其中k ^ -1是乘法逆并满足k-1

[ ... ] [...]

Either follow the link and continue on, to steps five, six, and seven via page 23; 请按照链接继续,通过第23页继续执行第五步,第六步和第七步; or via a python answer here via Jorky10: How to sign and verify signature with ecdsa in python 或通过一个python回答这里通过Jorky10: 如何签署和验证签名与ecdsa在python中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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