使用 NodeJS 的 ECDH 创建签名

问题描述 投票:0回答:1

我无法使用 Node 的加密模块为私钥所有权创建签名。我如何使用以下十六进制公钥和私钥来做到这一点:

const crypto = require("crypto");

const ecdh = crypto.createECDH("secp256k1");
ecdh.generateKeys();
const privateKey = ecdh.getPrivateKey("hex");
const publicKey = ecdh.getPublicKey("hex");
node.js cryptography digital-signature
1个回答
0
投票

ECDH - 是一种为加密算法生成秘密的算法。

你应该计算依赖于另一个公钥的秘密:

const secret = ecdh.computeSecret(anotherPublicKeyInHex, 'hex');

并在密码/解密中使用它:

crypto.createCipheriv('some-algorithm', secret, initialVector, options);
crypto.createDecipheriv('some-algorithm', secret, initialVector, options);

如果你不知道,你可以用它做什么,不要使用它。首先,您需要阅读有关密码算法、生成秘密的算法等更多信息

https://en.wikipedia.org/wiki/Public-key_cryptography

https://en.wikipedia.org/wiki/Key_generation

https://en.wikipedia.org/wiki/Elliptic-curve_cryptography

© www.soinside.com 2019 - 2024. All rights reserved.