Skip to content

Commit

Permalink
Merge pull request #331 from fmoessbauer/master
Browse files Browse the repository at this point in the history
document scalar clamping of curve25519 keys
  • Loading branch information
Hunter275 authored Nov 10, 2024
2 parents 6138d9f + 79c5638 commit 443c7fc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/utils/x25519.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { x25519 } from "@noble/curves/ed25519";
export function getX25519PrivateKey(): Uint8Array {
const key = x25519.utils.randomPrivateKey();

// scalar clamping for curve25519, according to
// https://www.rfc-editor.org/rfc/rfc7748#section-5
key[0] &= 248;
key[31] &= 127;
key[31] |= 64;
Expand Down

0 comments on commit 443c7fc

Please sign in to comment.