Skip to content

Commit 723bde6

Browse files
d70-tachingbrain
andauthored
ed25519 generateKeyPairSync: use publicKey.x instead of privateKey.x (#2926)
Although [RFC7518 6.3.2](https://datatracker.ietf.org/doc/html/rfc7518#section-6.3.2) specifies that private key JWKs must include all the fields present in the public key, this is not the case for the implementation of `node:crypto.generateKeyPairSync` in the deno runtime. While Node returns the (same) `x` property in both, the `privateKey` and the `publicKey`, Deno only returns the `x` property in `publicKey` (i.e. [no x here](https://github.com/denoland/deno/blob/88490d092751288f736855b2418a4da606a31ce7/ext/node/ops/crypto/keys.rs#L1475)). This change should not affect any Node users, but would enable the use of libp2p on Deno. Co-authored-by: Alex Potsides <[email protected]>
1 parent a32fbeb commit 723bde6

File tree

1 file changed

+1
-1
lines changed
  • packages/crypto/src/keys/ed25519

1 file changed

+1
-1
lines changed

packages/crypto/src/keys/ed25519/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function generateKey (): Uint8ArrayKeyPair {
4545
// @ts-expect-error node types are missing jwk as a format
4646
const privateKeyRaw = uint8arrayFromString(key.privateKey.d, 'base64url')
4747
// @ts-expect-error node types are missing jwk as a format
48-
const publicKeyRaw = uint8arrayFromString(key.privateKey.x, 'base64url')
48+
const publicKeyRaw = uint8arrayFromString(key.publicKey.x, 'base64url')
4949

5050
return {
5151
privateKey: uint8arrayConcat([privateKeyRaw, publicKeyRaw], privateKeyRaw.byteLength + publicKeyRaw.byteLength),

0 commit comments

Comments
 (0)