blobstream-contracts 0.0.1-security → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of blobstream-contracts might be problematic. Click here for more details.
- package/.codecov.yml +51 -0
- package/.github/CODEOWNERS +7 -0
- package/.github/dependabot.yml +18 -0
- package/.github/workflows/code-analysis.yml +41 -0
- package/.github/workflows/contract-inheritance-check.yml +28 -0
- package/.github/workflows/go-check.yml +25 -0
- package/.github/workflows/labels.yml +19 -0
- package/.github/workflows/lint.yml +37 -0
- package/.github/workflows/tests.yml +72 -0
- package/.gitmodules +12 -0
- package/.golangci.yml +64 -0
- package/.markdownlint.yaml +5 -0
- package/.markdownlint.yml +4 -0
- package/.markdownlintignore +1 -0
- package/.prettierrc.json +11 -0
- package/LICENSE +201 -0
- package/Makefile +18 -0
- package/README.md +102 -5
- package/docs/inclusion-proofs.md +69 -0
- package/foundry.toml +4 -0
- package/go.mod +34 -0
- package/go.sum +212 -0
- package/hardhat.config.ts +46 -0
- package/index.js +16 -0
- package/package.json +31 -3
- package/remappings.txt +6 -0
- package/scripts/Dockerfile_Environment +39 -0
- package/scripts/deploy.ts +12 -0
- package/scripts/gen.sh +34 -0
- package/scripts/upgradability_check.sh +22 -0
- package/slither.config.json +3 -0
- package/src/Blobstream.sol +366 -0
- package/src/Constants.sol +10 -0
- package/src/DataRootTuple.sol +15 -0
- package/src/IDAOracle.sol +18 -0
- package/src/lib/tree/Constants.sol +23 -0
- package/src/lib/tree/Types.sol +37 -0
- package/src/lib/tree/Utils.sol +106 -0
- package/src/lib/tree/binary/BinaryMerkleMultiproof.sol +12 -0
- package/src/lib/tree/binary/BinaryMerkleProof.sol +12 -0
- package/src/lib/tree/binary/BinaryMerkleTree.sol +256 -0
- package/src/lib/tree/binary/TreeHasher.sol +23 -0
- package/src/lib/tree/binary/test/BinaryMerkleTree.t.sol +365 -0
- package/src/lib/tree/binary/test/TreeHasher.t.sol +40 -0
- package/src/lib/tree/namespace/NamespaceMerkleMultiproof.sol +14 -0
- package/src/lib/tree/namespace/NamespaceMerkleProof.sol +14 -0
- package/src/lib/tree/namespace/NamespaceMerkleTree.sol +306 -0
- package/src/lib/tree/namespace/NamespaceNode.sol +23 -0
- package/src/lib/tree/namespace/TreeHasher.sol +69 -0
- package/src/lib/tree/namespace/test/NamespaceMerkleMultiproof.t.sol +108 -0
- package/src/lib/tree/namespace/test/NamespaceMerkleTree.t.sol +644 -0
- package/src/lib/tree/namespace/test/TreeHasher.t.sol +66 -0
- package/src/lib/tree/test/Utils.t.sol +48 -0
- package/src/lib/tree/test/blob.dat +0 -0
- package/src/lib/tree/test/header.dat +0 -0
- package/src/lib/tree/test/proofs.json +1 -0
- package/src/lib/verifier/DAVerifier.sol +328 -0
- package/src/lib/verifier/test/DAVerifier.t.sol +396 -0
- package/src/lib/verifier/test/RollupInclusionProofs.t.sol +589 -0
- package/src/test/Blobstream.t.sol +200 -0
- package/src/test/BlobstreamBenchmark.t.sol +137 -0
- package/tsconfig.json +11 -0
- package/wrappers/Blobstream.sol/wrapper.go +1325 -0
- package/wrappers/ERC1967Proxy.sol/wrapper.go +668 -0
@@ -0,0 +1,644 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
pragma solidity ^0.8.22;
|
3
|
+
|
4
|
+
import "ds-test/test.sol";
|
5
|
+
|
6
|
+
import "../NamespaceNode.sol";
|
7
|
+
import "../NamespaceMerkleProof.sol";
|
8
|
+
import "../NamespaceMerkleTree.sol";
|
9
|
+
import "../../Constants.sol";
|
10
|
+
|
11
|
+
/**
|
12
|
+
* TEST VECTORS
|
13
|
+
*
|
14
|
+
* Data blocks: Namespace, data
|
15
|
+
* Data blocks: Namespace, data
|
16
|
+
* 0x0000000000000000000000000000000000000000000000000000000010 0x01
|
17
|
+
* 0x0000000000000000000000000000000000000000000000000000000020 0x02
|
18
|
+
* 0x0000000000000000000000000000000000000000000000000000000030 0x03
|
19
|
+
* 0x0000000000000000000000000000000000000000000000000000000040 0x04
|
20
|
+
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x05
|
21
|
+
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x06
|
22
|
+
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x07
|
23
|
+
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x08
|
24
|
+
*
|
25
|
+
* Leaf nodes: min namespace, max namespace, data
|
26
|
+
* 0x0000000000000000000000000000000000000000000000000000000010 0x0000000000000000000000000000000000000000000000000000000010 0xfdb4e3c872666aa9869a1d46c8a5a0e735becdf17c62b9c3ccf4258449475bda
|
27
|
+
* 0x0000000000000000000000000000000000000000000000000000000020 0x0000000000000000000000000000000000000000000000000000000020 0xc5fd5617b70207108c8d9bcf624b1eedf39b763af86f660255947674e043cd2c
|
28
|
+
* 0x0000000000000000000000000000000000000000000000000000000030 0x0000000000000000000000000000000000000000000000000000000030 0x35e864d3e196ef0986fcf18eea2782c7e68794c7106dacc2a4f7e40d6d7c7069
|
29
|
+
* 0x0000000000000000000000000000000000000000000000000000000040 0x0000000000000000000000000000000000000000000000000000000040 0xecdeb08b04dd92a17fec560e20c53269f65beff5a2626fa64f61bfa45b09119d
|
30
|
+
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x1617cc7010feae70f9ff07028da463c65ec19b1d6bafde31c7543718025e5efb
|
31
|
+
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x671157a4e268f7060abbdc4b48f091589555a0775a2694e6899833ec98fdb296
|
32
|
+
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x2669e36b48e95bd9903300e50c27c53984fc439f6235fade08e3f14e78a42aac
|
33
|
+
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x655790e24d376e9556a3cba9908a5d97f27faa050806ecfcb481861a83240bd5
|
34
|
+
*
|
35
|
+
* Inner nodes(depth = 2): min namespace, max namespace, data
|
36
|
+
* 0x0000000000000000000000000000000000000000000000000000000010 0x0000000000000000000000000000000000000000000000000000000020 0x1dae5c3d39a8bf31ea33ba368238a52f816cd50485c580565609554cf360c91f
|
37
|
+
* 0x0000000000000000000000000000000000000000000000000000000030 0x0000000000000000000000000000000000000000000000000000000040 0x2aa20c7587b009772a9a88402b7cc8fcb82edc9e31754e95544a670a696f55a7
|
38
|
+
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x055a3ea75c438d752aeabbba94ed8fac93e0b32321256a65fde176dba14f5186
|
39
|
+
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x1b79ffd74644e8c287fe5f1dd70bc8ea02738697cebf2810ffb2dc5157485c40
|
40
|
+
*
|
41
|
+
* Inner nodes(depth = 1): min namespace, max namespace, data
|
42
|
+
* 0x0000000000000000000000000000000000000000000000000000000010 0x0000000000000000000000000000000000000000000000000000000040 0xa8dcd9f365fb64aa6d72b5027fe74db0fc7d009c2d75c7b9b9656927281cb35e
|
43
|
+
* 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0x5aa3e7ea31995fdd38f41015275229b290a8ee4810521db766ad457b9a8373d6
|
44
|
+
*
|
45
|
+
* Root node: min namespace, max namespace, data
|
46
|
+
* 0x0000000000000000000000000000000000000000000000000000000010 0x0000000000000000000000000000000000000000000000000000000040 0x34e6541306dc4e57a5a2a9ef57a46d5705ed09efb8c6a02580d3a972922b6862
|
47
|
+
*
|
48
|
+
*/
|
49
|
+
contract NamespaceMerkleTreeTest is DSTest {
|
50
|
+
function setUp() external {}
|
51
|
+
|
52
|
+
function assertEqNamespaceNode(NamespaceNode memory first, NamespaceNode memory second) internal {
|
53
|
+
assertTrue(first.min.equalTo(second.min));
|
54
|
+
assertTrue(first.max.equalTo(second.max));
|
55
|
+
assertEq(first.digest, second.digest);
|
56
|
+
}
|
57
|
+
|
58
|
+
function testVerifyNone() external {
|
59
|
+
Namespace memory nid = Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000000);
|
60
|
+
NamespaceNode memory root = NamespaceNode(nid, nid, sha256(""));
|
61
|
+
NamespaceNode[] memory sideNodes;
|
62
|
+
uint256 key = 0;
|
63
|
+
uint256 numLeaves = 0;
|
64
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
65
|
+
bytes memory data;
|
66
|
+
bool isValid = NamespaceMerkleTree.verify(root, proof, nid, data);
|
67
|
+
assertTrue(!isValid);
|
68
|
+
}
|
69
|
+
|
70
|
+
function testVerifyOneLeafEmpty() external {
|
71
|
+
Namespace memory nid = Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000000);
|
72
|
+
NamespaceNode memory root =
|
73
|
+
NamespaceNode(nid, nid, 0x0679246d6c4216de0daa08e5523fb2674db2b6599c3b72ff946b488a15290b62);
|
74
|
+
NamespaceNode[] memory sideNodes;
|
75
|
+
uint256 key = 0;
|
76
|
+
uint256 numLeaves = 1;
|
77
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
78
|
+
bytes memory data;
|
79
|
+
bool isValid = NamespaceMerkleTree.verify(root, proof, nid, data);
|
80
|
+
assertTrue(isValid);
|
81
|
+
}
|
82
|
+
|
83
|
+
function testVerifyOneLeafSome() external {
|
84
|
+
Namespace memory nid = Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000000);
|
85
|
+
NamespaceNode memory root =
|
86
|
+
NamespaceNode(nid, nid, 0x56d8381cfe28e8eb21da620145b7b977a74837720da5147b00bfab6f1b4af24d);
|
87
|
+
NamespaceNode[] memory sideNodes;
|
88
|
+
uint256 key = 0;
|
89
|
+
uint256 numLeaves = 1;
|
90
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
91
|
+
bytes memory data = hex"deadbeef";
|
92
|
+
bool isValid = NamespaceMerkleTree.verify(root, proof, nid, data);
|
93
|
+
assertTrue(isValid);
|
94
|
+
}
|
95
|
+
|
96
|
+
function testVerifyOneLeaf01() external {
|
97
|
+
Namespace memory nid = Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000000);
|
98
|
+
NamespaceNode memory root =
|
99
|
+
NamespaceNode(nid, nid, 0x353857cdb4c745eb9fdebbd8ec44093fabb9f08d437e2298d9e6afa1a409b30c);
|
100
|
+
NamespaceNode[] memory sideNodes;
|
101
|
+
uint256 key = 0;
|
102
|
+
uint256 numLeaves = 1;
|
103
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
104
|
+
bytes memory data = hex"01";
|
105
|
+
bool isValid = NamespaceMerkleTree.verify(root, proof, nid, data);
|
106
|
+
assertTrue(isValid);
|
107
|
+
}
|
108
|
+
|
109
|
+
function testVerifyLeafOneOfTwo() external {
|
110
|
+
NamespaceNode memory root = NamespaceNode(
|
111
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
112
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000020),
|
113
|
+
0x1dae5c3d39a8bf31ea33ba368238a52f816cd50485c580565609554cf360c91f
|
114
|
+
);
|
115
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](1);
|
116
|
+
sideNodes[0] = NamespaceNode(
|
117
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000020),
|
118
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000020),
|
119
|
+
0xc5fd5617b70207108c8d9bcf624b1eedf39b763af86f660255947674e043cd2c
|
120
|
+
);
|
121
|
+
|
122
|
+
uint256 key = 0;
|
123
|
+
uint256 numLeaves = 2;
|
124
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
125
|
+
bytes memory data = hex"01";
|
126
|
+
bool isValid = NamespaceMerkleTree.verify(
|
127
|
+
root, proof, Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010), data
|
128
|
+
);
|
129
|
+
assertTrue(isValid);
|
130
|
+
}
|
131
|
+
|
132
|
+
function testVerifyLeafOneOfFour() external {
|
133
|
+
NamespaceNode memory root = NamespaceNode(
|
134
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
135
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
136
|
+
0xa8dcd9f365fb64aa6d72b5027fe74db0fc7d009c2d75c7b9b9656927281cb35e
|
137
|
+
);
|
138
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](2);
|
139
|
+
sideNodes[0] = NamespaceNode(
|
140
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000020),
|
141
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000020),
|
142
|
+
0xc5fd5617b70207108c8d9bcf624b1eedf39b763af86f660255947674e043cd2c
|
143
|
+
);
|
144
|
+
sideNodes[1] = NamespaceNode(
|
145
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000030),
|
146
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
147
|
+
0x2aa20c7587b009772a9a88402b7cc8fcb82edc9e31754e95544a670a696f55a7
|
148
|
+
);
|
149
|
+
|
150
|
+
uint256 key = 0;
|
151
|
+
uint256 numLeaves = 4;
|
152
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
153
|
+
bytes memory data = hex"01";
|
154
|
+
bool isValid = NamespaceMerkleTree.verify(
|
155
|
+
root, proof, Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010), data
|
156
|
+
);
|
157
|
+
assertTrue(isValid);
|
158
|
+
}
|
159
|
+
|
160
|
+
function testVerifyLeafOneOfEight() external {
|
161
|
+
NamespaceNode memory root = NamespaceNode(
|
162
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
163
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
164
|
+
0x34e6541306dc4e57a5a2a9ef57a46d5705ed09efb8c6a02580d3a972922b6862
|
165
|
+
);
|
166
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](3);
|
167
|
+
sideNodes[0] = NamespaceNode(
|
168
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000020),
|
169
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000020),
|
170
|
+
0xc5fd5617b70207108c8d9bcf624b1eedf39b763af86f660255947674e043cd2c
|
171
|
+
);
|
172
|
+
sideNodes[1] = NamespaceNode(
|
173
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000030),
|
174
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
175
|
+
0x2aa20c7587b009772a9a88402b7cc8fcb82edc9e31754e95544a670a696f55a7
|
176
|
+
);
|
177
|
+
sideNodes[2] = NamespaceNode(
|
178
|
+
PARITY_SHARE_NAMESPACE(),
|
179
|
+
PARITY_SHARE_NAMESPACE(),
|
180
|
+
0x5aa3e7ea31995fdd38f41015275229b290a8ee4810521db766ad457b9a8373d6
|
181
|
+
);
|
182
|
+
|
183
|
+
uint256 key = 0;
|
184
|
+
uint256 numLeaves = 8;
|
185
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
186
|
+
bytes memory data = hex"01";
|
187
|
+
bool isValid = NamespaceMerkleTree.verify(
|
188
|
+
root, proof, Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010), data
|
189
|
+
);
|
190
|
+
assertTrue(isValid);
|
191
|
+
}
|
192
|
+
|
193
|
+
function testVerifyLeafSevenOfEight() external {
|
194
|
+
NamespaceNode memory root = NamespaceNode(
|
195
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
196
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
197
|
+
0x34e6541306dc4e57a5a2a9ef57a46d5705ed09efb8c6a02580d3a972922b6862
|
198
|
+
);
|
199
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](3);
|
200
|
+
sideNodes[0] = NamespaceNode(
|
201
|
+
PARITY_SHARE_NAMESPACE(),
|
202
|
+
PARITY_SHARE_NAMESPACE(),
|
203
|
+
0x655790e24d376e9556a3cba9908a5d97f27faa050806ecfcb481861a83240bd5
|
204
|
+
);
|
205
|
+
sideNodes[1] = NamespaceNode(
|
206
|
+
PARITY_SHARE_NAMESPACE(),
|
207
|
+
PARITY_SHARE_NAMESPACE(),
|
208
|
+
0x055a3ea75c438d752aeabbba94ed8fac93e0b32321256a65fde176dba14f5186
|
209
|
+
);
|
210
|
+
sideNodes[2] = NamespaceNode(
|
211
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
212
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
213
|
+
0xa8dcd9f365fb64aa6d72b5027fe74db0fc7d009c2d75c7b9b9656927281cb35e
|
214
|
+
);
|
215
|
+
|
216
|
+
uint256 key = 6;
|
217
|
+
uint256 numLeaves = 8;
|
218
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
219
|
+
bytes memory data = hex"07";
|
220
|
+
bool isValid = NamespaceMerkleTree.verify(root, proof, PARITY_SHARE_NAMESPACE(), data);
|
221
|
+
assertTrue(isValid);
|
222
|
+
}
|
223
|
+
|
224
|
+
function testVerifyLeafEightOfEight() external {
|
225
|
+
NamespaceNode memory root = NamespaceNode(
|
226
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
227
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
228
|
+
0x34e6541306dc4e57a5a2a9ef57a46d5705ed09efb8c6a02580d3a972922b6862
|
229
|
+
);
|
230
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](3);
|
231
|
+
sideNodes[0] = NamespaceNode(
|
232
|
+
PARITY_SHARE_NAMESPACE(),
|
233
|
+
PARITY_SHARE_NAMESPACE(),
|
234
|
+
0x2669e36b48e95bd9903300e50c27c53984fc439f6235fade08e3f14e78a42aac
|
235
|
+
);
|
236
|
+
sideNodes[1] = NamespaceNode(
|
237
|
+
PARITY_SHARE_NAMESPACE(),
|
238
|
+
PARITY_SHARE_NAMESPACE(),
|
239
|
+
0x055a3ea75c438d752aeabbba94ed8fac93e0b32321256a65fde176dba14f5186
|
240
|
+
);
|
241
|
+
sideNodes[2] = NamespaceNode(
|
242
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
243
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
244
|
+
0xa8dcd9f365fb64aa6d72b5027fe74db0fc7d009c2d75c7b9b9656927281cb35e
|
245
|
+
);
|
246
|
+
|
247
|
+
uint256 key = 7;
|
248
|
+
uint256 numLeaves = 8;
|
249
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
250
|
+
bytes memory data = hex"08";
|
251
|
+
bool isValid = NamespaceMerkleTree.verify(root, proof, PARITY_SHARE_NAMESPACE(), data);
|
252
|
+
assertTrue(isValid);
|
253
|
+
}
|
254
|
+
|
255
|
+
function testVerifyLeafFiveOfEight() external {
|
256
|
+
NamespaceNode memory root = NamespaceNode(
|
257
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
258
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
259
|
+
0x34e6541306dc4e57a5a2a9ef57a46d5705ed09efb8c6a02580d3a972922b6862
|
260
|
+
);
|
261
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](3);
|
262
|
+
sideNodes[0] = NamespaceNode(
|
263
|
+
PARITY_SHARE_NAMESPACE(),
|
264
|
+
PARITY_SHARE_NAMESPACE(),
|
265
|
+
0x671157a4e268f7060abbdc4b48f091589555a0775a2694e6899833ec98fdb296
|
266
|
+
);
|
267
|
+
sideNodes[1] = NamespaceNode(
|
268
|
+
PARITY_SHARE_NAMESPACE(),
|
269
|
+
PARITY_SHARE_NAMESPACE(),
|
270
|
+
0x1b79ffd74644e8c287fe5f1dd70bc8ea02738697cebf2810ffb2dc5157485c40
|
271
|
+
);
|
272
|
+
sideNodes[2] = NamespaceNode(
|
273
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
274
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
275
|
+
0xa8dcd9f365fb64aa6d72b5027fe74db0fc7d009c2d75c7b9b9656927281cb35e
|
276
|
+
);
|
277
|
+
|
278
|
+
uint256 key = 4;
|
279
|
+
uint256 numLeaves = 8;
|
280
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
281
|
+
bytes memory data = hex"05";
|
282
|
+
bool isValid = NamespaceMerkleTree.verify(root, proof, PARITY_SHARE_NAMESPACE(), data);
|
283
|
+
assertTrue(isValid);
|
284
|
+
}
|
285
|
+
|
286
|
+
function testVerifyLeafFourOfEight() external {
|
287
|
+
NamespaceNode memory root = NamespaceNode(
|
288
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
289
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
290
|
+
0x34e6541306dc4e57a5a2a9ef57a46d5705ed09efb8c6a02580d3a972922b6862
|
291
|
+
);
|
292
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](3);
|
293
|
+
sideNodes[0] = NamespaceNode(
|
294
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000030),
|
295
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000030),
|
296
|
+
0x35e864d3e196ef0986fcf18eea2782c7e68794c7106dacc2a4f7e40d6d7c7069
|
297
|
+
);
|
298
|
+
sideNodes[1] = NamespaceNode(
|
299
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
300
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000020),
|
301
|
+
0x1dae5c3d39a8bf31ea33ba368238a52f816cd50485c580565609554cf360c91f
|
302
|
+
);
|
303
|
+
sideNodes[2] = NamespaceNode(
|
304
|
+
PARITY_SHARE_NAMESPACE(),
|
305
|
+
PARITY_SHARE_NAMESPACE(),
|
306
|
+
0x5aa3e7ea31995fdd38f41015275229b290a8ee4810521db766ad457b9a8373d6
|
307
|
+
);
|
308
|
+
|
309
|
+
uint256 key = 3;
|
310
|
+
uint256 numLeaves = 8;
|
311
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
312
|
+
bytes memory data = hex"04";
|
313
|
+
bool isValid = NamespaceMerkleTree.verify(
|
314
|
+
root, proof, Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040), data
|
315
|
+
);
|
316
|
+
assertTrue(isValid);
|
317
|
+
}
|
318
|
+
|
319
|
+
function testVerifyLeafThreeOfEight() external {
|
320
|
+
NamespaceNode memory root = NamespaceNode(
|
321
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
322
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
323
|
+
0x34e6541306dc4e57a5a2a9ef57a46d5705ed09efb8c6a02580d3a972922b6862
|
324
|
+
);
|
325
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](3);
|
326
|
+
sideNodes[0] = NamespaceNode(
|
327
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
328
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
329
|
+
0xecdeb08b04dd92a17fec560e20c53269f65beff5a2626fa64f61bfa45b09119d
|
330
|
+
);
|
331
|
+
sideNodes[1] = NamespaceNode(
|
332
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
333
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000020),
|
334
|
+
0x1dae5c3d39a8bf31ea33ba368238a52f816cd50485c580565609554cf360c91f
|
335
|
+
);
|
336
|
+
sideNodes[2] = NamespaceNode(
|
337
|
+
PARITY_SHARE_NAMESPACE(),
|
338
|
+
PARITY_SHARE_NAMESPACE(),
|
339
|
+
0x5aa3e7ea31995fdd38f41015275229b290a8ee4810521db766ad457b9a8373d6
|
340
|
+
);
|
341
|
+
|
342
|
+
uint256 key = 2;
|
343
|
+
uint256 numLeaves = 8;
|
344
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
345
|
+
bytes memory data = hex"03";
|
346
|
+
bool isValid = NamespaceMerkleTree.verify(
|
347
|
+
root, proof, Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000030), data
|
348
|
+
);
|
349
|
+
assertTrue(isValid);
|
350
|
+
}
|
351
|
+
|
352
|
+
function testVerifyLeafFiveOfSeven() external {
|
353
|
+
NamespaceNode memory root = NamespaceNode(
|
354
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
355
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
356
|
+
0xfe7100a7170cba2065c48e01cb18772ed93865100bb7610aed3f614829c87a48
|
357
|
+
);
|
358
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](3);
|
359
|
+
sideNodes[0] = NamespaceNode(
|
360
|
+
PARITY_SHARE_NAMESPACE(),
|
361
|
+
PARITY_SHARE_NAMESPACE(),
|
362
|
+
0x671157a4e268f7060abbdc4b48f091589555a0775a2694e6899833ec98fdb296
|
363
|
+
);
|
364
|
+
sideNodes[1] = NamespaceNode(
|
365
|
+
PARITY_SHARE_NAMESPACE(),
|
366
|
+
PARITY_SHARE_NAMESPACE(),
|
367
|
+
0x2669e36b48e95bd9903300e50c27c53984fc439f6235fade08e3f14e78a42aac
|
368
|
+
);
|
369
|
+
sideNodes[2] = NamespaceNode(
|
370
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
371
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
372
|
+
0xa8dcd9f365fb64aa6d72b5027fe74db0fc7d009c2d75c7b9b9656927281cb35e
|
373
|
+
);
|
374
|
+
|
375
|
+
uint256 key = 4;
|
376
|
+
uint256 numLeaves = 7;
|
377
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
378
|
+
bytes memory data = hex"05";
|
379
|
+
bool isValid = NamespaceMerkleTree.verify(root, proof, PARITY_SHARE_NAMESPACE(), data);
|
380
|
+
assertTrue(isValid);
|
381
|
+
}
|
382
|
+
|
383
|
+
function testVerifyLeafNineOfTen() external {
|
384
|
+
NamespaceNode memory root = NamespaceNode(
|
385
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
386
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000060),
|
387
|
+
0x21013157ca1c0d454c988665e05894f5cf9422928552349ac3fd359bd1d39ac1
|
388
|
+
);
|
389
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](2);
|
390
|
+
sideNodes[0] = NamespaceNode(
|
391
|
+
PARITY_SHARE_NAMESPACE(),
|
392
|
+
PARITY_SHARE_NAMESPACE(),
|
393
|
+
0x8ecd4167595d96b6caf19871584b07f255a4d80037b122c9f1f71acb1366a1ae
|
394
|
+
);
|
395
|
+
sideNodes[1] = NamespaceNode(
|
396
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
397
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000060),
|
398
|
+
0xee695202b2d3090a2319e7491483cf50e71a5907cebcf1fed4d02daa02f39827
|
399
|
+
);
|
400
|
+
|
401
|
+
uint256 key = 8;
|
402
|
+
uint256 numLeaves = 10;
|
403
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
404
|
+
bytes memory data = hex"09";
|
405
|
+
bool isValid = NamespaceMerkleTree.verify(root, proof, PARITY_SHARE_NAMESPACE(), data);
|
406
|
+
assertTrue(isValid);
|
407
|
+
}
|
408
|
+
|
409
|
+
function testVerifyLeafTwelveOfThirteen() external {
|
410
|
+
NamespaceNode memory root = NamespaceNode(
|
411
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
412
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000060),
|
413
|
+
0xcdf9d9d4b408a7bf1ec5653dcb5f8cda23a329754890b63344e706302ef70e43
|
414
|
+
);
|
415
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](4);
|
416
|
+
sideNodes[0] = NamespaceNode(
|
417
|
+
PARITY_SHARE_NAMESPACE(),
|
418
|
+
PARITY_SHARE_NAMESPACE(),
|
419
|
+
0x311733a16ba3f14dca59dcd88e6b64276613cac5a9e20a4b228c520722851b3a
|
420
|
+
);
|
421
|
+
sideNodes[1] = NamespaceNode(
|
422
|
+
PARITY_SHARE_NAMESPACE(),
|
423
|
+
PARITY_SHARE_NAMESPACE(),
|
424
|
+
0x8137f8ca69ccd4d39d47836ace7aa22b010222eaa904e67a6ff9bf05542f7124
|
425
|
+
);
|
426
|
+
sideNodes[2] = NamespaceNode(
|
427
|
+
PARITY_SHARE_NAMESPACE(),
|
428
|
+
PARITY_SHARE_NAMESPACE(),
|
429
|
+
0x3666000822ff8e0e5bf01c170264fe39dc38d887a5ec5e87b4f72b328a323ec5
|
430
|
+
);
|
431
|
+
sideNodes[3] = NamespaceNode(
|
432
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
433
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000060),
|
434
|
+
0xee695202b2d3090a2319e7491483cf50e71a5907cebcf1fed4d02daa02f39827
|
435
|
+
);
|
436
|
+
|
437
|
+
uint256 key = 11;
|
438
|
+
uint256 numLeaves = 13;
|
439
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
440
|
+
bytes memory data = hex"0c";
|
441
|
+
bool isValid = NamespaceMerkleTree.verify(root, proof, PARITY_SHARE_NAMESPACE(), data);
|
442
|
+
assertTrue(isValid);
|
443
|
+
}
|
444
|
+
|
445
|
+
function testVerifyLeafThirteenOfThirteen() external {
|
446
|
+
NamespaceNode memory root = NamespaceNode(
|
447
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
448
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000060),
|
449
|
+
0xcdf9d9d4b408a7bf1ec5653dcb5f8cda23a329754890b63344e706302ef70e43
|
450
|
+
);
|
451
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](2);
|
452
|
+
sideNodes[0] = NamespaceNode(
|
453
|
+
PARITY_SHARE_NAMESPACE(),
|
454
|
+
PARITY_SHARE_NAMESPACE(),
|
455
|
+
0x31501dc8a114b0aa3cde0f4f99f0643760b3b11303ab1ee568538f3e5769fbfe
|
456
|
+
);
|
457
|
+
sideNodes[1] = NamespaceNode(
|
458
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
459
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000060),
|
460
|
+
0xee695202b2d3090a2319e7491483cf50e71a5907cebcf1fed4d02daa02f39827
|
461
|
+
);
|
462
|
+
|
463
|
+
uint256 key = 12;
|
464
|
+
uint256 numLeaves = 13;
|
465
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
466
|
+
bytes memory data = hex"0d";
|
467
|
+
bool isValid = NamespaceMerkleTree.verify(root, proof, PARITY_SHARE_NAMESPACE(), data);
|
468
|
+
assertTrue(isValid);
|
469
|
+
}
|
470
|
+
|
471
|
+
function testVerifyInternalNodeOneAndTwoOfFour() external pure {
|
472
|
+
uint256 key = 1;
|
473
|
+
uint256 numLeaves = 4;
|
474
|
+
uint256 startingHeight = 2;
|
475
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](1);
|
476
|
+
|
477
|
+
bytes memory data = hex"01";
|
478
|
+
NamespaceNode memory node1 =
|
479
|
+
leafDigest(Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010), data);
|
480
|
+
NamespaceNode memory node2 =
|
481
|
+
leafDigest(Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000020), data);
|
482
|
+
NamespaceNode memory node3 =
|
483
|
+
leafDigest(Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000030), data);
|
484
|
+
NamespaceNode memory node4 =
|
485
|
+
leafDigest(Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040), data);
|
486
|
+
NamespaceNode memory node1_2 = nodeDigest(node1, node2);
|
487
|
+
NamespaceNode memory node3_4 = nodeDigest(node3, node4);
|
488
|
+
NamespaceNode memory root = nodeDigest(node1_2, node3_4);
|
489
|
+
NamespaceNode memory startingNode = node1_2;
|
490
|
+
|
491
|
+
sideNodes[0] = node3_4;
|
492
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
493
|
+
bool isValid = NamespaceMerkleTree.verifyInner(root, proof, startingNode, startingHeight);
|
494
|
+
assert(isValid);
|
495
|
+
}
|
496
|
+
|
497
|
+
function testVerifyInternalNodeOneAndTwoOfThree() external pure {
|
498
|
+
uint256 key = 0;
|
499
|
+
uint256 numLeaves = 3;
|
500
|
+
uint256 startingHeight = 2;
|
501
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](1);
|
502
|
+
|
503
|
+
bytes memory data = hex"01";
|
504
|
+
NamespaceNode memory node1 =
|
505
|
+
leafDigest(Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010), data);
|
506
|
+
NamespaceNode memory node2 =
|
507
|
+
leafDigest(Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000020), data);
|
508
|
+
NamespaceNode memory node3 =
|
509
|
+
leafDigest(Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000030), data);
|
510
|
+
NamespaceNode memory node1_2 = nodeDigest(node1, node2);
|
511
|
+
NamespaceNode memory root = nodeDigest(node1_2, node3);
|
512
|
+
NamespaceNode memory startingNode = node1_2;
|
513
|
+
|
514
|
+
sideNodes[0] = node3;
|
515
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
516
|
+
bool isValid = NamespaceMerkleTree.verifyInner(root, proof, startingNode, startingHeight);
|
517
|
+
assert(isValid);
|
518
|
+
}
|
519
|
+
|
520
|
+
function testVerifyInnerLeafIsRoot() external {
|
521
|
+
Namespace memory nid = Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000000);
|
522
|
+
NamespaceNode memory root =
|
523
|
+
NamespaceNode(nid, nid, 0xc59fa9c4ec515726c2b342544433f844c7b930cf7a5e7abab593332453ceaf70);
|
524
|
+
NamespaceNode[] memory sideNodes;
|
525
|
+
uint256 key = 0;
|
526
|
+
uint256 numLeaves = 1;
|
527
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
528
|
+
NamespaceNode memory node =
|
529
|
+
NamespaceNode(nid, nid, 0xc59fa9c4ec515726c2b342544433f844c7b930cf7a5e7abab593332453ceaf70);
|
530
|
+
uint256 startingHeight = 1;
|
531
|
+
bool isValid = NamespaceMerkleTree.verifyInner(root, proof, node, startingHeight);
|
532
|
+
assertTrue(isValid);
|
533
|
+
}
|
534
|
+
|
535
|
+
function testVerifyInnerFalseForStartingHeightZero() external {
|
536
|
+
Namespace memory nid = Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000020);
|
537
|
+
NamespaceNode memory root =
|
538
|
+
NamespaceNode(nid, nid, 0xc59fa9c4ec515726c2b342544433f844c7b930cf7a5e7abab593332453ceaf70);
|
539
|
+
NamespaceNode[] memory sideNodes;
|
540
|
+
uint256 key = 0;
|
541
|
+
uint256 numLeaves = 1;
|
542
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
543
|
+
NamespaceNode memory node =
|
544
|
+
NamespaceNode(nid, nid, 0xc59fa9c4ec515726c2b342544433f844c7b930cf7a5e7abab593332453ceaf70);
|
545
|
+
uint256 startingHeight = 0;
|
546
|
+
bool isValid = NamespaceMerkleTree.verifyInner(root, proof, node, startingHeight);
|
547
|
+
assertTrue(!isValid);
|
548
|
+
}
|
549
|
+
|
550
|
+
function testVerifyInnerFalseForTooLargeKey() external {
|
551
|
+
Namespace memory nid = Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000020);
|
552
|
+
NamespaceNode memory root =
|
553
|
+
NamespaceNode(nid, nid, 0xc59fa9c4ec515726c2b342544433f844c7b930cf7a5e7abab593332453ceaf70);
|
554
|
+
NamespaceNode[] memory sideNodes;
|
555
|
+
uint256 key = 3; // key is larger than num leaves
|
556
|
+
uint256 numLeaves = 1;
|
557
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
558
|
+
NamespaceNode memory node =
|
559
|
+
NamespaceNode(nid, nid, 0xc59fa9c4ec515726c2b342544433f844c7b930cf7a5e7abab593332453ceaf70);
|
560
|
+
uint256 startingHeight = 1;
|
561
|
+
bool isValid = NamespaceMerkleTree.verifyInner(root, proof, node, startingHeight);
|
562
|
+
assertTrue(!isValid);
|
563
|
+
}
|
564
|
+
|
565
|
+
function testVerifyInnerFalseForIncorrectProofLength() external {
|
566
|
+
Namespace memory nid = Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000020);
|
567
|
+
NamespaceNode memory root =
|
568
|
+
NamespaceNode(nid, nid, 0xc59fa9c4ec515726c2b342544433f844c7b930cf7a5e7abab593332453ceaf70);
|
569
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](1);
|
570
|
+
sideNodes[0] = NamespaceNode(
|
571
|
+
PARITY_SHARE_NAMESPACE(),
|
572
|
+
PARITY_SHARE_NAMESPACE(),
|
573
|
+
0x24ddc56b10cebbf760b3a744ad3a0e91093db34b4d22995f6de6dac918e38ae5
|
574
|
+
);
|
575
|
+
uint256 key = 0;
|
576
|
+
uint256 numLeaves = 1;
|
577
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
578
|
+
NamespaceNode memory node =
|
579
|
+
NamespaceNode(nid, nid, 0xc59fa9c4ec515726c2b342544433f844c7b930cf7a5e7abab593332453ceaf70);
|
580
|
+
uint256 startingHeight = 1;
|
581
|
+
bool isValid = NamespaceMerkleTree.verifyInner(root, proof, node, startingHeight);
|
582
|
+
assertTrue(!isValid);
|
583
|
+
}
|
584
|
+
|
585
|
+
function testVerifyInnerOneOfEight() external {
|
586
|
+
NamespaceNode memory root = NamespaceNode(
|
587
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
588
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
589
|
+
0x34e6541306dc4e57a5a2a9ef57a46d5705ed09efb8c6a02580d3a972922b6862
|
590
|
+
);
|
591
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](2);
|
592
|
+
sideNodes[0] = NamespaceNode(
|
593
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000030),
|
594
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
595
|
+
0x2aa20c7587b009772a9a88402b7cc8fcb82edc9e31754e95544a670a696f55a7
|
596
|
+
);
|
597
|
+
sideNodes[1] = NamespaceNode(
|
598
|
+
PARITY_SHARE_NAMESPACE(),
|
599
|
+
PARITY_SHARE_NAMESPACE(),
|
600
|
+
0x5aa3e7ea31995fdd38f41015275229b290a8ee4810521db766ad457b9a8373d6
|
601
|
+
);
|
602
|
+
NamespaceNode memory node = NamespaceNode(
|
603
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
604
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000020),
|
605
|
+
0x1dae5c3d39a8bf31ea33ba368238a52f816cd50485c580565609554cf360c91f
|
606
|
+
);
|
607
|
+
|
608
|
+
uint256 key = 0;
|
609
|
+
uint256 numLeaves = 8;
|
610
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
611
|
+
bool isValid = NamespaceMerkleTree.verifyInner(root, proof, node, 2);
|
612
|
+
assertTrue(isValid);
|
613
|
+
}
|
614
|
+
|
615
|
+
function testVerifyInnerSevenOfEight() external {
|
616
|
+
NamespaceNode memory root = NamespaceNode(
|
617
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
618
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
619
|
+
0x34e6541306dc4e57a5a2a9ef57a46d5705ed09efb8c6a02580d3a972922b6862
|
620
|
+
);
|
621
|
+
NamespaceNode[] memory sideNodes = new NamespaceNode[](2);
|
622
|
+
sideNodes[0] = NamespaceNode(
|
623
|
+
PARITY_SHARE_NAMESPACE(),
|
624
|
+
PARITY_SHARE_NAMESPACE(),
|
625
|
+
0x055a3ea75c438d752aeabbba94ed8fac93e0b32321256a65fde176dba14f5186
|
626
|
+
);
|
627
|
+
sideNodes[1] = NamespaceNode(
|
628
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000010),
|
629
|
+
Namespace(0x00, 0x00000000000000000000000000000000000000000000000000000040),
|
630
|
+
0xa8dcd9f365fb64aa6d72b5027fe74db0fc7d009c2d75c7b9b9656927281cb35e
|
631
|
+
);
|
632
|
+
NamespaceNode memory node = NamespaceNode(
|
633
|
+
PARITY_SHARE_NAMESPACE(),
|
634
|
+
PARITY_SHARE_NAMESPACE(),
|
635
|
+
0x1b79ffd74644e8c287fe5f1dd70bc8ea02738697cebf2810ffb2dc5157485c40
|
636
|
+
);
|
637
|
+
|
638
|
+
uint256 key = 6;
|
639
|
+
uint256 numLeaves = 8;
|
640
|
+
NamespaceMerkleProof memory proof = NamespaceMerkleProof(sideNodes, key, numLeaves);
|
641
|
+
bool isValid = NamespaceMerkleTree.verifyInner(root, proof, node, 2);
|
642
|
+
assertTrue(isValid);
|
643
|
+
}
|
644
|
+
}
|