pub struct Entry { /* private fields */ }Expand description
One entry in a tamper-evident audit log.
An entry binds a payload both to its position in the log and to the entry before it: it carries the payload, the entry’s index, the digest of the previous entry (the chain link), and a signature over this entry’s digest. Because each entry commits to the one before, altering, reordering, inserting, or dropping any entry breaks the chain and is caught on verification.
Implementations§
Source§impl Entry
impl Entry
Sourcepub fn previous(&self) -> [u8; 32]
pub fn previous(&self) -> [u8; 32]
Returns the digest of the previous entry that this entry chains to.
§Returns
The previous entry’s digest, or all zeros for the first entry.
Sourcepub fn digest(&self) -> [u8; 32]
pub fn digest(&self) -> [u8; 32]
Computes this entry’s digest: the hash the signature covers and the next entry chains to.
§Returns
The 32-byte SHA-256 digest over the index, previous digest, and payload.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Encodes the entry to bytes for durable storage.
The layout is the little-endian index, the previous digest, the signature, then the payload.
§Returns
The encoded entry.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Decodes an entry from its stored bytes.
§Arguments
bytes- the encoded entry, as produced byto_bytes.
§Returns
The decoded entry.
§Errors
Returns Error::Codec if bytes is shorter than
an entry header.