Crate transparentlog_core

Crate transparentlog_core 

Source
Expand description

§Transparent Log

This crate provides an implementation of a Merkle tree for log records, for sceptical clients.

See https://research.swtch.com/tlog

§Examples

use transparentlog_core::{check_record,InMemoryLog,InMemoryLogClientBuilder,TransparentLog};
 
// Create a new log
let mut ml: InMemoryLog<String>=InMemoryLog::default();
// Create a new client
let mut client= InMemoryLogClientBuilder::new(&ml)?.build();
// Append a record to the log
let rec1 = ml.append(String::from("entry1"))?;
// Check the log contains the record
assert_eq!(true, check_record(&mut client,&ml,&rec1)?);
// Get back the data
assert_eq!("entry1",ml.get(rec1.id)?.unwrap().as_str());

Re-exports§

pub use test_helpers::*;

Modules§

test_helpers

Structs§

FileLog
A file based transparent log
InMemoryLog
An in-memory transparent log
InMemoryLogClient
In-memory client to a TransparentLog, keeping track of the latest log verified
InMemoryLogClientBuilder
Build an in-memory client, from the current state of the log or a saved state
LogTree
Reference to a full log: its size and root hash
LogTreePosition
Position in the tree
Record
Reference to a Record, with its ID and its hash

Traits§

LogClient
A simple log client, optionally keeping a cache of tree entries
TransparentLog
Transparent log Trait

Functions§

check_record
Check a given index + hash is contained in the given log, using the stored latest verification if possible or updating the cache if needed
hash
Hash a given record via its Serialize instance
prefix_proof_positions
Calculate the proof positions needed to assert a tree of size1 is a prefix of a tree of size 2
proof_positions
Calculate the proof position needed to assert the record at the given index is present in a log of the given size
tree_sizes
Return the level sizes for each level of the tree
verify
Verify that a given record belongs to the given tree, using the proofs provided
verify_tree
Verify that the tree is correct with the proofs provided

Type Aliases§

LogHeight
The height of the tree