Expand description
Bao is an implementation of BLAKE3 verified streaming. For more about how verified streaming works and what the Bao format looks like, see the project README and the full specification.
Example
use std::io::prelude::*;
// Encode some example bytes.
let input = b"some input";
let (encoded, hash) = abao::encode::encode(input);
// Decode them with one of the all-at-once functions.
let decoded_at_once = abao::decode::decode(&encoded, &hash)?;
// Also decode them incrementally.
let mut decoded_incrementally = Vec::new();
let mut decoder = abao::decode::Decoder::new(&*encoded, &hash);
decoder.read_to_end(&mut decoded_incrementally)?;
// Assert that we got the same results both times.
assert_eq!(decoded_at_once, decoded_incrementally);
// Flipping a bit in encoding will cause a decoding error.
let mut bad_encoded = encoded.clone();
let last_index = bad_encoded.len() - 1;
bad_encoded[last_index] ^= 1;
let err = abao::decode::decode(&bad_encoded, &hash).unwrap_err();
assert_eq!(std::io::ErrorKind::InvalidData, err.kind());
Modules
- Decode the Bao format, or decode a slice.
- Encode some input bytes into the Bao format, or slice an existing encoding.
Structs
- An output of the default size, 32 bytes, which provides constant-time equality checking.
Constants
- The size of a
Hash
, 32 bytes.