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

Function decryptLegacy

packages/consortium-cli/src/api/encryption.ts:84–92  ·  view source on GitHub ↗
(data: Uint8Array, secret: Uint8Array)

Source from the content-addressed store, hash-verified

82 * Decrypt data using NaCl secretbox (legacy)
83 */
84export function decryptLegacy(data: Uint8Array, secret: Uint8Array): any | null {
85 const nonce = data.slice(0, tweetnacl.secretbox.nonceLength);
86 const encrypted = data.slice(tweetnacl.secretbox.nonceLength);
87 const decrypted = tweetnacl.secretbox.open(encrypted, nonce, secret);
88 if (!decrypted) {
89 return null;
90 }
91 return JSON.parse(new TextDecoder().decode(decrypted));
92}
93
94/**
95 * Encrypt data using AES-256-GCM with the data encryption key

Callers 1

decryptFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected