rfc9162_tiles/lib.rs
1//! Tiled, indexed storage for an RFC 9162 log, laid out as C2SP tlog-tiles
2//! (<https://c2sp.org/tlog-tiles>): 256-hash tiles, 256-entry bundles, and the
3//! tree [`rfc9162`] hashes. Any tlog-tiles client reads the tree. The index
4//! sidecars beside it are this crate's addition and tlog clients ignore them.
5//!
6//! The root over the tiles is `rfc9162::root` over the same leaves, and the
7//! proofs a reader assembles from tiles are the bytes `rfc9162::inclusion_proof`
8//! and `rfc9162::consistency_proof` give over the flat leaf slice. The head
9//! is a C2SP checkpoint, an Ed25519 signed note, with witness cosignatures
10//! checked as cosignature/v1.
11//!
12//! ```
13//! use rfc9162_tiles::index::no_keys;
14//! use rfc9162_tiles::{MemoryStore, Reader, Writer};
15//!
16//! let store = MemoryStore::new();
17//! let mut writer = Writer::open(store.clone(), no_keys())?;
18//! let index = writer.append(b"first record")?;
19//! drop(writer);
20//!
21//! let reader = Reader::open(store, no_keys())?;
22//! assert_eq!(reader.get(index)?, Some(b"first record".to_vec()));
23//! let proof = reader.inclusion(index)?.unwrap();
24//! assert!(rfc9162::verify_inclusion(
25//! &rfc9162::leaf_hash(b"first record"),
26//! index as usize,
27//! reader.size() as usize,
28//! &proof,
29//! &rfc9162::hex(&reader.root()),
30//! ));
31//! # Ok::<(), rfc9162_tiles::Error>(())
32//! ```
33
34pub mod base64;
35pub mod bloom;
36pub mod bundle;
37pub mod checkpoint;
38pub mod error;
39pub mod index;
40pub mod layout;
41pub mod log;
42pub mod pack;
43pub mod store;
44pub mod tree;
45
46pub use bloom::Bloom;
47pub use checkpoint::{Checkpoint, Cosigner, Note, Signer, Verifier};
48pub use error::{Error, Result};
49pub use index::{KeyFn, Manifest, Sidecar};
50pub use layout::{Layout, Tile};
51pub use log::{Reader, TreeState, Writer};
52pub use pack::{Compacted, PackStore, PACK_MAGIC, PACK_MAGIC_V1, SHARED_LOCK_WAIT};
53pub use store::{MemoryStore, PosixStore, TileStore};
54pub use tree::{Frontier, Hash, TileHashReader};