package irmin-pack
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=92a9de7a0a2a35c2feba0c35a806b1f0df24c1c0d15164eebf3f919296d26715
sha512=0203ec5117a851ad5afeb2f9091659b4e142e231b6b945caab93f4d7beb23397c8ac43f7056e91d18f4bff0be1062f6ae966d221f877c229328c0cbbf29fd9f0
doc/irmin-pack.mem/Irmin_pack_mem/Maker/Make/Tree/Proof/index.html
Module Tree.Proof
Proofs are compact representations of trees which can be shared between peers.
This is expected to be used as follows:
- A first peer runs a function
f
over a treet
. While performing this computation, it records: the hash oft
(calledbefore
below), the hash off t
(calledafter
below) and a subset oft
which is needed to replayf
without any access to the first peer's storage. Once done, all these informations are packed into a proof of typet
that is sent to the second peer.
- The second peer generates an initial tree
t'
fromp
and computesf t'
. Once done, it comparest'
's hash andf t'
's hash tobefore
andafter
. If they match, they know that the result statef t'
is a valid context state, without having to have access to the full storage of the first peer.
val kinded_hash_t : kinded_hash Irmin__.Type.t
The type for (internal) inode proofs.
These proofs encode large directories into a tree-like structure.
Invariants are dependent on the backend.
length
is the total number of entries in the children of the inode. It's the size of the "flattened" version of that inode. length
can be used to prove the correctness of operations such as Tree.length
and Tree.list ~offset ~length
in an efficient way.
proofs
contains the children proofs. It is a sparse list of 'a
values. These values are associated to their index in the list, and the list is kept sorted in increasing order of indices. 'a
can be a concrete proof or a hash of that proof.
For irmin-pack
: proofs
have a length of at most Conf.entries
entries. For binary trees, this boolean index is a step of the left-right sequence / decision proof corresponding to the path in that binary tree.
val inode_t : 'a Irmin__.Type.t -> 'a inode Irmin__.Type.t
The type for inode extenders.
An extender is a compact representation of a sequence of inode
which contain only one child. As for inodes, the 'a
parameter can be a concrete proof or a hash of that proof.
If an inode proof contains singleton children i_0, ..., i_n
such as: {length=l; proofs = [ (i_0, {proofs = ... { proofs = [ (i_n, p) ] }})]}
, then it is compressed into the inode extender {length=l; segment = [i_0;..;i_n]; proof=p}
sharing the same length l
and final proof p
.
val inode_extender_t : 'a Irmin__.Type.t -> 'a inode_extender Irmin__.Type.t
type tree =
| Contents of contents * metadata
| Blinded_contents of hash * metadata
| Node of (step * tree) list
| Blinded_node of hash
| Inode of inode_tree inode
| Extender of inode_tree inode_extender
The type for compressed and partial Merkle tree proofs.
Tree proofs do not provide any guarantee with the ordering of computations. For instance, if two effects commute, they won't be distinguishable by this kind of proof.
Value v
proves that a value v
exists in the store.
Blinded_value h
proves a value with hash h
exists in the store.
Node ls
proves that a a "flat" node containing the list of files ls
exists in the store. For irmin-pack
: the length of ls
is at most Conf.stable_hash
;
Blinded_node h
proves that a node with hash h
exists in the store.
Inode i
proves that an inode i
exists in the store.
Extender e
proves that an inode extender e
exist in the store.
and inode_tree =
| Blinded_inode of hash
| Inode_values of (step * tree) list
| Inode_tree of inode_tree inode
| Inode_extender of inode_tree inode_extender
The type for inode trees. It is a subset of tree
, limited to nodes.
Blinded_inode h
proves that an inode with hash h
exists in the store.
Inode_values ls
is simliar to trees' Node
.
Inode_tree i
is similar to tree's Inode
.
Inode_extender e
is similar to trees' Extender
.
val tree_t : tree Irmin__.Type.t
val inode_tree_t : inode_tree Irmin__.Type.t
The type for Merkle proofs.
A proof p
proves that the state advanced from before p
to after p
. state p
's hash is before p
, and state p
contains the minimal information for the computation to reach after p
.
val t : t Irmin__.Type.t
val v : before:kinded_hash -> after:kinded_hash -> tree -> t
v ~before ~after p
proves that the state advanced from before
to after
. p
's hash is before
, and p
contains the minimal information for the computation to reach after
.
val before : t -> kinded_hash
before t
it the state's hash at the beginning of the computation.
val after : t -> kinded_hash
after t
is the state's hash at the end of the computation.
state t
is a subset of the initial state needed to prove that the proven computation could run without performing any I/O.