Skip to content

Commit 1c5a0d2

Browse files
author
Docs Syncer
committed
CI: 95969bf
1 parent 1b7cef7 commit 1c5a0d2

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

docs/reference/contracts/libs/data-structures/SparseMerkleTree.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ uintTree.getRoot();
6161
6262
SparseMerkleTree.Proof memory proof = uintTree.getProof(100);
6363
64+
uintTree.verifyProof(proof);
65+
6466
uintTree.getNodeByKey(100);
6567
6668
uintTree.remove(100);
@@ -448,6 +450,34 @@ Return values:
448450
| :--- | :---------------------------- | :---------------- |
449451
| [0] | struct SparseMerkleTree.Proof | SMT proof struct. |
450452

453+
### verifyProof
454+
455+
```solidity
456+
function verifyProof(
457+
SparseMerkleTree.UintSMT storage tree,
458+
SparseMerkleTree.Proof memory proof_
459+
) internal view returns (bool)
460+
```
461+
462+
The function to verify the proof for inclusion or exclusion of a node in the SMT.
463+
Complexity is O(log(n)), where n is the max depth of the tree.
464+
465+
466+
467+
Parameters:
468+
469+
| Name | Type | Description |
470+
| :----- | :------------------------------ | :--------------------- |
471+
| tree | struct SparseMerkleTree.UintSMT | self. |
472+
| proof_ | struct SparseMerkleTree.Proof | The SMT proof struct. |
473+
474+
475+
Return values:
476+
477+
| Name | Type | Description |
478+
| :--- | :--- | :------------------------------------------- |
479+
| [0] | bool | True if the proof is valid, false otherwise. |
480+
451481
### getRoot
452482

453483
```solidity
@@ -775,6 +805,34 @@ Return values:
775805
| :--- | :---------------------------- | :---------------- |
776806
| [0] | struct SparseMerkleTree.Proof | SMT proof struct. |
777807

808+
### verifyProof
809+
810+
```solidity
811+
function verifyProof(
812+
SparseMerkleTree.Bytes32SMT storage tree,
813+
SparseMerkleTree.Proof memory proof_
814+
) internal view returns (bool)
815+
```
816+
817+
The function to verify the proof for inclusion or exclusion of a node in the SMT.
818+
Complexity is O(log(n)), where n is the max depth of the tree.
819+
820+
821+
822+
Parameters:
823+
824+
| Name | Type | Description |
825+
| :----- | :--------------------------------- | :--------------------- |
826+
| tree | struct SparseMerkleTree.Bytes32SMT | self. |
827+
| proof_ | struct SparseMerkleTree.Proof | The SMT proof struct. |
828+
829+
830+
Return values:
831+
832+
| Name | Type | Description |
833+
| :--- | :--- | :------------------------------------------- |
834+
| [0] | bool | True if the proof is valid, false otherwise. |
835+
778836
### getRoot
779837

780838
```solidity
@@ -1102,6 +1160,34 @@ Return values:
11021160
| :--- | :---------------------------- | :---------------- |
11031161
| [0] | struct SparseMerkleTree.Proof | SMT proof struct. |
11041162

1163+
### verifyProof
1164+
1165+
```solidity
1166+
function verifyProof(
1167+
SparseMerkleTree.AddressSMT storage tree,
1168+
SparseMerkleTree.Proof memory proof_
1169+
) internal view returns (bool)
1170+
```
1171+
1172+
The function to verify the proof for inclusion or exclusion of a node in the SMT.
1173+
Complexity is O(log(n)), where n is the max depth of the tree.
1174+
1175+
1176+
1177+
Parameters:
1178+
1179+
| Name | Type | Description |
1180+
| :----- | :--------------------------------- | :--------------------- |
1181+
| tree | struct SparseMerkleTree.AddressSMT | self. |
1182+
| proof_ | struct SparseMerkleTree.Proof | The SMT proof struct. |
1183+
1184+
1185+
Return values:
1186+
1187+
| Name | Type | Description |
1188+
| :--- | :--- | :------------------------------------------- |
1189+
| [0] | bool | True if the proof is valid, false otherwise. |
1190+
11051191
### getRoot
11061192

11071193
```solidity

0 commit comments

Comments
 (0)