我想在 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
.
任何帮助表示赞赏。