Skip to main content

Module merkle

Module merkle 

Source
Expand description

Merkle batch signing (issue #392).

A TPM 2.0 makes roughly 5-50 ECDSA signatures per second, far below robot topic rates. In batch mode the agent hashes a batch of events into a Merkle tree and the signer signs only a batch statement naming the root, once per batch. Each event carries the statement, its signature and its inclusion proof in provenance.batch, so it can still be verified on its own.

The tree is the RFC 9162 (Certificate Transparency) Merkle tree over SHA-256: leaf SHA-256(0x00 || leaf payload), node SHA-256(0x01 || left || right), inclusion proofs as RFC 9162 audit paths (leaf first). The leaf payload is the event’s signing payload with provenance.batch also removed. The construction is identical to the Python SDK’s phytrace.core.merkle and PhyCloud’s verifier, pinned by PhyTrace/test-vectors/merkle-batch.json.

Constants§

STATEMENT_TYPE
type of a batch statement.

Functions§

audit_path
RFC 9162 inclusion proof for leaves[index], leaf first; None if index is out of range.
hex
Lowercase hex.
leaf_hash
Hash of a leaf payload.
merkle_root
RFC 9162 Merkle tree hash of leaf hashes.
node_hash
Hash of an interior node.
root_from_proof
The root an inclusion proof leads to (RFC 9162 §2.1.3.2), or None if the proof does not fit a tree of size leaves.
verify_inclusion
Whether a batch-signed event (JSON) is in the batch its statement describes: its inclusion proof leads to the statement’s root, and its provenance matches the statement (boot epoch, key, sequence range). The statement’s signature is checked separately.

Type Aliases§

Hash
A 32-byte SHA-256 hash.