Revert "Improve code splitting"

This reverts commit f98b91ea3c.
This commit is contained in:
2025-09-26 13:49:51 +03:00
Unverified
parent 92f275c665
commit 230b8d7e56
5 changed files with 13 additions and 16 deletions
+3 -6
View File
@@ -1,3 +1,4 @@
import nacl from "tweetnacl";
import { hkdfExtractAndExpand } from "../crypto/kdf";
export interface X25519KeyPair {
@@ -7,16 +8,12 @@ export interface X25519KeyPair {
export type KeyPair = X25519KeyPair;
export async function generateX25519KeyPair(): Promise<X25519KeyPair> {
const nacl = await import("tweetnacl");
export function generateX25519KeyPair(): X25519KeyPair {
const kp = nacl.box.keyPair();
return { publicKey: kp.publicKey, privateKey: kp.secretKey };
}
export async function ecdhSharedSecret(myPrivateKey: Uint8Array, theirPublicKey: Uint8Array): Promise<Uint8Array> {
const nacl = await import("tweetnacl");
export function ecdhSharedSecret(myPrivateKey: Uint8Array, theirPublicKey: Uint8Array): Uint8Array {
// nacl.box.before returns shared key (Curve25519, XSalsa20-Poly1305 context). We use it as IKM into HKDF.
return nacl.box.before(theirPublicKey, myPrivateKey);
}