MCPcopy Create free account
hub / github.com/ConsortiumAI/Consortium / decryptBox

Function decryptBox

packages/consortium-web/src/lib/encryption.ts:57–74  ·  view source on GitHub ↗
(
  bundle: Uint8Array,
  recipientSecretKey: Uint8Array,
)

Source from the content-addressed store, hash-verified

55// --- NaCl box encryption (for data encryption key unwrapping) ---
56
57export function decryptBox(
58 bundle: Uint8Array,
59 recipientSecretKey: Uint8Array,
60): Uint8Array | null {
61 const ephemeralPublicKey = bundle.slice(0, 32);
62 const nonce = bundle.slice(32, 56);
63 const encrypted = bundle.slice(56);
64 try {
65 return sodium.crypto_box_open_easy(
66 encrypted,
67 nonce,
68 ephemeralPublicKey,
69 recipientSecretKey,
70 );
71 } catch {
72 return null;
73 }
74}
75
76export function boxKeyPairFromSeed(seed: Uint8Array): {
77 publicKey: Uint8Array;

Callers 1

resolveSessionKeyFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected