MCPcopy
hub / github.com/streetwriters/notesnook / streamingDecrypt

Function streamingDecrypt

packages/sodium/tests/utils.ts:57–87  ·  view source on GitHub ↗
(
  crypto: ISodium,
  key: Uint8Array,
  cipher: { header: string; chunks: string[] }
)

Source from the content-addressed store, hash-verified

55}
56
57export async function streamingDecrypt(
58 crypto: ISodium,
59 key: Uint8Array,
60 cipher: { header: string; chunks: string[] }
61) {
62 await crypto.initialize();
63 const state = crypto.crypto_secretstream_xchacha20poly1305_init_pull(
64 crypto.from_base64(cipher.header),
65 key
66 );
67 return [
68 crypto.crypto_secretstream_xchacha20poly1305_pull(
69 state,
70 crypto.from_base64(cipher.chunks[0]),
71 null,
72 "text"
73 ),
74 crypto.crypto_secretstream_xchacha20poly1305_pull(
75 state,
76 crypto.from_base64(cipher.chunks[1]),
77 null,
78 "text"
79 ),
80 crypto.crypto_secretstream_xchacha20poly1305_pull(
81 state,
82 crypto.from_base64(cipher.chunks[2]),
83 null,
84 "text"
85 )
86 ];
87}
88
89export async function decrypt(
90 crypto: ISodium,

Callers 1

compat.test.tsFile · 0.90

Tested by

no test coverage detected