@proto-kit/common 0.1.1-develop.211 → 0.1.1-develop.2137

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.
Files changed (258) hide show
  1. package/dist/cache/CacheManifest.d.ts +11 -0
  2. package/dist/cache/CacheManifest.d.ts.map +1 -0
  3. package/dist/cache/CacheManifest.js +56 -0
  4. package/dist/cache/CacheManifest.js.map +1 -0
  5. package/dist/cache/ProxyCache.d.ts +13 -0
  6. package/dist/cache/ProxyCache.d.ts.map +1 -0
  7. package/dist/cache/ProxyCache.js +24 -0
  8. package/dist/cache/ProxyCache.js.map +1 -0
  9. package/dist/cache/RemoteCache.d.ts +8 -0
  10. package/dist/cache/RemoteCache.d.ts.map +1 -0
  11. package/dist/cache/RemoteCache.js +2 -0
  12. package/dist/cache/RemoteCache.js.map +1 -0
  13. package/dist/cache/RemoteCacheCompiler.d.ts +16 -0
  14. package/dist/cache/RemoteCacheCompiler.d.ts.map +1 -0
  15. package/dist/cache/RemoteCacheCompiler.js +104 -0
  16. package/dist/cache/RemoteCacheCompiler.js.map +1 -0
  17. package/dist/compiling/AtomicCompileHelper.d.ts +15 -0
  18. package/dist/compiling/AtomicCompileHelper.d.ts.map +1 -0
  19. package/dist/compiling/AtomicCompileHelper.js +61 -0
  20. package/dist/compiling/AtomicCompileHelper.js.map +1 -0
  21. package/dist/compiling/CompilableModule.d.ts +6 -0
  22. package/dist/compiling/CompilableModule.d.ts.map +1 -0
  23. package/dist/compiling/CompilableModule.js +2 -0
  24. package/dist/compiling/CompilableModule.js.map +1 -0
  25. package/dist/compiling/CompileRegistry.d.ts +25 -0
  26. package/dist/compiling/CompileRegistry.d.ts.map +1 -0
  27. package/dist/compiling/CompileRegistry.js +62 -0
  28. package/dist/compiling/CompileRegistry.js.map +1 -0
  29. package/dist/compiling/services/ChildVerificationKeyService.d.ts +10 -0
  30. package/dist/compiling/services/ChildVerificationKeyService.d.ts.map +1 -0
  31. package/dist/compiling/services/ChildVerificationKeyService.js +27 -0
  32. package/dist/compiling/services/ChildVerificationKeyService.js.map +1 -0
  33. package/dist/config/ChildContainerCreatable.d.ts +5 -0
  34. package/dist/config/ChildContainerCreatable.d.ts.map +1 -0
  35. package/dist/config/ChildContainerCreatable.js +2 -0
  36. package/dist/config/ChildContainerCreatable.js.map +1 -0
  37. package/dist/config/ChildContainerProvider.d.ts +5 -0
  38. package/dist/config/ChildContainerProvider.d.ts.map +1 -0
  39. package/dist/config/ChildContainerProvider.js +2 -0
  40. package/dist/config/ChildContainerProvider.js.map +1 -0
  41. package/dist/config/ConfigurableModule.d.ts +6 -2
  42. package/dist/config/ConfigurableModule.d.ts.map +1 -1
  43. package/dist/config/ConfigurableModule.js +5 -0
  44. package/dist/config/ConfigurableModule.js.map +1 -0
  45. package/dist/config/ModuleContainer.d.ts +70 -23
  46. package/dist/config/ModuleContainer.d.ts.map +1 -1
  47. package/dist/config/ModuleContainer.js +164 -31
  48. package/dist/config/ModuleContainer.js.map +1 -0
  49. package/dist/config/Startable.d.ts +4 -0
  50. package/dist/config/Startable.d.ts.map +1 -0
  51. package/dist/config/Startable.js +2 -0
  52. package/dist/config/Startable.js.map +1 -0
  53. package/dist/config/injectAlias.d.ts +18 -0
  54. package/dist/config/injectAlias.d.ts.map +1 -0
  55. package/dist/config/injectAlias.js +47 -0
  56. package/dist/config/injectAlias.js.map +1 -0
  57. package/dist/dependencyFactory/DependencyFactory.d.ts +14 -9
  58. package/dist/dependencyFactory/DependencyFactory.d.ts.map +1 -1
  59. package/dist/dependencyFactory/DependencyFactory.js +2 -96
  60. package/dist/dependencyFactory/DependencyFactory.js.map +1 -0
  61. package/dist/dependencyFactory/injectOptional.d.ts +16 -0
  62. package/dist/dependencyFactory/injectOptional.d.ts.map +1 -0
  63. package/dist/dependencyFactory/injectOptional.js +40 -0
  64. package/dist/dependencyFactory/injectOptional.js.map +1 -0
  65. package/dist/dummyVerificationKey.d.ts +3 -0
  66. package/dist/dummyVerificationKey.d.ts.map +1 -0
  67. package/dist/dummyVerificationKey.js +8 -0
  68. package/dist/dummyVerificationKey.js.map +1 -0
  69. package/dist/events/EventEmitter.d.ts +19 -0
  70. package/dist/events/EventEmitter.d.ts.map +1 -0
  71. package/dist/events/EventEmitter.js +35 -0
  72. package/dist/events/EventEmitter.js.map +1 -0
  73. package/dist/events/EventEmitterProxy.d.ts +18 -0
  74. package/dist/events/EventEmitterProxy.d.ts.map +1 -0
  75. package/dist/events/EventEmitterProxy.js +35 -0
  76. package/dist/events/EventEmitterProxy.js.map +1 -0
  77. package/dist/events/EventEmittingComponent.d.ts +9 -0
  78. package/dist/events/EventEmittingComponent.d.ts.map +1 -0
  79. package/dist/events/EventEmittingComponent.js +2 -0
  80. package/dist/events/EventEmittingComponent.js.map +1 -0
  81. package/dist/events/ReplayingSingleUseEventEmitter.d.ts +17 -0
  82. package/dist/events/ReplayingSingleUseEventEmitter.d.ts.map +1 -0
  83. package/dist/events/ReplayingSingleUseEventEmitter.js +34 -0
  84. package/dist/events/ReplayingSingleUseEventEmitter.js.map +1 -0
  85. package/dist/index.d.ts +27 -1
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +28 -2
  88. package/dist/index.js.map +1 -0
  89. package/dist/log.d.ts +37 -0
  90. package/dist/log.d.ts.map +1 -0
  91. package/dist/log.js +117 -0
  92. package/dist/log.js.map +1 -0
  93. package/dist/trees/InMemoryLinkedLeafStore.d.ts +21 -0
  94. package/dist/trees/InMemoryLinkedLeafStore.d.ts.map +1 -0
  95. package/dist/trees/InMemoryLinkedLeafStore.js +26 -0
  96. package/dist/trees/InMemoryLinkedLeafStore.js.map +1 -0
  97. package/dist/trees/InMemoryLinkedMerkleLeafStore.d.ts +7 -0
  98. package/dist/trees/InMemoryLinkedMerkleLeafStore.d.ts.map +1 -0
  99. package/dist/trees/InMemoryLinkedMerkleLeafStore.js +6 -0
  100. package/dist/trees/InMemoryLinkedMerkleLeafStore.js.map +1 -0
  101. package/dist/trees/InMemoryMerkleTreeStorage.d.ts +11 -0
  102. package/dist/trees/InMemoryMerkleTreeStorage.d.ts.map +1 -0
  103. package/dist/trees/InMemoryMerkleTreeStorage.js +13 -0
  104. package/dist/trees/InMemoryMerkleTreeStorage.js.map +1 -0
  105. package/dist/trees/LinkedMerkleTree.d.ts +345 -0
  106. package/dist/trees/LinkedMerkleTree.d.ts.map +1 -0
  107. package/dist/trees/LinkedMerkleTree.js +337 -0
  108. package/dist/trees/LinkedMerkleTree.js.map +1 -0
  109. package/dist/trees/LinkedMerkleTreeStore.d.ts +24 -0
  110. package/dist/trees/LinkedMerkleTreeStore.d.ts.map +1 -0
  111. package/dist/trees/LinkedMerkleTreeStore.js +2 -0
  112. package/dist/trees/LinkedMerkleTreeStore.js.map +1 -0
  113. package/dist/trees/MerkleTreeStore.d.ts +5 -0
  114. package/dist/trees/MerkleTreeStore.d.ts.map +1 -0
  115. package/dist/trees/MerkleTreeStore.js +2 -0
  116. package/dist/trees/MerkleTreeStore.js.map +1 -0
  117. package/dist/trees/MockAsyncMerkleStore.d.ts +9 -0
  118. package/dist/trees/MockAsyncMerkleStore.d.ts.map +1 -0
  119. package/dist/trees/MockAsyncMerkleStore.js +20 -0
  120. package/dist/trees/MockAsyncMerkleStore.js.map +1 -0
  121. package/dist/trees/RollupMerkleTree.d.ts +147 -0
  122. package/dist/trees/RollupMerkleTree.d.ts.map +1 -0
  123. package/dist/trees/RollupMerkleTree.js +218 -0
  124. package/dist/trees/RollupMerkleTree.js.map +1 -0
  125. package/dist/trees/VirtualMerkleTreeStore.d.ts +13 -0
  126. package/dist/trees/VirtualMerkleTreeStore.d.ts.map +1 -0
  127. package/dist/trees/VirtualMerkleTreeStore.js +18 -0
  128. package/dist/trees/VirtualMerkleTreeStore.js.map +1 -0
  129. package/dist/trees/lmt/AbstractLinkedMerkleTree.d.ts +288 -0
  130. package/dist/trees/lmt/AbstractLinkedMerkleTree.d.ts.map +1 -0
  131. package/dist/trees/lmt/AbstractLinkedMerkleTree.js +22 -0
  132. package/dist/trees/lmt/AbstractLinkedMerkleTree.js.map +1 -0
  133. package/dist/trees/lmt/InMemoryLinkedLeafStore.d.ts +21 -0
  134. package/dist/trees/lmt/InMemoryLinkedLeafStore.d.ts.map +1 -0
  135. package/dist/trees/lmt/InMemoryLinkedLeafStore.js +26 -0
  136. package/dist/trees/lmt/InMemoryLinkedLeafStore.js.map +1 -0
  137. package/dist/trees/lmt/InMemoryLinkedMerkleLeafStore.d.ts +7 -0
  138. package/dist/trees/lmt/InMemoryLinkedMerkleLeafStore.d.ts.map +1 -0
  139. package/dist/trees/lmt/InMemoryLinkedMerkleLeafStore.js +6 -0
  140. package/dist/trees/lmt/InMemoryLinkedMerkleLeafStore.js.map +1 -0
  141. package/dist/trees/lmt/LinkedLeafStore.d.ts +16 -0
  142. package/dist/trees/lmt/LinkedLeafStore.d.ts.map +1 -0
  143. package/dist/trees/lmt/LinkedLeafStore.js +2 -0
  144. package/dist/trees/lmt/LinkedLeafStore.js.map +1 -0
  145. package/dist/trees/lmt/LinkedLinkedStore.d.ts +16 -0
  146. package/dist/trees/lmt/LinkedLinkedStore.d.ts.map +1 -0
  147. package/dist/trees/lmt/LinkedLinkedStore.js +2 -0
  148. package/dist/trees/lmt/LinkedLinkedStore.js.map +1 -0
  149. package/dist/trees/lmt/LinkedMerkleTree.d.ts +11 -0
  150. package/dist/trees/lmt/LinkedMerkleTree.d.ts.map +1 -0
  151. package/dist/trees/lmt/LinkedMerkleTree.js +241 -0
  152. package/dist/trees/lmt/LinkedMerkleTree.js.map +1 -0
  153. package/dist/trees/lmt/LinkedMerkleTreeCircuitOps.d.ts +113 -0
  154. package/dist/trees/lmt/LinkedMerkleTreeCircuitOps.d.ts.map +1 -0
  155. package/dist/trees/lmt/LinkedMerkleTreeCircuitOps.js +113 -0
  156. package/dist/trees/lmt/LinkedMerkleTreeCircuitOps.js.map +1 -0
  157. package/dist/trees/lmt/LinkedMerkleTreeDatabase.d.ts +7 -0
  158. package/dist/trees/lmt/LinkedMerkleTreeDatabase.d.ts.map +1 -0
  159. package/dist/trees/lmt/LinkedMerkleTreeDatabase.js +2 -0
  160. package/dist/trees/lmt/LinkedMerkleTreeDatabase.js.map +1 -0
  161. package/dist/trees/lmt/LinkedMerkleTreeStore.d.ts +16 -0
  162. package/dist/trees/lmt/LinkedMerkleTreeStore.d.ts.map +1 -0
  163. package/dist/trees/lmt/LinkedMerkleTreeStore.js +2 -0
  164. package/dist/trees/lmt/LinkedMerkleTreeStore.js.map +1 -0
  165. package/dist/trees/lmt/LinkedMerkleTreeTypes.d.ts +74 -0
  166. package/dist/trees/lmt/LinkedMerkleTreeTypes.d.ts.map +1 -0
  167. package/dist/trees/lmt/LinkedMerkleTreeTypes.js +50 -0
  168. package/dist/trees/lmt/LinkedMerkleTreeTypes.js.map +1 -0
  169. package/dist/trees/sparse/InMemoryMerkleTreeStorage.d.ts +11 -0
  170. package/dist/trees/sparse/InMemoryMerkleTreeStorage.d.ts.map +1 -0
  171. package/dist/trees/sparse/InMemoryMerkleTreeStorage.js +13 -0
  172. package/dist/trees/sparse/InMemoryMerkleTreeStorage.js.map +1 -0
  173. package/dist/trees/sparse/MerkleTreeStore.d.ts +5 -0
  174. package/dist/trees/sparse/MerkleTreeStore.d.ts.map +1 -0
  175. package/dist/trees/sparse/MerkleTreeStore.js +2 -0
  176. package/dist/trees/sparse/MerkleTreeStore.js.map +1 -0
  177. package/dist/trees/sparse/MockAsyncMerkleStore.d.ts +9 -0
  178. package/dist/trees/sparse/MockAsyncMerkleStore.d.ts.map +1 -0
  179. package/dist/trees/sparse/MockAsyncMerkleStore.js +20 -0
  180. package/dist/trees/sparse/MockAsyncMerkleStore.js.map +1 -0
  181. package/dist/trees/sparse/RollupMerkleTree.d.ts +158 -0
  182. package/dist/trees/sparse/RollupMerkleTree.d.ts.map +1 -0
  183. package/dist/trees/sparse/RollupMerkleTree.js +330 -0
  184. package/dist/trees/sparse/RollupMerkleTree.js.map +1 -0
  185. package/dist/types.d.ts +62 -0
  186. package/dist/types.d.ts.map +1 -1
  187. package/dist/types.js +14 -1
  188. package/dist/types.js.map +1 -0
  189. package/dist/union/union.d.ts +177 -0
  190. package/dist/union/union.d.ts.map +1 -0
  191. package/dist/union/union.js +35 -0
  192. package/dist/union/union.js.map +1 -0
  193. package/dist/utils.d.ts +57 -2
  194. package/dist/utils.d.ts.map +1 -1
  195. package/dist/utils.js +153 -4
  196. package/dist/utils.js.map +1 -0
  197. package/dist/zkProgrammable/ProvableMethodExecutionContext.d.ts +4 -3
  198. package/dist/zkProgrammable/ProvableMethodExecutionContext.d.ts.map +1 -1
  199. package/dist/zkProgrammable/ProvableMethodExecutionContext.js +2 -3
  200. package/dist/zkProgrammable/ProvableMethodExecutionContext.js.map +1 -0
  201. package/dist/zkProgrammable/ZkProgrammable.d.ts +32 -11
  202. package/dist/zkProgrammable/ZkProgrammable.d.ts.map +1 -1
  203. package/dist/zkProgrammable/ZkProgrammable.js +36 -17
  204. package/dist/zkProgrammable/ZkProgrammable.js.map +1 -0
  205. package/dist/zkProgrammable/provableMethod.d.ts +7 -4
  206. package/dist/zkProgrammable/provableMethod.d.ts.map +1 -1
  207. package/dist/zkProgrammable/provableMethod.js +30 -14
  208. package/dist/zkProgrammable/provableMethod.js.map +1 -0
  209. package/jest.config.cjs +12 -1
  210. package/package.json +9 -7
  211. package/src/cache/CacheManifest.ts +57 -0
  212. package/src/cache/ProxyCache.ts +30 -0
  213. package/src/cache/RemoteCache.ts +9 -0
  214. package/src/cache/RemoteCacheCompiler.ts +131 -0
  215. package/src/compiling/AtomicCompileHelper.ts +71 -0
  216. package/src/compiling/CompilableModule.ts +6 -0
  217. package/src/compiling/CompileRegistry.ts +64 -0
  218. package/src/compiling/services/ChildVerificationKeyService.ts +26 -0
  219. package/src/config/ChildContainerCreatable.ts +5 -0
  220. package/src/config/ChildContainerProvider.ts +5 -0
  221. package/src/config/ConfigurableModule.ts +15 -2
  222. package/src/config/ModuleContainer.ts +286 -58
  223. package/src/config/Startable.ts +3 -0
  224. package/src/config/injectAlias.ts +70 -0
  225. package/src/dependencyFactory/DependencyFactory.ts +34 -109
  226. package/src/dummyVerificationKey.ts +10 -0
  227. package/src/events/EventEmitter.ts +61 -0
  228. package/src/events/EventEmitterProxy.ts +81 -0
  229. package/src/events/EventEmittingComponent.ts +11 -0
  230. package/src/events/ReplayingSingleUseEventEmitter.ts +42 -0
  231. package/src/index.ts +27 -2
  232. package/src/log.ts +145 -0
  233. package/src/trees/lmt/AbstractLinkedMerkleTree.ts +102 -0
  234. package/src/trees/lmt/InMemoryLinkedLeafStore.ts +42 -0
  235. package/src/trees/lmt/LinkedLeafStore.ts +13 -0
  236. package/src/trees/lmt/LinkedMerkleTree.ts +335 -0
  237. package/src/trees/lmt/LinkedMerkleTreeCircuitOps.ts +188 -0
  238. package/src/trees/lmt/LinkedMerkleTreeTypes.ts +53 -0
  239. package/src/trees/sparse/InMemoryMerkleTreeStorage.ts +17 -0
  240. package/src/trees/sparse/MerkleTreeStore.ts +5 -0
  241. package/src/trees/sparse/MockAsyncMerkleStore.ts +30 -0
  242. package/src/trees/sparse/RollupMerkleTree.ts +512 -0
  243. package/src/types.ts +53 -2
  244. package/src/utils.ts +281 -5
  245. package/src/zkProgrammable/ProvableMethodExecutionContext.ts +6 -6
  246. package/src/zkProgrammable/ZkProgrammable.ts +90 -35
  247. package/src/zkProgrammable/provableMethod.ts +50 -23
  248. package/test/config/ContainerEvents.test.ts +65 -0
  249. package/test/config/ModuleContainer.test.ts +146 -15
  250. package/test/config/injectAlias.test.ts +28 -0
  251. package/test/trees/LinkedMerkleTree.test.ts +124 -0
  252. package/test/trees/LinkedMerkleTreeCircuitOps.test.ts +147 -0
  253. package/test/trees/MerkleTree.test.ts +251 -0
  254. package/test/tsconfig.json +5 -2
  255. package/test/zkProgrammable/ZkProgrammable.test.ts +145 -119
  256. package/tsconfig.json +1 -1
  257. package/LICENSE.md +0 -201
  258. package/tsconfig.test.json +0 -9
@@ -0,0 +1,337 @@
1
+ // eslint-disable-next-line max-classes-per-file
2
+ import { Bool, Field, Poseidon, Provable, Struct } from "o1js";
3
+ import { range } from "../utils";
4
+ import { createMerkleTree, maybeSwap, } from "./RollupMerkleTree";
5
+ import { InMemoryLinkedMerkleLeafStore } from "./InMemoryLinkedMerkleLeafStore";
6
+ const RollupMerkleTreeWitness = createMerkleTree(40).WITNESS;
7
+ export class LinkedLeafStruct extends Struct({
8
+ value: Field,
9
+ path: Field,
10
+ nextPath: Field,
11
+ }) {
12
+ hash() {
13
+ return Poseidon.hash(LinkedLeafStruct.toFields(this));
14
+ }
15
+ }
16
+ // We use the RollupMerkleTreeWitness here, although we will actually implement
17
+ // the RollupMerkleTreeWitnessV2 defined below when instantiating the class.
18
+ export class LinkedLeafAndMerkleWitness extends Struct({
19
+ leaf: LinkedLeafStruct,
20
+ merkleWitness: RollupMerkleTreeWitness,
21
+ }) {
22
+ }
23
+ class LinkedStructTemplate extends Struct({
24
+ leafPrevious: LinkedLeafAndMerkleWitness,
25
+ leafCurrent: LinkedLeafAndMerkleWitness,
26
+ }) {
27
+ }
28
+ export function createLinkedMerkleTree(height) {
29
+ var _a;
30
+ class LinkedMerkleWitness extends LinkedStructTemplate {
31
+ }
32
+ /**
33
+ * The {@link RollupMerkleWitness} class defines a circuit-compatible base class
34
+ * for [Merkle Witness'](https://computersciencewiki.org/index.php/Merkle_proof).
35
+ */
36
+ // We define the RollupMerkleWitness again here as we want it to have the same height
37
+ // as the tree. If we re-used the Witness from the RollupMerkleTree.ts we wouldn't have
38
+ // control, whilst having the overhead of creating the RollupTree, since the witness is
39
+ // defined from the tree (for the height reason already described).
40
+ class RollupMerkleWitnessV2 extends Struct({
41
+ path: Provable.Array(Field, height - 1),
42
+ isLeft: Provable.Array(Bool, height - 1),
43
+ }) {
44
+ height() {
45
+ return RollupMerkleWitnessV2.height;
46
+ }
47
+ /**
48
+ * Calculates a root depending on the leaf value.
49
+ * @param leaf Value of the leaf node that belongs to this Witness.
50
+ * @returns The calculated root.
51
+ */
52
+ calculateRoot(leaf) {
53
+ let hash = leaf;
54
+ const n = this.height();
55
+ for (let index = 1; index < n; ++index) {
56
+ const isLeft = this.isLeft[index - 1];
57
+ const [left, right] = maybeSwap(isLeft, hash, this.path[index - 1]);
58
+ hash = Poseidon.hash([left, right]);
59
+ }
60
+ return hash;
61
+ }
62
+ /**
63
+ * Calculates the index of the leaf node that belongs to this Witness.
64
+ * @returns Index of the leaf.
65
+ */
66
+ calculateIndex() {
67
+ let powerOfTwo = Field(1);
68
+ let index = Field(0);
69
+ const n = this.height();
70
+ for (let i = 1; i < n; ++i) {
71
+ index = Provable.if(this.isLeft[i - 1], index, index.add(powerOfTwo));
72
+ powerOfTwo = powerOfTwo.mul(2);
73
+ }
74
+ return index;
75
+ }
76
+ checkMembership(root, key, value) {
77
+ const calculatedRoot = this.calculateRoot(value);
78
+ const calculatedKey = this.calculateIndex();
79
+ // We don't have to range-check the key, because if it would be greater
80
+ // than leafCount, it would not match the computedKey
81
+ key.assertEquals(calculatedKey, "Keys of MerkleWitness does not match");
82
+ return root.equals(calculatedRoot);
83
+ }
84
+ checkMembershipSimple(root, value) {
85
+ const calculatedRoot = this.calculateRoot(value);
86
+ return root.equals(calculatedRoot);
87
+ }
88
+ checkMembershipGetRoots(root, key, value) {
89
+ const calculatedRoot = this.calculateRoot(value);
90
+ const calculatedKey = this.calculateIndex();
91
+ key.assertEquals(calculatedKey, "Keys of MerkleWitness does not match");
92
+ return [root.equals(calculatedRoot), root, calculatedRoot];
93
+ }
94
+ toShortenedEntries() {
95
+ return range(0, 5)
96
+ .concat(range(this.height() - 4, this.height()))
97
+ .map((index) => [
98
+ this.path[index].toString(),
99
+ this.isLeft[index].toString(),
100
+ ].toString());
101
+ }
102
+ static dummy() {
103
+ return new RollupMerkleWitnessV2({
104
+ isLeft: Array(this.height - 1).fill(Bool(false)),
105
+ path: Array(this.height - 1).fill(Field(0)),
106
+ });
107
+ }
108
+ }
109
+ RollupMerkleWitnessV2.height = height;
110
+ return _a = class AbstractLinkedRollupMerkleTree {
111
+ constructor(store) {
112
+ this.store = store;
113
+ this.zeroes = [0n];
114
+ for (let index = 1; index < AbstractLinkedRollupMerkleTree.HEIGHT; index += 1) {
115
+ const previousLevel = Field(this.zeroes[index - 1]);
116
+ this.zeroes.push(Poseidon.hash([previousLevel, previousLevel]).toBigInt());
117
+ }
118
+ // We only do the leaf initialisation when the store
119
+ // has no values. Otherwise, we leave the store
120
+ // as is to not overwrite any data.
121
+ if (this.store.getMaximumIndex() === undefined) {
122
+ this.setLeafInitialisation();
123
+ }
124
+ }
125
+ getNode(level, index) {
126
+ const node = this.store.getNode(index, level);
127
+ return Field(node ?? this.zeroes[level]);
128
+ }
129
+ /**
130
+ * Returns leaf which lives at a given path.
131
+ * Errors if the path is not defined.
132
+ * @param path path of the node.
133
+ * @returns The data of the node.
134
+ */
135
+ getLeaf(path) {
136
+ const storedLeaf = this.store.getLeaf(path);
137
+ if (storedLeaf === undefined) {
138
+ return undefined;
139
+ }
140
+ return new LinkedLeafStruct({
141
+ value: Field(storedLeaf.leaf.value),
142
+ path: Field(storedLeaf.leaf.path),
143
+ nextPath: Field(storedLeaf.leaf.nextPath),
144
+ });
145
+ }
146
+ /**
147
+ * Returns the root of the [Merkle Tree](https://en.wikipedia.org/wiki/Merkle_tree).
148
+ * @returns The root of the Merkle Tree.
149
+ */
150
+ getRoot() {
151
+ return this.getNode(AbstractLinkedRollupMerkleTree.HEIGHT - 1, 0n).toConstant();
152
+ }
153
+ setNode(level, index, value) {
154
+ this.store.setNode(index, level, value.toBigInt());
155
+ }
156
+ /**
157
+ * Sets the value of a leaf node at a given index to a given value
158
+ * and carry the change through to the tree.
159
+ * @param index Position of the leaf node.
160
+ * @param leaf New value.
161
+ */
162
+ setMerkleLeaf(index, leaf) {
163
+ this.setNode(0, index, leaf.hash());
164
+ let tempIndex = index;
165
+ for (let level = 1; level < AbstractLinkedRollupMerkleTree.HEIGHT; level += 1) {
166
+ tempIndex /= 2n;
167
+ const leftPrev = this.getNode(level - 1, tempIndex * 2n);
168
+ const rightPrev = this.getNode(level - 1, tempIndex * 2n + 1n);
169
+ this.setNode(level, tempIndex, Poseidon.hash([leftPrev, rightPrev]));
170
+ }
171
+ }
172
+ /**
173
+ * Sets the value of a node at a given index to a given value.
174
+ * @param path Position of the leaf node.
175
+ * @param value New value.
176
+ */
177
+ setLeaf(path, value) {
178
+ if (value === undefined) {
179
+ return new LinkedMerkleWitness({
180
+ leafPrevious: this.dummy(),
181
+ leafCurrent: this.getWitness(path),
182
+ });
183
+ }
184
+ const storedLeaf = this.store.getLeaf(path);
185
+ const prevLeaf = this.store.getLeafLessOrEqual(path);
186
+ if (prevLeaf === undefined) {
187
+ throw Error("Prev leaf shouldn't be undefined");
188
+ }
189
+ let witnessPrevious;
190
+ let index;
191
+ if (storedLeaf === undefined) {
192
+ // The above means the path doesn't already exist, and we are inserting, not updating.
193
+ // This requires us to update the node with the previous path, as well.
194
+ const tempIndex = this.store.getMaximumIndex();
195
+ if (tempIndex === undefined) {
196
+ throw Error("Store Max Index not defined");
197
+ }
198
+ if (tempIndex + 1n >= 2 ** height) {
199
+ throw new Error("Index greater than maximum leaf number");
200
+ }
201
+ witnessPrevious = this.getWitness(prevLeaf.leaf.path);
202
+ const newPrevLeaf = {
203
+ value: prevLeaf.leaf.value,
204
+ path: prevLeaf.leaf.path,
205
+ nextPath: path,
206
+ };
207
+ this.store.setLeaf(prevLeaf.index, newPrevLeaf);
208
+ this.setMerkleLeaf(prevLeaf.index, new LinkedLeafStruct({
209
+ value: Field(newPrevLeaf.value),
210
+ path: Field(newPrevLeaf.path),
211
+ nextPath: Field(newPrevLeaf.nextPath),
212
+ }));
213
+ index = tempIndex + 1n;
214
+ }
215
+ else {
216
+ witnessPrevious = this.dummy();
217
+ index = storedLeaf.index;
218
+ }
219
+ const newLeaf = {
220
+ value: value,
221
+ path: path,
222
+ nextPath: prevLeaf.leaf.nextPath,
223
+ };
224
+ const witnessNext = this.getWitness(newLeaf.path);
225
+ this.store.setLeaf(index, newLeaf);
226
+ this.setMerkleLeaf(index, new LinkedLeafStruct({
227
+ value: Field(newLeaf.value),
228
+ path: Field(newLeaf.path),
229
+ nextPath: Field(newLeaf.nextPath),
230
+ }));
231
+ return new LinkedMerkleWitness({
232
+ leafPrevious: witnessPrevious,
233
+ leafCurrent: witnessNext,
234
+ });
235
+ }
236
+ /**
237
+ * Sets the value of a leaf node at initialisation,
238
+ * i.e. {vale: 0, path: 0, nextPath: Field.Max}
239
+ */
240
+ setLeafInitialisation() {
241
+ // This is the maximum value of the hash
242
+ const MAX_FIELD_VALUE = Field.ORDER - 1n;
243
+ this.store.setLeaf(0n, {
244
+ value: 0n,
245
+ path: 0n,
246
+ nextPath: MAX_FIELD_VALUE,
247
+ });
248
+ // We now set the leafs in the merkle tree to cascade the values up
249
+ // the tree.
250
+ this.setMerkleLeaf(0n, new LinkedLeafStruct({
251
+ value: Field(0n),
252
+ path: Field(0n),
253
+ nextPath: Field(MAX_FIELD_VALUE),
254
+ }));
255
+ }
256
+ /**
257
+ * Returns the witness (also known as
258
+ * [Merkle Proof or Merkle Witness](https://computersciencewiki.org/index.php/Merkle_proof))
259
+ * for the leaf at the given path, otherwise returns a witness for the first unused index.
260
+ * @param path of the leaf node.
261
+ * @returns The witness that belongs to the leaf.
262
+ */
263
+ getWitness(path) {
264
+ const storedLeaf = this.store.getLeaf(path);
265
+ let leaf;
266
+ let currentIndex;
267
+ if (storedLeaf === undefined) {
268
+ const storeIndex = this.store.getMaximumIndex();
269
+ if (storeIndex === undefined) {
270
+ throw new Error("Store Undefined");
271
+ }
272
+ currentIndex = storeIndex + 1n;
273
+ leaf = new LinkedLeafStruct({
274
+ value: Field(0),
275
+ path: Field(0),
276
+ nextPath: Field(0),
277
+ });
278
+ }
279
+ else {
280
+ leaf = new LinkedLeafStruct({
281
+ value: Field(storedLeaf.leaf.value),
282
+ path: Field(storedLeaf.leaf.path),
283
+ nextPath: Field(storedLeaf.leaf.nextPath),
284
+ });
285
+ currentIndex = storedLeaf.index;
286
+ }
287
+ const pathArray = [];
288
+ const isLefts = [];
289
+ for (let level = 0; level < AbstractLinkedRollupMerkleTree.HEIGHT - 1; level += 1) {
290
+ const isLeft = currentIndex % 2n === 0n;
291
+ const sibling = this.getNode(level, isLeft ? currentIndex + 1n : currentIndex - 1n);
292
+ isLefts.push(Bool(isLeft));
293
+ pathArray.push(sibling);
294
+ currentIndex /= 2n;
295
+ }
296
+ return new LinkedLeafAndMerkleWitness({
297
+ merkleWitness: new RollupMerkleWitnessV2({
298
+ path: pathArray,
299
+ isLeft: isLefts,
300
+ }),
301
+ leaf: leaf,
302
+ });
303
+ }
304
+ dummy() {
305
+ return new LinkedLeafAndMerkleWitness({
306
+ merkleWitness: new RollupMerkleTreeWitness({
307
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
308
+ path: Array(40).fill(Field(0)),
309
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
310
+ isLeft: Array(40).fill(new Bool(true)),
311
+ }),
312
+ leaf: new LinkedLeafStruct({
313
+ value: Field(0),
314
+ path: Field(0),
315
+ nextPath: Field(0),
316
+ }),
317
+ });
318
+ }
319
+ dummyWitness() {
320
+ return new LinkedMerkleWitness({
321
+ leafPrevious: this.dummy(),
322
+ leafCurrent: this.dummy(),
323
+ });
324
+ }
325
+ },
326
+ _a.HEIGHT = height,
327
+ _a.EMPTY_ROOT = new _a(new InMemoryLinkedMerkleLeafStore())
328
+ .getRoot()
329
+ .toBigInt(),
330
+ _a.WITNESS = LinkedMerkleWitness,
331
+ _a;
332
+ }
333
+ export class LinkedMerkleTree extends createLinkedMerkleTree(40) {
334
+ }
335
+ export class LinkedMerkleTreeWitness extends LinkedMerkleTree.WITNESS {
336
+ }
337
+ //# sourceMappingURL=LinkedMerkleTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkedMerkleTree.js","sourceRoot":"","sources":["../../src/trees/LinkedMerkleTree.ts"],"names":[],"mappings":"AAAA,gDAAgD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AC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAW;qBACjD,CAAC;oBACF,IAAI,EAAE,IAAI,gBAAgB,CAAC;wBACzB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;wBACf,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;wBACd,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;qBACnB,CAAC;iBACH,CAAC,CAAC;YACL,CAAC;YAEM,YAAY;gBACjB,OAAO,IAAI,mBAAmB,CAAC;oBAC7B,YAAY,EAAE,IAAI,CAAC,KAAK,EAAE;oBAC1B,WAAW,EAAE,IAAI,CAAC,KAAK,EAAE;iBAC1B,CAAC,CAAC;YACL,CAAC;SACF;QA7Qe,SAAM,GAAG,MAAO;QAEhB,aAAU,GAAG,IAAI,EAA8B,CAC3D,IAAI,6BAA6B,EAAE,CACpC;aACE,OAAO,EAAE;aACT,QAAQ,EAAG;QAEA,UAAO,GAAG,mBAAoB;WAqQ5C;AACJ,CAAC;AAED,MAAM,OAAO,gBAAiB,SAAQ,sBAAsB,CAAC,EAAE,CAAC;CAAG;AACnE,MAAM,OAAO,uBAAwB,SAAQ,gBAAgB,CAAC,OAAO;CAAG"}
@@ -0,0 +1,24 @@
1
+ import { MerkleTreeStore } from "./MerkleTreeStore";
2
+ export interface LinkedLeafStore {
3
+ setLeaf: (index: bigint, value: LinkedLeaf) => void;
4
+ getLeaf: (path: bigint) => {
5
+ leaf: LinkedLeaf;
6
+ index: bigint;
7
+ } | undefined;
8
+ getLeafLessOrEqual: (path: bigint) => {
9
+ leaf: LinkedLeaf;
10
+ index: bigint;
11
+ } | undefined;
12
+ getMaximumIndex: () => bigint | undefined;
13
+ }
14
+ export type LinkedLeaf = {
15
+ value: bigint;
16
+ path: bigint;
17
+ nextPath: bigint;
18
+ };
19
+ export interface LinkedMerkleTreeStore extends LinkedLeafStore, MerkleTreeStore {
20
+ }
21
+ export interface PreloadingLinkedMerkleTreeStore extends LinkedMerkleTreeStore {
22
+ preloadKeys(path: bigint[]): Promise<void>;
23
+ }
24
+ //# sourceMappingURL=LinkedMerkleTreeStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkedMerkleTreeStore.d.ts","sourceRoot":"","sources":["../../src/trees/LinkedMerkleTreeStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IAEpD,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAE3E,kBAAkB,EAAE,CAClB,IAAI,EAAE,MAAM,KACT;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAErD,eAAe,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CAC3C;AAED,MAAM,MAAM,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAC3E,MAAM,WAAW,qBACf,SAAQ,eAAe,EACrB,eAAe;CAAG;AAEtB,MAAM,WAAW,+BAAgC,SAAQ,qBAAqB;IAC5E,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=LinkedMerkleTreeStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkedMerkleTreeStore.js","sourceRoot":"","sources":["../../src/trees/LinkedMerkleTreeStore.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export interface MerkleTreeStore {
2
+ setNode: (key: bigint, level: number, value: bigint) => void;
3
+ getNode: (key: bigint, level: number) => bigint | undefined;
4
+ }
5
+ //# sourceMappingURL=MerkleTreeStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MerkleTreeStore.d.ts","sourceRoot":"","sources":["../../src/trees/MerkleTreeStore.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAE7D,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CAC7D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MerkleTreeStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MerkleTreeStore.js","sourceRoot":"","sources":["../../src/trees/MerkleTreeStore.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { InMemoryMerkleTreeStorage } from "./InMemoryMerkleTreeStorage";
2
+ export declare class MockAsyncMerkleTreeStore {
3
+ readonly store: InMemoryMerkleTreeStorage;
4
+ commit(): void;
5
+ openTransaction(): void;
6
+ getNodeAsync(key: bigint, level: number): Promise<bigint | undefined>;
7
+ setNodeAsync(key: bigint, level: number, value: bigint): Promise<void>;
8
+ }
9
+ //# sourceMappingURL=MockAsyncMerkleStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockAsyncMerkleStore.d.ts","sourceRoot":"","sources":["../../src/trees/MockAsyncMerkleStore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,qBAAa,wBAAwB;IACnC,SAAgB,KAAK,4BAAmC;IAEjD,MAAM,IAAI,IAAI;IAId,eAAe,IAAI,IAAI;IAIjB,YAAY,CACvB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIjB,YAAY,CACvB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;CAGjB"}
@@ -0,0 +1,20 @@
1
+ import { noop } from "../utils";
2
+ import { InMemoryMerkleTreeStorage } from "./InMemoryMerkleTreeStorage";
3
+ export class MockAsyncMerkleTreeStore {
4
+ constructor() {
5
+ this.store = new InMemoryMerkleTreeStorage();
6
+ }
7
+ commit() {
8
+ noop();
9
+ }
10
+ openTransaction() {
11
+ noop();
12
+ }
13
+ async getNodeAsync(key, level) {
14
+ return this.store.getNode(key, level);
15
+ }
16
+ async setNodeAsync(key, level, value) {
17
+ this.store.setNode(key, level, value);
18
+ }
19
+ }
20
+ //# sourceMappingURL=MockAsyncMerkleStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockAsyncMerkleStore.js","sourceRoot":"","sources":["../../src/trees/MockAsyncMerkleStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,MAAM,OAAO,wBAAwB;IAArC;QACkB,UAAK,GAAG,IAAI,yBAAyB,EAAE,CAAC;IAwB1D,CAAC;IAtBQ,MAAM;QACX,IAAI,EAAE,CAAC;IACT,CAAC;IAEM,eAAe;QACpB,IAAI,EAAE,CAAC;IACT,CAAC;IAEM,KAAK,CAAC,YAAY,CACvB,GAAW,EACX,KAAa;QAEb,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAEM,KAAK,CAAC,YAAY,CACvB,GAAW,EACX,KAAa,EACb,KAAa;QAEb,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;CACF"}
@@ -0,0 +1,147 @@
1
+ import { Bool, Field } from "o1js";
2
+ import { TypedClass } from "../types";
3
+ import { MerkleTreeStore } from "./MerkleTreeStore";
4
+ declare const StructTemplate_base: (new (value: {
5
+ path: import("o1js/dist/node/lib/provable/field").Field[];
6
+ isLeft: import("o1js/dist/node/lib/provable/bool").Bool[];
7
+ }) => {
8
+ path: import("o1js/dist/node/lib/provable/field").Field[];
9
+ isLeft: import("o1js/dist/node/lib/provable/bool").Bool[];
10
+ }) & {
11
+ _isStruct: true;
12
+ } & Omit<import("o1js/dist/node/lib/provable/types/provable-intf").Provable<{
13
+ path: import("o1js/dist/node/lib/provable/field").Field[];
14
+ isLeft: import("o1js/dist/node/lib/provable/bool").Bool[];
15
+ }, {
16
+ path: bigint[];
17
+ isLeft: boolean[];
18
+ }>, "fromFields"> & {
19
+ fromFields: (fields: import("o1js/dist/node/lib/provable/field").Field[]) => {
20
+ path: import("o1js/dist/node/lib/provable/field").Field[];
21
+ isLeft: import("o1js/dist/node/lib/provable/bool").Bool[];
22
+ };
23
+ } & {
24
+ fromValue: (value: {
25
+ path: import("o1js/dist/node/lib/provable/field").Field[] | bigint[];
26
+ isLeft: import("o1js/dist/node/lib/provable/bool").Bool[] | boolean[];
27
+ }) => {
28
+ path: import("o1js/dist/node/lib/provable/field").Field[];
29
+ isLeft: import("o1js/dist/node/lib/provable/bool").Bool[];
30
+ };
31
+ toInput: (x: {
32
+ path: import("o1js/dist/node/lib/provable/field").Field[];
33
+ isLeft: import("o1js/dist/node/lib/provable/bool").Bool[];
34
+ }) => {
35
+ fields?: import("o1js/dist/node/lib/provable/field").Field[] | undefined;
36
+ packed?: [import("o1js/dist/node/lib/provable/field").Field, number][] | undefined;
37
+ };
38
+ toJSON: (x: {
39
+ path: import("o1js/dist/node/lib/provable/field").Field[];
40
+ isLeft: import("o1js/dist/node/lib/provable/bool").Bool[];
41
+ }) => {
42
+ path: string[];
43
+ isLeft: boolean[];
44
+ };
45
+ fromJSON: (x: {
46
+ path: string[];
47
+ isLeft: boolean[];
48
+ }) => {
49
+ path: import("o1js/dist/node/lib/provable/field").Field[];
50
+ isLeft: import("o1js/dist/node/lib/provable/bool").Bool[];
51
+ };
52
+ empty: () => {
53
+ path: import("o1js/dist/node/lib/provable/field").Field[];
54
+ isLeft: import("o1js/dist/node/lib/provable/bool").Bool[];
55
+ };
56
+ };
57
+ declare class StructTemplate extends StructTemplate_base {
58
+ }
59
+ export interface AbstractMerkleWitness extends StructTemplate {
60
+ height(): number;
61
+ /**
62
+ * Calculates a root depending on the leaf value.
63
+ * @param leaf Value of the leaf node that belongs to this Witness.
64
+ * @returns The calculated root.
65
+ */
66
+ calculateRoot(hash: Field): Field;
67
+ /**
68
+ * Calculates the index of the leaf node that belongs to this Witness.
69
+ * @returns Index of the leaf.
70
+ */
71
+ calculateIndex(): Field;
72
+ checkMembership(root: Field, key: Field, value: Field): Bool;
73
+ checkMembershipGetRoots(root: Field, key: Field, value: Field): [Bool, Field, Field];
74
+ toShortenedEntries(): string[];
75
+ }
76
+ export interface AbstractMerkleTree {
77
+ store: MerkleTreeStore;
78
+ readonly leafCount: bigint;
79
+ assertIndexRange(index: bigint): void;
80
+ /**
81
+ * Returns a node which lives at a given index and level.
82
+ * @param level Level of the node.
83
+ * @param index Index of the node.
84
+ * @returns The data of the node.
85
+ */
86
+ getNode(level: number, index: bigint): Field;
87
+ /**
88
+ * Returns the root of the [Merkle Tree](https://en.wikipedia.org/wiki/Merkle_tree).
89
+ * @returns The root of the Merkle Tree.
90
+ */
91
+ getRoot(): Field;
92
+ /**
93
+ * Sets the value of a leaf node at a given index to a given value.
94
+ * @param index Position of the leaf node.
95
+ * @param leaf New value.
96
+ */
97
+ setLeaf(index: bigint, leaf: Field): void;
98
+ /**
99
+ * Returns the witness (also known as
100
+ * [Merkle Proof or Merkle Witness](https://computersciencewiki.org/index.php/Merkle_proof))
101
+ * for the leaf at the given index.
102
+ * @param index Position of the leaf node.
103
+ * @returns The witness that belongs to the leaf.
104
+ */
105
+ getWitness(index: bigint): AbstractMerkleWitness;
106
+ /**
107
+ * Fills all leaves of the tree.
108
+ * @param leaves Values to fill the leaves with.
109
+ */
110
+ fill(leaves: Field[]): void;
111
+ }
112
+ export interface AbstractMerkleTreeClass {
113
+ new (store: MerkleTreeStore): AbstractMerkleTree;
114
+ WITNESS: TypedClass<AbstractMerkleWitness> & typeof StructTemplate & {
115
+ dummy: () => AbstractMerkleWitness;
116
+ };
117
+ HEIGHT: number;
118
+ EMPTY_ROOT: bigint;
119
+ get leafCount(): bigint;
120
+ }
121
+ /**
122
+ * A [Merkle Tree](https://en.wikipedia.org/wiki/Merkle_tree) is a binary tree in
123
+ * which every leaf is the cryptography hash of a piece of data,
124
+ * and every node is the hash of the concatenation of its two child nodes.
125
+ *
126
+ * A Merkle Tree allows developers to easily and securely verify
127
+ * the integrity of large amounts of data.
128
+ *
129
+ * Take a look at our [documentation](https://docs.minaprotocol.com/en/zkapps)
130
+ * on how to use Merkle Trees in combination with zkApps and
131
+ * zero knowledge programming!
132
+ *
133
+ * Levels are indexed from leaves (level 0) to root (level N - 1).
134
+ *
135
+ * This function takes a height as argument and returns a class
136
+ * that implements a merkletree with that specified height.
137
+ *
138
+ * It also holds the Witness class under tree.WITNESS
139
+ */
140
+ export declare function createMerkleTree(height: number): AbstractMerkleTreeClass;
141
+ declare const RollupMerkleTree_base: AbstractMerkleTreeClass;
142
+ export declare class RollupMerkleTree extends RollupMerkleTree_base {
143
+ }
144
+ export declare class RollupMerkleTreeWitness extends RollupMerkleTree.WITNESS {
145
+ }
146
+ export {};
147
+ //# sourceMappingURL=RollupMerkleTree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RollupMerkleTree.d.ts","sourceRoot":"","sources":["../../src/trees/RollupMerkleTree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAA8B,MAAM,MAAM,CAAC;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU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