Version 1 - mainnet - 0x27...b46212
Readme
Versions
1
Dependencies
0
Dependents
0
Analytics
On the way
Merkle Proof is a library for verifying Merkle proofs, commonly used in blockchain applications for efficient and secure verification of data inclusion.
The package provides core functions for working with Merkle proofs, including:
These functions are essential for implementing secure verification of data inclusion in Merkle trees.
merkle_proof# testnet
mvr add @interest/merkle-proof --network testnet
# mainnet
mvr add @interest/merkle-proof --network mainnet
To add this library to your project, add this to your Move.toml.
# goes into [dependencies] section
interest_merkle_proof = { r.mvr = "@interest/merkle-proof" }
# add this section to your Move.toml
[r.mvr]
network = "mainnet"
The package is deployed on Sui Network mainnet at: 0x2753893a5c7cab6c6509f3cfc93fdb99fddd477d70562d3c9517bbb62cb46212
The package is deployed on Sui Network testnet at: 0xed80808cc1ab8d45b44a1d43b2a86b5655d185f19a60e07ab2f01a24c95e6a2f
In your code, import and use the package as:
module my::awesome_project;
use interest_merkle_proof::merkle_proof;
public fun verify_inclusion(
proof: vector<vector<u8>>,
root: vector<u8>,
leaf: vector<u8>,
hash: |vector<u8>| -> vector<u8>
): bool {
merkle_proof::verify!(proof, root, leaf, hash)
}
public fun verify_with_position(
proof: vector<vector<u8>>,
root: vector<u8>,
leaf: vector<u8>,
hash: |vector<u8>| -> vector<u8>
): (bool, u256) {
merkle_proof::verify_with_index!(proof, root, leaf, hash)
}
verify: Verifies a Merkle proof against a root hash.
public macro fun verify(
$proof: vector<vector<u8>>,
$root: vector<u8>,
$leaf: vector<u8>,
$hash: |vector<u8>| -> vector<u8>,
): bool
verify_with_index: Verifies a Merkle proof and returns the position index.
public macro fun verify_with_index(
$proof: vector<vector<u8>>,
$root: vector<u8>,
$leaf: vector<u8>,
$hash: |vector<u8>| -> vector<u8>,
): (bool, u256)
process_proof: Processes a Merkle proof to compute the root hash.
public macro fun process_proof(
$proof: vector<vector<u8>>,
$leaf: vector<u8>,
$hash: |vector<u8>| -> vector<u8>,
): vector<u8
hash_pair: Efficiently hashes a pair of values in a consistent order.
public macro fun hash_pair(
$a: vector<u8>,
$b: vector<u8>,
$hash: |vector<u8>| -> vector<u8>,
): vector<u8>
Errors are encoded in u64.
| Error code | Reason |
|---|---|
| 0 | Proof item has a different length to the computed hash |
This is provided on an "as is" and "as available" basis.
We do not give any warranties and will not be liable for any loss incurred through any use of this codebase.
While Interest Merkle Proof has been tested, there may be parts that may exhibit unexpected emergent behavior when used with other code, or may break in future Move versions.
Please always include your own thorough tests when using Interest Merkle Proof to make sure it works correctly with your code.
This package is licensed under Apache-2.0.
You can install this package in your Move project by calling
mvr add @interest/merkle-proofMerkle Proof is a library for verifying Merkle proofs, commonly used in blockchain applications for efficient and secure verification of data inclusion.
jose@interestprotocol.com