Documentation ¶
Overview ¶
Package batchmap is a library to be used within Beam pipelines to construct verifiable data structures.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
func Create(s beam.Scope, entries beam.PCollection, treeID int64, hash crypto.Hash, prefixStrata int) (beam.PCollection, error)
Create builds a new map from the given PCollection of *Entry. Outputs the resulting Merkle tree tiles as a PCollection of *Tile.
The keys in the input PCollection must be 256-bit, uniformly distributed, and unique within the input. The values in the input PCollection must be 256-bit. treeID should be a unique ID for the lifetime of this map. This is used as part of the hashing algorithm to provide preimage resistance. If the tiles are to be imported into Trillian for serving, this must match the tree ID within Trillian. The internal hash algorithm can be picked between SHA256 and SHA512_256. The internal nodes will use this algorithm via the CONIKS strategy. prefixStrata is the number of 8-bit prefix strata. Any path from root to leaf will have prefixStrata+1 tiles.
func Update ¶
func Update(s beam.Scope, base, delta beam.PCollection, treeID int64, hash crypto.Hash, prefixStrata int) (beam.PCollection, error)
Update takes an existing base map (PCollection of *Tile), applies the delta (PCollection of *Entry) and returns the resulting map as a PCollection of *Tile. The deltas can add new keys to the map or overwrite existing keys. Keys cannot be deleted (though their value can be set to a sentinel value).
treeID, hash, and prefixStrata must match the values passed into the original call to Create that started the base map.
Types ¶
type Entry ¶
type Entry struct { // The key that uniquely identifies this key/value. // These keys must be distributed uniformly and randomly across the key space. HashKey []byte // Hash of the value to be committed to. This will literally be set as a hash // of a TileLeaf in a leaf Tile. // It is the job of the code constructing this Entry to ensure that this has // appropriate preimage protection and domain separation. This means this will // likely be set to something like H(salt || data). // // TODO(mhutchinson): Revisit this. My preference is that this is set to // H(data), and the map synthesis will set the hash to H(salt||H(data)). // This allows the map to always be constructed with good security. HashValue []byte }
Entry is a single key/value to be committed to by the map.
type Tile ¶
type Tile struct { // The path from the root of the map to the root of this tile. Path []byte // The computed hash of this subtree. // TODO(mhutchinson): Consider removing this. RootHash []byte // All non-empty leaves in this tile, sorted left-to-right. Leaves []*TileLeaf }
Tile represents a perfect subtree covering the whole height of a stratum within a sparse map.
type TileLeaf ¶
type TileLeaf struct { // The path from the root of the container Tile to this leaf. Path []byte // The hash value being committed to. Hash []byte }
TileLeaf is a leaf value of a Tile. If it belongs to a leaf tile then this represents one of the values that the map commits to. Otherwise, this leaf represents the root of the subtree in the stratum below.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
build
mapdemo is a simple example that shows how a verifiable map can be constructed in Beam.
|
mapdemo is a simple example that shows how a verifiable map can be constructed in Beam. |
verify
verify is a simple example that shows how a verifiable map can be used to demonstrate inclusion.
|
verify is a simple example that shows how a verifiable map can be used to demonstrate inclusion. |