Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node:crypto implementation doesn't support ECDSA secp256k1 #17184

Open
mary-ext opened this issue Feb 8, 2025 · 0 comments
Open

node:crypto implementation doesn't support ECDSA secp256k1 #17184

mary-ext opened this issue Feb 8, 2025 · 0 comments
Assignees
Labels
bug Something isn't working node:crypto

Comments

@mary-ext
Copy link

mary-ext commented Feb 8, 2025

What version of Bun is running?

1.2.2+c1708ea6a

What platform is your computer?

Linux 6.13.1-2-cachyos x86_64 unknown

What steps can reproduce the bug?

import * as crypt from 'node:crypto';
crypt.generateKeyPair('ec', { namedCurve: 'secp256k1' }, console.log);

What is the expected behavior?

Generates a ECDSA secp256k1 keypair and logs it to console

What do you see instead?

Throws, unsupported by Bun.

9327 |     typeof callback === "function" && callback(null, KeyObject.from(key2));
9328 |   } catch (err) {
9329 |     typeof callback === "function" && callback(err);
9330 |   }
9331 | };
9332 |   let result = generateKeyPairSync(algorithm, options);
                            ^
error: Unsupported JWK EC curve: secp256k1
 code: "ERR_CRYPTO_JWK_UNSUPPORTED_CURVE"

      at _generateKeyPairSync (node:crypto:9332:35)
      at _generateKeyPair (node:crypto:9342:38)

Additional information

Used in @atcute/crypto to validate most signatures in AT Protocol, as secp256k1 is more readily available in KMS/HSMs.

Web3/cryptocurrency use cases would also benefit from this addition.

Currently, @atcute/crypto mitigates this lack of support by adding an imports condition for Bun, it would be nice if Bun actually supported this to avoid using the JS-based @noble/secp256k1 library for signing and verification.

rel: #11284 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node:crypto
Projects
None yet
Development

No branches or pull requests

3 participants