crypto-seal is a small utility designed to securely "package" or seal serde-compatible data type that can passed around in an uncompromised manner.
Note: ED25519 is the default key type. The supported key types are ED25519, secp256k1, P-256, P-384, and AES-256. With the AES-256 key type, signing uses HMAC-SHA256 (with a MAC key derived separately from the encryption key), which is a symmetric authenticator and is not publicly verifiable like the elliptic-curve signatures.
use crypto_seal::{Seal, error::Error};
fn main() -> Result<(), Error> {
let my_data = String::from("Hello, World!");
let (my_key, sealed_data) = my_data.seal()?;
let unsealed_data = sealed_data.open(&my_key)?;
assert_eq!(my_data, unsealed_data);
Ok(())
}use crypto_seal::{Seal, Package, key::PrivateKey, error::Error};
fn main() -> Result<(), Error> {
let alice = PrivateKey::new();
let bob = PrivateKey::new();
let sealed = String::from("Hello, Bob!").seal_shared(&alice, vec![bob.public_key()?])?;
let bytes = sealed.to_bytes()?;
let received = Package::<String>::from_bytes(bytes)?;
let message = received.open_shared(&bob, &alice.public_key()?)?;
assert_eq!(String::from("Hello, Bob!"), message);
Ok(())
}The minimum supported rust version is 1.93, which can be changed in the future. There is no guarantee that this library will work on older versions of rust.
This crate is licensed under either Apache 2.0 or MIT.