From d0bd02980de89146341133e34cc152eb0ca2b107 Mon Sep 17 00:00:00 2001 From: Tilen Komel Date: Mon, 2 Sep 2024 13:10:59 +0200 Subject: [PATCH] Update private key generation --- src/core/utils/x25519.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/utils/x25519.ts b/src/core/utils/x25519.ts index d9ae20b5..8daa7a84 100644 --- a/src/core/utils/x25519.ts +++ b/src/core/utils/x25519.ts @@ -1,7 +1,13 @@ import { x25519 } from "@noble/curves/ed25519"; export function getX25519PrivateKey(): Uint8Array { - return x25519.utils.randomPrivateKey(); + const key = x25519.utils.randomPrivateKey(); + + key[0] &= 248 + key[31] &= 127 + key[31] |= 64 + + return key; } export function getX25519PublicKey(privateKey: Uint8Array): Uint8Array {