2021-09-27 16:07:59 +00:00
|
|
|
# Single leaf merkle proof tests
|
|
|
|
|
|
|
|
This series of tests provides reference test vectors for validating correct
|
|
|
|
generation and verification of merkle proofs based on static data.
|
|
|
|
|
|
|
|
## Test case format
|
|
|
|
|
2022-10-28 18:32:33 +00:00
|
|
|
Tests for each individual SSZ type are grouped into a `suite` indicating the SSZ type name.
|
2022-10-27 19:59:17 +00:00
|
|
|
|
|
|
|
### `object.yaml`
|
|
|
|
|
2022-10-28 18:32:33 +00:00
|
|
|
A SSZ-snappy encoded object from which other data is generated. The SSZ type can be determined from the test `suite` name.
|
2021-09-27 16:07:59 +00:00
|
|
|
|
|
|
|
### `proof.yaml`
|
|
|
|
|
2022-10-27 19:59:17 +00:00
|
|
|
A proof of the leaf value (a merkle root) at generalized-index `leaf_index` in the given `object`.
|
2021-09-27 16:07:59 +00:00
|
|
|
|
|
|
|
```yaml
|
|
|
|
leaf: Bytes32 # string, hex encoded, with 0x prefix
|
|
|
|
leaf_index: int # integer, decimal
|
2022-10-27 19:59:17 +00:00
|
|
|
branch: list of Bytes32 # list, each element is a string, hex encoded, with 0x prefix
|
2021-09-27 16:07:59 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Condition
|
|
|
|
|
|
|
|
A test-runner can implement the following assertions:
|
|
|
|
- Check that `is_valid_merkle_branch` confirms `leaf` at `leaf_index` to verify
|
2022-10-27 19:59:17 +00:00
|
|
|
against `hash_tree_root(object)` and `branch`.
|
2021-09-27 16:07:59 +00:00
|
|
|
- If the implementation supports generating merkle proofs, check that the
|
2022-10-27 19:59:17 +00:00
|
|
|
self-generated proof matches the `branch` provided with the test.
|