MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / decrypt_segment

Function decrypt_segment

nodedb-array/src/segment/encrypt.rs:41–45  ·  view source on GitHub ↗

Decrypt an encrypted array segment blob (starting at byte 0 = `SEGA`). Returns the inner plaintext segment bytes (starting with `NDAS`).

(key: &WalEncryptionKey, blob: &[u8])

Source from the content-addressed store, hash-verified

39///
40/// Returns the inner plaintext segment bytes (starting with `NDAS`).
41pub(crate) fn decrypt_segment(key: &WalEncryptionKey, blob: &[u8]) -> Result<Vec<u8>, ArrayError> {
42 decrypt_segment_envelope(key, &SEGA_MAGIC, blob).map_err(|e| ArrayError::DecryptionFailed {
43 detail: e.to_string(),
44 })
45}
46
47/// Sniff the first 4 bytes to determine if `blob` is a plaintext (`NDAS`)
48/// or encrypted (`SEGA`) segment. Returns `true` if encrypted.

Callers 2

open_with_kekMethod · 0.70

Calls 2

decrypt_segment_envelopeFunction · 0.85
to_stringMethod · 0.80