如何将ECDSA曲线规范从SEC2形式转换为Go所需的形式?
我正在尝试在 Google Go 的曲线 secp256k1 中实现 ECDSA。
Secp256k1 由 SECG 标准(SEC 2,第 2 部分,推荐的椭圆曲线域参数
I`m trying to implement ECDSA in the curve secp256k1 in Google Go.
Secp256k1 is defined by the SECG standard (SEC 2, part 2, Recommended Elliptic Curve Domain Parameters over ????p, page 15) in terms of parameters p, a, b, G compressed, G uncompressed, n and h.
In Go's crypto library, the curves are defined by parameters P, N, B, Gx, Gy and BitSize. How do I convert parameters given by SECG into the ones needed by Go?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在Go的
elliptic
包中,因此,我们得到了
y² = x³ - 3·x + B
形式的曲线(其中x
和y
均采用In the
elliptic
package of Go,So, we have curves of the form
y² = x³ - 3·x + B
(where bothx
andy
take values in ????P).P
andB
thus are the parameters to identify a curve, the others are only necessary for the operations on the curve elements which will be used for cryptography.The SECG standard SEC 2 defines the secp256k1 curve as
y² = x³ + a·x + b
with a = 0, i.e. effectivelyy² = x³ + b
.These curves are not the same, independent of which b and B are selected here.
Your conversion is not possible with the
elliptic
package'sCurve
class, as it only supports some special class of curves (these witha = -3
), while SEC 2 recommends curves from other classes (a = 0 for the...k1
curves).On the other hand, the curves with
...r1
in the name seem to havea = -3
. And actually,secp256r1
seems to be the same curve which is available inelliptic
asp256()
. (I didn't prove this, but at least some the hex digits of the uncompressed form of the base point in SEC 2 are the coordinates of the base point in elliptic.)