Browse Source
Merge pull request #331 from fmoessbauer/master
document scalar clamping of curve25519 keys
pull/338/head
Hunter Thornsberry
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
2 additions and
0 deletions
-
src/core/utils/x25519.ts
|
|
|
@ -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; |
|
|
|
|