Javascript:从私钥生成 ECDSA public 密钥

Javascript: Generating ECDSA public key from private key

是否有任何库支持从 javascript(前端)的私钥导出 ecdsa public 密钥? (有了私钥,我们就可以生成对应的public密钥)

学习了localethereum white paper,想实现加密层

它说:

AccountKeyIdentityPublic — Using the SECP‐256k1 curve, an ECDSA public key that corresponds to AccountKeyIdentityPrivate.

但是,似乎有很多库 (1, 2) 不支持此功能

谁能给我一些建议?谢谢!

你可以用支持点乘的库来做这样的事情。 要获得 public 密钥,您只需将生成点 G 乘以您的私钥即可。

例如使用 elliptic 包:

var EC = require('elliptic').ec;

// Create and initialize EC context
// (better do it once and reuse it)
var ec = new EC('secp256k1');

// Then generate the public point/key corresponding to your secret key.
var pubPoint = ec.keyFromSecret(secret).getPublic();