MCPcopy
hub / github.com/slopus/happy / deriveContentKeyPair

Function deriveContentKeyPair

packages/happy-agent/src/encryption.ts:74–81  ·  view source on GitHub ↗
(secret: Uint8Array)

Source from the content-addressed store, hash-verified

72}
73
74export function deriveContentKeyPair(secret: Uint8Array): { publicKey: Uint8Array; secretKey: Uint8Array } {
75 const seed = deriveKey(secret, 'Happy EnCoder', ['content']);
76 // libsodium's crypto_box_seed_keypair does SHA-512(seed)[0:32] internally
77 const hashedSeed = new Uint8Array(createHash('sha512').update(seed).digest());
78 const boxSecretKey = hashedSeed.slice(0, 32);
79 const keyPair = tweetnacl.box.keyPair.fromSecretKey(boxSecretKey);
80 return { publicKey: keyPair.publicKey, secretKey: keyPair.secretKey };
81}
82
83// --- AES-256-GCM encryption ---
84

Callers 6

makeCredentialsFunction · 0.90
cli-smoke.test.tsFile · 0.90
makeCredentialsFunction · 0.90
readCredentialsFunction · 0.90
encryption.test.tsFile · 0.90

Calls 1

deriveKeyFunction · 0.70

Tested by 2

makeCredentialsFunction · 0.72
makeCredentialsFunction · 0.72