feat(extensions): add extension loader infrastructure #3

Merged
padreug merged 15 commits from feature/extension-loader into dev 2026-04-02 18:47:55 +00:00
Showing only changes of commit b115712c87 - Show all commits

View file

@ -1,14 +1,14 @@
import { base64 } from "@scure/base"; import { base64, hex } from "@scure/base";
import { randomBytes } from "@noble/hashes/utils"; import { randomBytes } from "@noble/hashes/utils";
import { streamXOR as xchacha20 } from "@stablelib/xchacha20"; import { streamXOR as xchacha20 } from "@stablelib/xchacha20";
import { secp256k1 } from "@noble/curves/secp256k1"; import { secp256k1 } from "@noble/curves/secp256k1.js";
import { sha256 } from "@noble/hashes/sha256"; import { sha256 } from "@noble/hashes/sha256";
export type EncryptedData = { export type EncryptedData = {
ciphertext: Uint8Array; ciphertext: Uint8Array;
nonce: Uint8Array; nonce: Uint8Array;
} }
export const getSharedSecret = (privateKey: string, publicKey: string) => { export const getSharedSecret = (privateKey: string, publicKey: string) => {
const key = secp256k1.getSharedSecret(privateKey, "02" + publicKey); const key = secp256k1.getSharedSecret(hex.decode(privateKey), hex.decode("02" + publicKey));
return sha256(key.slice(1, 33)); return sha256(key.slice(1, 33));
} }