This code has not been reviewed and is not safe to use in non-research capacities.
This is a proof of concept implement 7E6C ation of Verkle Tries. Any and all mistakes made are mine and are not reflective of the protocol.
This implementation will be magnitudes times slow as currently we are committing to the polynomials in coefficient form, so each branch node in the path requires an 2^10 IFFT .
-
The code has been intentionally implemented in a different way in most places to check for consistency and any misunderstandings. For example, recursion is not used as much when inserting leaves. This means that the code will be more verbose as we need to compute exactly when the algorithm will stop ahead of time.
-
An arena is used to allocate node data, which further changes the way the code looks.
-
Consistency between implementations has not been tested and most likely will not be the case as hash_to_fr for example, is implemented differently in golang.
This implementation references the go-verkle implementation : https://github.com/gballet/go-verkle
It also uses the kzg scheme referenced here for multi-point proofs: https://notes.ethereum.org/nrQqhVpQRi6acQckwm1Ryg
use verkle_trie::{dummy_setup, Key, Value, VerkleTrie};
// Trusted setup
let srs_poly_degree = 1024;
let (commit_key, opening_key) = dummy_setup(srs_poly_degree);
// Create a trie and insert two values
let mut trie = VerkleTrie::new();
trie.insert(Key::one(), Value::one());
trie.insert(Key::zero(), Value::one());
// Create a VerklePath for key
let verkle_path = trie.create_path(&Key::one(), &commit_key).unwrap();
// Create a VerkleProof
let verkle_proof = verkle_path.create_proof(&commit_key);
// Verification here means that the KZG10 proof passed
//
// To "finish" the proof, the verifier should check the hash of leaf node themselves
let ok = verkle_proof.verify(
&opening_key,
&verkle_path.commitments,
&verkle_path.omega_path_indices,
&verkle_path.node_roots,
);
assert!(ok);MIT/APACHE