如何将ECDSA曲线规范从SEC2形式转换为Go所需的形式?

发布于 2024-12-05 13:18:37 字数 171 浏览 1 评论 0原文

我正在尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独守阴晴ぅ圆缺 2024-12-12 13:18:38

在Go的elliptic包中,

曲线表示 a=-3 的简短形式 Weierstrass 曲线。

因此,我们得到了 y² = x³ - 3·x + B 形式的曲线(其中 xy 均采用

In the elliptic package of Go,

A Curve represents a short-form Weierstrass curve with a=-3.

So, we have curves of the form y² = x³ - 3·x + B (where both x and y take values in ????P). P and B 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. effectively y² = 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's Curve class, as it only supports some special class of curves (these with a = -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 have a = -3. And actually, secp256r1 seems to be the same curve which is available in elliptic as p256(). (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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文