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

fix: use publicKey.x instead of privateKey.x #2926

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

d70-t
Copy link

@d70-t d70-t commented Jan 27, 2025

fix: ed25519 generateKeyPairSync: use publicKey.x instead of privateKey.x

Description

Although RFC7518 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).

This change should not affect any Node users, but would enable the use of libp2p on Deno.

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

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.
@d70-t d70-t requested a review from a team as a code owner January 27, 2025 19:00
@d70-t d70-t changed the title ed25519 generateKeyPairSync: use publicKey.x instead of privateKey.x fix: ed25519 generateKeyPairSync: use publicKey.x instead of privateKey.x Jan 27, 2025
@d70-t d70-t changed the title fix: ed25519 generateKeyPairSync: use publicKey.x instead of privateKey.x fix: use publicKey.x instead of privateKey.x Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant