【问题标题】:subtle crypto with ECDSA : Cannot create a key using the specified key usagesECDSA 的微妙加密:无法使用指定的密钥用法创建密钥
【发布时间】:2021-08-27 13:19:47
【问题描述】:

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

在尝试使用 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 一致。

任何帮助表示赞赏。

【问题讨论】:

    标签: javascript cryptography ecdsa jose


    【解决方案1】:

    Web Cryptography API 不支持secp256k1 曲线。以后还会not support它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-07
      • 1970-01-01
      • 1970-01-01
      • 2012-05-08
      相关资源
      最近更新 更多