Struct zk_kit_smt::smt::SMT
source · pub struct SMT { /* private fields */ }
Implementations§
source§impl SMT
impl SMT
sourcepub fn new(hash: HashFunction, big_numbers: bool) -> Self
pub fn new(hash: HashFunction, big_numbers: bool) -> Self
sourcepub fn add(&mut self, key: Key, value: Value) -> Result<(), SMTError>
pub fn add(&mut self, key: Key, value: Value) -> Result<(), SMTError>
Adds a new key-value pair to the SMT.
It retrieves a matching entry or a zero node with a top-down approach and then it updates all the hashes of the nodes in the path of the new entry with a bottom up approach.
§Arguments
key
- The key to add.value
- The value associated with the key.
§Returns
An Result
indicating whether the operation was successful or not.
sourcepub fn update(&mut self, key: Key, value: Value) -> Result<(), SMTError>
pub fn update(&mut self, key: Key, value: Value) -> Result<(), SMTError>
Updates the value associated with the given key in the SMT.
Also in this case, all the hashes of the nodes in the path of the updated entry are updated with a bottom up approach.
§Arguments
key
- The key to update the value for.value
- The new value associated with the key.
§Returns
An Result
indicating whether the operation was successful or not.
sourcepub fn delete(&mut self, key: Key) -> Result<(), SMTError>
pub fn delete(&mut self, key: Key) -> Result<(), SMTError>
Deletes the key-value pair associated with the given key from the SMT.
Also in this case, all the hashes of the nodes in the path of the deleted entry are updated with a bottom up approach.
§Arguments
key
- The key to delete.
§Returns
An Result
indicating whether the operation was successful or not.