Expand description
This crate defines and implements the encrypted offline storage format used by the Stronghold ecosystem.
The format has a header with version and magic bytes to appease applications wishing to provide file-type detection.
The data stored within a snapshot is considered opaque and uses 256 bit keys. It provides recommended ways to derive the snapshot encryption key from a user provided password. The format also allows using an authenticated data bytestring to further protect the offline snapshot files (one might consider using a secondary user password strengthened by an HSM).
The current version of the format is using X25519 together with an ephemeral key to derive a shared key for the symmetric XChaCha20 cipher and uses the Poly1305 message authentication algorithm. Future versions, when the demands for larger snapshot sizes and/or random access is desired, might consider encrypting smaller chunks (B-trees?) or similar using per chunk derived ephemeral keys.
Modules§
Structs§
Enums§
Constants§
- KEY_
SIZE - Key size for the ephemeral key
- MAGIC
- Magic bytes (bytes 0-4 in a snapshot file) aka PARTI
- VERSION
- Current version bytes (bytes 5-6 in a snapshot file)
Functions§
- compress
- Compress data using an LZ4 Algorithm.
- decompress
- Decompress data using an LZ4 Algorithm.
- decrypt_
content - Decrypt snapshot content with key using maximum work factor recommended for password-based (weak) keys.
- decrypt_
content_ with_ work_ factor - Decrypt snapshot content with key using custom maximum work factor.
- decrypt_
file - Check the file header,
decrypt_content, and decompress the ciphertext from the specified path. - encrypt_
content - Encrypt snapshot content with key using work factor recommended for password-based (weak) keys.
- encrypt_
content_ with_ work_ factor - Encrypt snapshot content with key using custom work factor.
- encrypt_
file - Put magic and version bytes as file-header,
encrypt_contentthe specified plaintext to the specified path. - get_
encrypt_ work_ factor - try_
set_ encrypt_ work_ factor
Type Aliases§
- Key
- Key type alias.