0

我想在 Chrome 中导入 ECDSA 私钥来签署一些数据,但尝试使用crypto.subtle.importKey:importKey使用secp256k1.

尝试使用 lib 时,我遇到了以下错误: Cannot create a key using the specified key usages.

编码:

const browserKey = await crypto.subtle.importKey(
    'raw',
    derivatedNode.privateKey, // ArrayBuffer
    {
        name: 'ECDSA',
        namedCurve: 'P-256' // Haven't found better fit for secp256k1?
    },
    false,
    ['sign']
);

仔细检查了我的私钥,得到了Uint8Array(32)似乎通常可以使用importKey.

任何帮助表示赞赏。

4

1 回答 1

2

Web Cryptography API 不支持secp256k1曲线。它也不会在未来支持它。

于 2021-06-10T15:15:11.183 回答