@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.
- package/dist/cache/CacheManifest.d.ts +11 -0
- package/dist/cache/CacheManifest.d.ts.map +1 -0
- package/dist/cache/CacheManifest.js +56 -0
- package/dist/cache/CacheManifest.js.map +1 -0
- package/dist/cache/ProxyCache.d.ts +13 -0
- package/dist/cache/ProxyCache.d.ts.map +1 -0
- package/dist/cache/ProxyCache.js +24 -0
- package/dist/cache/ProxyCache.js.map +1 -0
- package/dist/cache/RemoteCache.d.ts +8 -0
- package/dist/cache/RemoteCache.d.ts.map +1 -0
- package/dist/cache/RemoteCache.js +2 -0
- package/dist/cache/RemoteCache.js.map +1 -0
- package/dist/cache/RemoteCacheCompiler.d.ts +16 -0
- package/dist/cache/RemoteCacheCompiler.d.ts.map +1 -0
- package/dist/cache/RemoteCacheCompiler.js +104 -0
- package/dist/cache/RemoteCacheCompiler.js.map +1 -0
- package/dist/compiling/AtomicCompileHelper.d.ts +15 -0
- package/dist/compiling/AtomicCompileHelper.d.ts.map +1 -0
- package/dist/compiling/AtomicCompileHelper.js +61 -0
- package/dist/compiling/AtomicCompileHelper.js.map +1 -0
- package/dist/compiling/CompilableModule.d.ts +6 -0
- package/dist/compiling/CompilableModule.d.ts.map +1 -0
- package/dist/compiling/CompilableModule.js +2 -0
- package/dist/compiling/CompilableModule.js.map +1 -0
- package/dist/compiling/CompileRegistry.d.ts +25 -0
- package/dist/compiling/CompileRegistry.d.ts.map +1 -0
- package/dist/compiling/CompileRegistry.js +62 -0
- package/dist/compiling/CompileRegistry.js.map +1 -0
- package/dist/compiling/services/ChildVerificationKeyService.d.ts +10 -0
- package/dist/compiling/services/ChildVerificationKeyService.d.ts.map +1 -0
- package/dist/compiling/services/ChildVerificationKeyService.js +27 -0
- package/dist/compiling/services/ChildVerificationKeyService.js.map +1 -0
- package/dist/config/ChildContainerCreatable.d.ts +5 -0
- package/dist/config/ChildContainerCreatable.d.ts.map +1 -0
- package/dist/config/ChildContainerCreatable.js +2 -0
- package/dist/config/ChildContainerCreatable.js.map +1 -0
- package/dist/config/ChildContainerProvider.d.ts +5 -0
- package/dist/config/ChildContainerProvider.d.ts.map +1 -0
- package/dist/config/ChildContainerProvider.js +2 -0
- package/dist/config/ChildContainerProvider.js.map +1 -0
- package/dist/config/ConfigurableModule.d.ts +6 -2
- package/dist/config/ConfigurableModule.d.ts.map +1 -1
- package/dist/config/ConfigurableModule.js +5 -0
- package/dist/config/ConfigurableModule.js.map +1 -0
- package/dist/config/ModuleContainer.d.ts +70 -23
- package/dist/config/ModuleContainer.d.ts.map +1 -1
- package/dist/config/ModuleContainer.js +164 -31
- package/dist/config/ModuleContainer.js.map +1 -0
- package/dist/config/Startable.d.ts +4 -0
- package/dist/config/Startable.d.ts.map +1 -0
- package/dist/config/Startable.js +2 -0
- package/dist/config/Startable.js.map +1 -0
- package/dist/config/injectAlias.d.ts +18 -0
- package/dist/config/injectAlias.d.ts.map +1 -0
- package/dist/config/injectAlias.js +47 -0
- package/dist/config/injectAlias.js.map +1 -0
- package/dist/dependencyFactory/DependencyFactory.d.ts +14 -9
- package/dist/dependencyFactory/DependencyFactory.d.ts.map +1 -1
- package/dist/dependencyFactory/DependencyFactory.js +2 -96
- package/dist/dependencyFactory/DependencyFactory.js.map +1 -0
- package/dist/dependencyFactory/injectOptional.d.ts +16 -0
- package/dist/dependencyFactory/injectOptional.d.ts.map +1 -0
- package/dist/dependencyFactory/injectOptional.js +40 -0
- package/dist/dependencyFactory/injectOptional.js.map +1 -0
- package/dist/dummyVerificationKey.d.ts +3 -0
- package/dist/dummyVerificationKey.d.ts.map +1 -0
- package/dist/dummyVerificationKey.js +8 -0
- package/dist/dummyVerificationKey.js.map +1 -0
- package/dist/events/EventEmitter.d.ts +19 -0
- package/dist/events/EventEmitter.d.ts.map +1 -0
- package/dist/events/EventEmitter.js +35 -0
- package/dist/events/EventEmitter.js.map +1 -0
- package/dist/events/EventEmitterProxy.d.ts +18 -0
- package/dist/events/EventEmitterProxy.d.ts.map +1 -0
- package/dist/events/EventEmitterProxy.js +35 -0
- package/dist/events/EventEmitterProxy.js.map +1 -0
- package/dist/events/EventEmittingComponent.d.ts +9 -0
- package/dist/events/EventEmittingComponent.d.ts.map +1 -0
- package/dist/events/EventEmittingComponent.js +2 -0
- package/dist/events/EventEmittingComponent.js.map +1 -0
- package/dist/events/ReplayingSingleUseEventEmitter.d.ts +17 -0
- package/dist/events/ReplayingSingleUseEventEmitter.d.ts.map +1 -0
- package/dist/events/ReplayingSingleUseEventEmitter.js +34 -0
- package/dist/events/ReplayingSingleUseEventEmitter.js.map +1 -0
- package/dist/index.d.ts +27 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -2
- package/dist/index.js.map +1 -0
- package/dist/log.d.ts +37 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +117 -0
- package/dist/log.js.map +1 -0
- package/dist/trees/InMemoryLinkedLeafStore.d.ts +21 -0
- package/dist/trees/InMemoryLinkedLeafStore.d.ts.map +1 -0
- package/dist/trees/InMemoryLinkedLeafStore.js +26 -0
- package/dist/trees/InMemoryLinkedLeafStore.js.map +1 -0
- package/dist/trees/InMemoryLinkedMerkleLeafStore.d.ts +7 -0
- package/dist/trees/InMemoryLinkedMerkleLeafStore.d.ts.map +1 -0
- package/dist/trees/InMemoryLinkedMerkleLeafStore.js +6 -0
- package/dist/trees/InMemoryLinkedMerkleLeafStore.js.map +1 -0
- package/dist/trees/InMemoryMerkleTreeStorage.d.ts +11 -0
- package/dist/trees/InMemoryMerkleTreeStorage.d.ts.map +1 -0
- package/dist/trees/InMemoryMerkleTreeStorage.js +13 -0
- package/dist/trees/InMemoryMerkleTreeStorage.js.map +1 -0
- package/dist/trees/LinkedMerkleTree.d.ts +345 -0
- package/dist/trees/LinkedMerkleTree.d.ts.map +1 -0
- package/dist/trees/LinkedMerkleTree.js +337 -0
- package/dist/trees/LinkedMerkleTree.js.map +1 -0
- package/dist/trees/LinkedMerkleTreeStore.d.ts +24 -0
- package/dist/trees/LinkedMerkleTreeStore.d.ts.map +1 -0
- package/dist/trees/LinkedMerkleTreeStore.js +2 -0
- package/dist/trees/LinkedMerkleTreeStore.js.map +1 -0
- package/dist/trees/MerkleTreeStore.d.ts +5 -0
- package/dist/trees/MerkleTreeStore.d.ts.map +1 -0
- package/dist/trees/MerkleTreeStore.js +2 -0
- package/dist/trees/MerkleTreeStore.js.map +1 -0
- package/dist/trees/MockAsyncMerkleStore.d.ts +9 -0
- package/dist/trees/MockAsyncMerkleStore.d.ts.map +1 -0
- package/dist/trees/MockAsyncMerkleStore.js +20 -0
- package/dist/trees/MockAsyncMerkleStore.js.map +1 -0
- package/dist/trees/RollupMerkleTree.d.ts +147 -0
- package/dist/trees/RollupMerkleTree.d.ts.map +1 -0
- package/dist/trees/RollupMerkleTree.js +218 -0
- package/dist/trees/RollupMerkleTree.js.map +1 -0
- package/dist/trees/VirtualMerkleTreeStore.d.ts +13 -0
- package/dist/trees/VirtualMerkleTreeStore.d.ts.map +1 -0
- package/dist/trees/VirtualMerkleTreeStore.js +18 -0
- package/dist/trees/VirtualMerkleTreeStore.js.map +1 -0
- package/dist/trees/lmt/AbstractLinkedMerkleTree.d.ts +288 -0
- package/dist/trees/lmt/AbstractLinkedMerkleTree.d.ts.map +1 -0
- package/dist/trees/lmt/AbstractLinkedMerkleTree.js +22 -0
- package/dist/trees/lmt/AbstractLinkedMerkleTree.js.map +1 -0
- package/dist/trees/lmt/InMemoryLinkedLeafStore.d.ts +21 -0
- package/dist/trees/lmt/InMemoryLinkedLeafStore.d.ts.map +1 -0
- package/dist/trees/lmt/InMemoryLinkedLeafStore.js +26 -0
- package/dist/trees/lmt/InMemoryLinkedLeafStore.js.map +1 -0
- package/dist/trees/lmt/InMemoryLinkedMerkleLeafStore.d.ts +7 -0
- package/dist/trees/lmt/InMemoryLinkedMerkleLeafStore.d.ts.map +1 -0
- package/dist/trees/lmt/InMemoryLinkedMerkleLeafStore.js +6 -0
- package/dist/trees/lmt/InMemoryLinkedMerkleLeafStore.js.map +1 -0
- package/dist/trees/lmt/LinkedLeafStore.d.ts +16 -0
- package/dist/trees/lmt/LinkedLeafStore.d.ts.map +1 -0
- package/dist/trees/lmt/LinkedLeafStore.js +2 -0
- package/dist/trees/lmt/LinkedLeafStore.js.map +1 -0
- package/dist/trees/lmt/LinkedLinkedStore.d.ts +16 -0
- package/dist/trees/lmt/LinkedLinkedStore.d.ts.map +1 -0
- package/dist/trees/lmt/LinkedLinkedStore.js +2 -0
- package/dist/trees/lmt/LinkedLinkedStore.js.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTree.d.ts +11 -0
- package/dist/trees/lmt/LinkedMerkleTree.d.ts.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTree.js +241 -0
- package/dist/trees/lmt/LinkedMerkleTree.js.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeCircuitOps.d.ts +113 -0
- package/dist/trees/lmt/LinkedMerkleTreeCircuitOps.d.ts.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeCircuitOps.js +113 -0
- package/dist/trees/lmt/LinkedMerkleTreeCircuitOps.js.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeDatabase.d.ts +7 -0
- package/dist/trees/lmt/LinkedMerkleTreeDatabase.d.ts.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeDatabase.js +2 -0
- package/dist/trees/lmt/LinkedMerkleTreeDatabase.js.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeStore.d.ts +16 -0
- package/dist/trees/lmt/LinkedMerkleTreeStore.d.ts.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeStore.js +2 -0
- package/dist/trees/lmt/LinkedMerkleTreeStore.js.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeTypes.d.ts +74 -0
- package/dist/trees/lmt/LinkedMerkleTreeTypes.d.ts.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeTypes.js +50 -0
- package/dist/trees/lmt/LinkedMerkleTreeTypes.js.map +1 -0
- package/dist/trees/sparse/InMemoryMerkleTreeStorage.d.ts +11 -0
- package/dist/trees/sparse/InMemoryMerkleTreeStorage.d.ts.map +1 -0
- package/dist/trees/sparse/InMemoryMerkleTreeStorage.js +13 -0
- package/dist/trees/sparse/InMemoryMerkleTreeStorage.js.map +1 -0
- package/dist/trees/sparse/MerkleTreeStore.d.ts +5 -0
- package/dist/trees/sparse/MerkleTreeStore.d.ts.map +1 -0
- package/dist/trees/sparse/MerkleTreeStore.js +2 -0
- package/dist/trees/sparse/MerkleTreeStore.js.map +1 -0
- package/dist/trees/sparse/MockAsyncMerkleStore.d.ts +9 -0
- package/dist/trees/sparse/MockAsyncMerkleStore.d.ts.map +1 -0
- package/dist/trees/sparse/MockAsyncMerkleStore.js +20 -0
- package/dist/trees/sparse/MockAsyncMerkleStore.js.map +1 -0
- package/dist/trees/sparse/RollupMerkleTree.d.ts +158 -0
- package/dist/trees/sparse/RollupMerkleTree.d.ts.map +1 -0
- package/dist/trees/sparse/RollupMerkleTree.js +330 -0
- package/dist/trees/sparse/RollupMerkleTree.js.map +1 -0
- package/dist/types.d.ts +62 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +14 -1
- package/dist/types.js.map +1 -0
- package/dist/union/union.d.ts +177 -0
- package/dist/union/union.d.ts.map +1 -0
- package/dist/union/union.js +35 -0
- package/dist/union/union.js.map +1 -0
- package/dist/utils.d.ts +57 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +153 -4
- package/dist/utils.js.map +1 -0
- package/dist/zkProgrammable/ProvableMethodExecutionContext.d.ts +4 -3
- package/dist/zkProgrammable/ProvableMethodExecutionContext.d.ts.map +1 -1
- package/dist/zkProgrammable/ProvableMethodExecutionContext.js +2 -3
- package/dist/zkProgrammable/ProvableMethodExecutionContext.js.map +1 -0
- package/dist/zkProgrammable/ZkProgrammable.d.ts +32 -11
- package/dist/zkProgrammable/ZkProgrammable.d.ts.map +1 -1
- package/dist/zkProgrammable/ZkProgrammable.js +36 -17
- package/dist/zkProgrammable/ZkProgrammable.js.map +1 -0
- package/dist/zkProgrammable/provableMethod.d.ts +7 -4
- package/dist/zkProgrammable/provableMethod.d.ts.map +1 -1
- package/dist/zkProgrammable/provableMethod.js +30 -14
- package/dist/zkProgrammable/provableMethod.js.map +1 -0
- package/jest.config.cjs +12 -1
- package/package.json +9 -7
- package/src/cache/CacheManifest.ts +57 -0
- package/src/cache/ProxyCache.ts +30 -0
- package/src/cache/RemoteCache.ts +9 -0
- package/src/cache/RemoteCacheCompiler.ts +131 -0
- package/src/compiling/AtomicCompileHelper.ts +71 -0
- package/src/compiling/CompilableModule.ts +6 -0
- package/src/compiling/CompileRegistry.ts +64 -0
- package/src/compiling/services/ChildVerificationKeyService.ts +26 -0
- package/src/config/ChildContainerCreatable.ts +5 -0
- package/src/config/ChildContainerProvider.ts +5 -0
- package/src/config/ConfigurableModule.ts +15 -2
- package/src/config/ModuleContainer.ts +286 -58
- package/src/config/Startable.ts +3 -0
- package/src/config/injectAlias.ts +70 -0
- package/src/dependencyFactory/DependencyFactory.ts +34 -109
- package/src/dummyVerificationKey.ts +10 -0
- package/src/events/EventEmitter.ts +61 -0
- package/src/events/EventEmitterProxy.ts +81 -0
- package/src/events/EventEmittingComponent.ts +11 -0
- package/src/events/ReplayingSingleUseEventEmitter.ts +42 -0
- package/src/index.ts +27 -2
- package/src/log.ts +145 -0
- package/src/trees/lmt/AbstractLinkedMerkleTree.ts +102 -0
- package/src/trees/lmt/InMemoryLinkedLeafStore.ts +42 -0
- package/src/trees/lmt/LinkedLeafStore.ts +13 -0
- package/src/trees/lmt/LinkedMerkleTree.ts +335 -0
- package/src/trees/lmt/LinkedMerkleTreeCircuitOps.ts +188 -0
- package/src/trees/lmt/LinkedMerkleTreeTypes.ts +53 -0
- package/src/trees/sparse/InMemoryMerkleTreeStorage.ts +17 -0
- package/src/trees/sparse/MerkleTreeStore.ts +5 -0
- package/src/trees/sparse/MockAsyncMerkleStore.ts +30 -0
- package/src/trees/sparse/RollupMerkleTree.ts +512 -0
- package/src/types.ts +53 -2
- package/src/utils.ts +281 -5
- package/src/zkProgrammable/ProvableMethodExecutionContext.ts +6 -6
- package/src/zkProgrammable/ZkProgrammable.ts +90 -35
- package/src/zkProgrammable/provableMethod.ts +50 -23
- package/test/config/ContainerEvents.test.ts +65 -0
- package/test/config/ModuleContainer.test.ts +146 -15
- package/test/config/injectAlias.test.ts +28 -0
- package/test/trees/LinkedMerkleTree.test.ts +124 -0
- package/test/trees/LinkedMerkleTreeCircuitOps.test.ts +147 -0
- package/test/trees/MerkleTree.test.ts +251 -0
- package/test/tsconfig.json +5 -2
- package/test/zkProgrammable/ZkProgrammable.test.ts +145 -119
- package/tsconfig.json +1 -1
- package/LICENSE.md +0 -201
- package/tsconfig.test.json +0 -9
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Mixin } from "ts-mixer";
|
|
2
|
+
import { InMemoryLinkedLeafStore } from "./InMemoryLinkedLeafStore";
|
|
3
|
+
import { InMemoryMerkleTreeStorage } from "../sparse/InMemoryMerkleTreeStorage";
|
|
4
|
+
export class InMemoryLinkedMerkleLeafStore extends Mixin(InMemoryLinkedLeafStore, InMemoryMerkleTreeStorage) {
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=InMemoryLinkedMerkleLeafStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InMemoryLinkedMerkleLeafStore.js","sourceRoot":"","sources":["../../../src/trees/lmt/InMemoryLinkedMerkleLeafStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,MAAM,OAAO,6BAA8B,SAAQ,KAAK,CACtD,uBAAuB,EACvB,yBAAyB,CAC1B;CAAG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type LinkedLeaf = {
|
|
2
|
+
value: bigint;
|
|
3
|
+
path: bigint;
|
|
4
|
+
nextPath: bigint;
|
|
5
|
+
};
|
|
6
|
+
export type StoredLeaf = {
|
|
7
|
+
leaf: LinkedLeaf;
|
|
8
|
+
index: bigint;
|
|
9
|
+
};
|
|
10
|
+
export interface LinkedLeafStore {
|
|
11
|
+
setLeaf: (index: bigint, value: LinkedLeaf) => void;
|
|
12
|
+
getLeaf: (path: bigint) => StoredLeaf | undefined;
|
|
13
|
+
getPreviousLeaf: (path: bigint) => StoredLeaf | undefined;
|
|
14
|
+
getMaximumIndex: () => bigint | undefined;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=LinkedLeafStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkedLeafStore.d.ts","sourceRoot":"","sources":["../../../src/trees/lmt/LinkedLeafStore.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,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,UAAU,GAAG,SAAS,CAAC;IAElD,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,GAAG,SAAS,CAAC;IAE1D,eAAe,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkedLeafStore.js","sourceRoot":"","sources":["../../../src/trees/lmt/LinkedLeafStore.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type LinkedLeaf = {
|
|
2
|
+
value: bigint;
|
|
3
|
+
path: bigint;
|
|
4
|
+
nextPath: bigint;
|
|
5
|
+
};
|
|
6
|
+
export type StoredLeaf = {
|
|
7
|
+
leaf: LinkedLeaf;
|
|
8
|
+
index: bigint;
|
|
9
|
+
};
|
|
10
|
+
export interface LinkedLeafStore {
|
|
11
|
+
setLeaf: (index: bigint, value: LinkedLeaf) => void;
|
|
12
|
+
getLeaf: (path: bigint) => StoredLeaf | undefined;
|
|
13
|
+
getLeafLessOrEqual: (path: bigint) => StoredLeaf | undefined;
|
|
14
|
+
getMaximumIndex: () => bigint | undefined;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=LinkedLinkedStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkedLinkedStore.d.ts","sourceRoot":"","sources":["../../../src/trees/lmt/LinkedLinkedStore.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,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,UAAU,GAAG,SAAS,CAAC;IAElD,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,GAAG,SAAS,CAAC;IAE7D,eAAe,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkedLinkedStore.js","sourceRoot":"","sources":["../../../src/trees/lmt/LinkedLinkedStore.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AbstractLinkedMerkleTreeClass } from "./AbstractLinkedMerkleTree";
|
|
2
|
+
export declare function createLinkedMerkleTree(height: number): AbstractLinkedMerkleTreeClass;
|
|
3
|
+
declare const LinkedMerkleTree_base: AbstractLinkedMerkleTreeClass;
|
|
4
|
+
export declare class LinkedMerkleTree extends LinkedMerkleTree_base {
|
|
5
|
+
}
|
|
6
|
+
export declare class LinkedMerkleTreeWitness extends LinkedMerkleTree.WITNESS {
|
|
7
|
+
}
|
|
8
|
+
export declare class LinkedMerkleTreeReadWitness extends LinkedMerkleTree.READ_WITNESS {
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=LinkedMerkleTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkedMerkleTree.d.ts","sourceRoot":"","sources":["../../../src/trees/lmt/LinkedMerkleTree.ts"],"names":[],"mappings":"AASA,OAAO,EAEL,6BAA6B,EAC9B,MAAM,4BAA4B,CAAC;AAapC,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,GACb,6BAA6B,CA+S/B;;AAED,qBAAa,gBAAiB,SAAQ,qBAA0B;CAAG;AACnE,qBAAa,uBAAwB,SAAQ,gBAAgB,CAAC,OAAO;CAAG;AACxE,qBAAa,2BAA4B,SAAQ,gBAAgB,CAAC,YAAY;CAAG"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { Field, Struct } from "o1js";
|
|
2
|
+
import { createMerkleTree } from "../sparse/RollupMerkleTree";
|
|
3
|
+
import { InMemoryMerkleTreeStorage } from "../sparse/InMemoryMerkleTreeStorage";
|
|
4
|
+
import { InMemoryLinkedLeafStore } from "./InMemoryLinkedLeafStore";
|
|
5
|
+
import { LinkedLeafStruct } from "./LinkedMerkleTreeTypes";
|
|
6
|
+
export function createLinkedMerkleTree(height) {
|
|
7
|
+
var _a;
|
|
8
|
+
const SparseTreeClass = createMerkleTree(height);
|
|
9
|
+
class LinkedLeafAndMerkleWitness extends Struct({
|
|
10
|
+
leaf: LinkedLeafStruct,
|
|
11
|
+
merkleWitness: SparseTreeClass.WITNESS,
|
|
12
|
+
}) {
|
|
13
|
+
checkMembership(root, path, value) {
|
|
14
|
+
const pathEquals = path.equals(this.leaf.path);
|
|
15
|
+
return this.merkleWitness
|
|
16
|
+
.calculateRoot(new LinkedLeafStruct({
|
|
17
|
+
...this.leaf,
|
|
18
|
+
value,
|
|
19
|
+
}).hash())
|
|
20
|
+
.equals(root)
|
|
21
|
+
.and(pathEquals);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class LinkedOperationWitness extends Struct({
|
|
25
|
+
leafPrevious: LinkedLeafAndMerkleWitness,
|
|
26
|
+
leafCurrent: LinkedLeafAndMerkleWitness,
|
|
27
|
+
}) {
|
|
28
|
+
// implements LinkedStructTemplate
|
|
29
|
+
static fromReadWitness(readWitness) {
|
|
30
|
+
return new LinkedOperationWitness({
|
|
31
|
+
leafPrevious: new LinkedLeafAndMerkleWitness({
|
|
32
|
+
merkleWitness: SparseTreeClass.WITNESS.dummy(),
|
|
33
|
+
leaf: LinkedLeafStruct.dummy(),
|
|
34
|
+
}),
|
|
35
|
+
leafCurrent: readWitness,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return _a = class AbstractLinkedRollupMerkleTree {
|
|
40
|
+
constructor(store, leafStore) {
|
|
41
|
+
this.leafStore = leafStore;
|
|
42
|
+
this.tree = new SparseTreeClass(store);
|
|
43
|
+
// We only do the leaf initialisation when the store
|
|
44
|
+
// has no values. Otherwise, we leave the store
|
|
45
|
+
// as is to not overwrite any data.
|
|
46
|
+
if (this.leafStore.getLeaf(0n) === undefined) {
|
|
47
|
+
this.setLeafInitialisation();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns leaf which lives at a given path.
|
|
52
|
+
* Errors if the path is not defined.
|
|
53
|
+
* @param path path of the node.
|
|
54
|
+
* @returns The data of the node.
|
|
55
|
+
*/
|
|
56
|
+
getLeaf(path) {
|
|
57
|
+
const storedLeaf = this.leafStore.getLeaf(path);
|
|
58
|
+
if (storedLeaf === undefined) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
return new LinkedLeafStruct({
|
|
62
|
+
value: Field(storedLeaf.leaf.value),
|
|
63
|
+
path: Field(storedLeaf.leaf.path),
|
|
64
|
+
nextPath: Field(storedLeaf.leaf.nextPath),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Returns the root of the [Merkle Tree](https://en.wikipedia.org/wiki/Merkle_tree).
|
|
69
|
+
* @returns The root of the Merkle Tree.
|
|
70
|
+
*/
|
|
71
|
+
getRoot() {
|
|
72
|
+
return this.tree.getRoot().toConstant();
|
|
73
|
+
}
|
|
74
|
+
writeLeaf(index, leaf) {
|
|
75
|
+
this.leafStore.setLeaf(index, leaf);
|
|
76
|
+
const leafHash = new LinkedLeafStruct(LinkedLeafStruct.fromValue(leaf)).hash();
|
|
77
|
+
return {
|
|
78
|
+
index,
|
|
79
|
+
leaf: leafHash,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
setLeafInternal(path, value) {
|
|
83
|
+
const storedLeaf = this.leafStore.getLeaf(path);
|
|
84
|
+
if (storedLeaf === undefined) {
|
|
85
|
+
// Insert case
|
|
86
|
+
// The above means the path doesn't already exist, and we are inserting, not updating.
|
|
87
|
+
// This requires us to update the node with the previous path, as well.
|
|
88
|
+
const tempIndex = this.leafStore.getMaximumIndex();
|
|
89
|
+
if (tempIndex === undefined) {
|
|
90
|
+
throw Error("Store Max Index not defined");
|
|
91
|
+
}
|
|
92
|
+
if (tempIndex + 1n >= 2 ** height) {
|
|
93
|
+
throw new Error("Index greater than maximum leaf number");
|
|
94
|
+
}
|
|
95
|
+
const nextFreeIndex = tempIndex + 1n;
|
|
96
|
+
const previousLeaf = this.leafStore.getPreviousLeaf(path);
|
|
97
|
+
if (previousLeaf === undefined) {
|
|
98
|
+
throw Error(`Prev leaf shouldn't be undefined (path ${path})`);
|
|
99
|
+
}
|
|
100
|
+
const newPrevLeaf = {
|
|
101
|
+
...previousLeaf.leaf,
|
|
102
|
+
nextPath: path,
|
|
103
|
+
};
|
|
104
|
+
const treeWrite1 = this.writeLeaf(previousLeaf.index, newPrevLeaf);
|
|
105
|
+
const newLeaf = {
|
|
106
|
+
path,
|
|
107
|
+
value,
|
|
108
|
+
nextPath: previousLeaf.leaf.nextPath,
|
|
109
|
+
};
|
|
110
|
+
const treeWrite2 = this.writeLeaf(nextFreeIndex, newLeaf);
|
|
111
|
+
return {
|
|
112
|
+
leafPrevious: {
|
|
113
|
+
witness: previousLeaf.index,
|
|
114
|
+
witnessLeaf: new LinkedLeafStruct(LinkedLeafStruct.fromValue(previousLeaf.leaf)),
|
|
115
|
+
write: treeWrite1,
|
|
116
|
+
},
|
|
117
|
+
leafCurrent: {
|
|
118
|
+
witness: nextFreeIndex,
|
|
119
|
+
witnessLeaf: LinkedLeafStruct.dummy(),
|
|
120
|
+
write: treeWrite2,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
// Update case
|
|
126
|
+
const updatedLeaf = {
|
|
127
|
+
...storedLeaf.leaf,
|
|
128
|
+
value: value,
|
|
129
|
+
};
|
|
130
|
+
const treeWrite = this.writeLeaf(storedLeaf.index, updatedLeaf);
|
|
131
|
+
return {
|
|
132
|
+
leafPrevious: "dummy",
|
|
133
|
+
leafCurrent: {
|
|
134
|
+
witness: storedLeaf.index,
|
|
135
|
+
witnessLeaf: new LinkedLeafStruct(LinkedLeafStruct.fromValue(storedLeaf.leaf)),
|
|
136
|
+
write: treeWrite,
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
applyOperationInstruction(instruction) {
|
|
142
|
+
if (instruction === "dummy") {
|
|
143
|
+
return AbstractLinkedRollupMerkleTree.dummyReadWitness();
|
|
144
|
+
}
|
|
145
|
+
const merkleWitness = this.tree.getWitness(instruction.witness);
|
|
146
|
+
this.tree.setLeaf(instruction.write.index, instruction.write.leaf);
|
|
147
|
+
return new LinkedLeafAndMerkleWitness({
|
|
148
|
+
merkleWitness,
|
|
149
|
+
leaf: instruction.witnessLeaf,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Sets the value of a node at a given index to a given value.
|
|
154
|
+
* @param path Position of the leaf node.
|
|
155
|
+
* @param value New value.
|
|
156
|
+
*/
|
|
157
|
+
setLeaf(path, value) {
|
|
158
|
+
const { leafPrevious: previousLeafInstruction, leafCurrent: currentLeafInstruction, } = this.setLeafInternal(path, value);
|
|
159
|
+
const leafPrevious = this.applyOperationInstruction(previousLeafInstruction);
|
|
160
|
+
const leafCurrent = this.applyOperationInstruction(currentLeafInstruction);
|
|
161
|
+
return { leafPrevious, leafCurrent };
|
|
162
|
+
}
|
|
163
|
+
setLeaves(batch) {
|
|
164
|
+
if (batch.length > 0) {
|
|
165
|
+
const witnesses = batch.map(({ path, value }) => this.setLeafInternal(path, value));
|
|
166
|
+
// tree.setLeafBatch internally takes care of making the writes unique to optimize
|
|
167
|
+
this.tree.setLeaves(witnesses.flatMap(({ leafPrevious, leafCurrent }) => (leafPrevious === "dummy" ? [] : [leafPrevious.write]).concat(leafCurrent.write)));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Sets the value of a leaf node at initialisation,
|
|
172
|
+
* i.e. {vale: 0, path: 0, nextPath: Field.Max}
|
|
173
|
+
*/
|
|
174
|
+
setLeafInitialisation() {
|
|
175
|
+
// This is the maximum value of the hash
|
|
176
|
+
const MAX_FIELD_VALUE = Field.ORDER - 1n;
|
|
177
|
+
const zeroLeaf = {
|
|
178
|
+
value: 0n,
|
|
179
|
+
path: 0n,
|
|
180
|
+
nextPath: MAX_FIELD_VALUE,
|
|
181
|
+
};
|
|
182
|
+
this.leafStore.setLeaf(0n, zeroLeaf);
|
|
183
|
+
// We now set the leafs in the merkle tree to cascade the values up
|
|
184
|
+
// the tree.
|
|
185
|
+
this.tree.setLeaf(0n, new LinkedLeafStruct(LinkedLeafStruct.fromValue(zeroLeaf)).hash());
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Returns the witness (also known as
|
|
189
|
+
* [Merkle Proof or Merkle Witness](https://computersciencewiki.org/index.php/Merkle_proof))
|
|
190
|
+
* for the leaf at the given path, otherwise returns a witness for the first unused index.
|
|
191
|
+
* @param path of the leaf node.
|
|
192
|
+
* @returns The witness that belongs to the leaf.
|
|
193
|
+
*/
|
|
194
|
+
getReadWitness(path) {
|
|
195
|
+
const storedLeaf = this.leafStore.getLeaf(path);
|
|
196
|
+
let leaf;
|
|
197
|
+
let currentIndex;
|
|
198
|
+
if (storedLeaf === undefined) {
|
|
199
|
+
const storeIndex = this.leafStore.getMaximumIndex();
|
|
200
|
+
if (storeIndex === undefined) {
|
|
201
|
+
throw new Error("Store undefined");
|
|
202
|
+
}
|
|
203
|
+
currentIndex = storeIndex + 1n;
|
|
204
|
+
leaf = LinkedLeafStruct.dummy();
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
leaf = new LinkedLeafStruct(LinkedLeafStruct.fromValue(storedLeaf.leaf));
|
|
208
|
+
currentIndex = storedLeaf.index;
|
|
209
|
+
}
|
|
210
|
+
const merkleWitness = this.tree.getWitness(currentIndex);
|
|
211
|
+
return new LinkedLeafAndMerkleWitness({
|
|
212
|
+
merkleWitness,
|
|
213
|
+
leaf,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
static dummyReadWitness() {
|
|
217
|
+
return new LinkedLeafAndMerkleWitness({
|
|
218
|
+
merkleWitness: SparseTreeClass.WITNESS.dummy(),
|
|
219
|
+
leaf: LinkedLeafStruct.dummy(),
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
static dummyWitness() {
|
|
223
|
+
return new LinkedOperationWitness({
|
|
224
|
+
leafPrevious: AbstractLinkedRollupMerkleTree.dummyReadWitness(),
|
|
225
|
+
leafCurrent: AbstractLinkedRollupMerkleTree.dummyReadWitness(),
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
_a.HEIGHT = height,
|
|
230
|
+
_a.EMPTY_ROOT = new _a(new InMemoryMerkleTreeStorage(), new InMemoryLinkedLeafStore()).getRoot(),
|
|
231
|
+
_a.READ_WITNESS = LinkedLeafAndMerkleWitness,
|
|
232
|
+
_a.WITNESS = LinkedOperationWitness,
|
|
233
|
+
_a;
|
|
234
|
+
}
|
|
235
|
+
export class LinkedMerkleTree extends createLinkedMerkleTree(40) {
|
|
236
|
+
}
|
|
237
|
+
export class LinkedMerkleTreeWitness extends LinkedMerkleTree.WITNESS {
|
|
238
|
+
}
|
|
239
|
+
export class LinkedMerkleTreeReadWitness extends LinkedMerkleTree.READ_WITNESS {
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=LinkedMerkleTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkedMerkleTree.js","sourceRoot":"","sources":["../../../src/trees/lmt/LinkedMerkleTree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAoB,MAAM,4BAA4B,CAAC;AAEhF,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,gBAAgB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B;WA4P/C;AACJ,CAAC;AAED,MAAM,OAAO,gBAAiB,SAAQ,sBAAsB,CAAC,EAAE,CAAC;CAAG;AACnE,MAAM,OAAO,uBAAwB,SAAQ,gBAAgB,CAAC,OAAO;CAAG;AACxE,MAAM,OAAO,2BAA4B,SAAQ,gBAAgB,CAAC,YAAY;CAAG"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Field } from "o1js";
|
|
2
|
+
import { LinkedMerkleTreeWitness } from "./LinkedMerkleTree";
|
|
3
|
+
import { LinkedLeafStruct } from "./LinkedMerkleTreeTypes";
|
|
4
|
+
export type TreeWrite = {
|
|
5
|
+
path: Field;
|
|
6
|
+
from: Field;
|
|
7
|
+
to: Field;
|
|
8
|
+
};
|
|
9
|
+
export declare namespace LinkedMerkleTreeCircuitOps {
|
|
10
|
+
const ComputeRootInstruction_base: (new (value: {
|
|
11
|
+
newPreviousLeaf: LinkedLeafStruct;
|
|
12
|
+
newCurrentLeaf: LinkedLeafStruct;
|
|
13
|
+
allChecksMet: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
14
|
+
}) => {
|
|
15
|
+
newPreviousLeaf: LinkedLeafStruct;
|
|
16
|
+
newCurrentLeaf: LinkedLeafStruct;
|
|
17
|
+
allChecksMet: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
18
|
+
}) & {
|
|
19
|
+
_isStruct: true;
|
|
20
|
+
} & Omit<import("o1js/dist/node/lib/provable/types/provable-intf").Provable<{
|
|
21
|
+
newPreviousLeaf: LinkedLeafStruct;
|
|
22
|
+
newCurrentLeaf: LinkedLeafStruct;
|
|
23
|
+
allChecksMet: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
24
|
+
}, {
|
|
25
|
+
newPreviousLeaf: {
|
|
26
|
+
value: bigint;
|
|
27
|
+
path: bigint;
|
|
28
|
+
nextPath: bigint;
|
|
29
|
+
};
|
|
30
|
+
newCurrentLeaf: {
|
|
31
|
+
value: bigint;
|
|
32
|
+
path: bigint;
|
|
33
|
+
nextPath: bigint;
|
|
34
|
+
};
|
|
35
|
+
allChecksMet: boolean;
|
|
36
|
+
}>, "fromFields"> & {
|
|
37
|
+
fromFields: (fields: import("o1js/dist/node/lib/provable/field").Field[]) => {
|
|
38
|
+
newPreviousLeaf: LinkedLeafStruct;
|
|
39
|
+
newCurrentLeaf: LinkedLeafStruct;
|
|
40
|
+
allChecksMet: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
41
|
+
};
|
|
42
|
+
} & {
|
|
43
|
+
fromValue: (value: {
|
|
44
|
+
newPreviousLeaf: LinkedLeafStruct | {
|
|
45
|
+
value: string | number | bigint | import("o1js/dist/node/lib/provable/field").Field;
|
|
46
|
+
path: string | number | bigint | import("o1js/dist/node/lib/provable/field").Field;
|
|
47
|
+
nextPath: string | number | bigint | import("o1js/dist/node/lib/provable/field").Field;
|
|
48
|
+
};
|
|
49
|
+
newCurrentLeaf: LinkedLeafStruct | {
|
|
50
|
+
value: string | number | bigint | import("o1js/dist/node/lib/provable/field").Field;
|
|
51
|
+
path: string | number | bigint | import("o1js/dist/node/lib/provable/field").Field;
|
|
52
|
+
nextPath: string | number | bigint | import("o1js/dist/node/lib/provable/field").Field;
|
|
53
|
+
};
|
|
54
|
+
allChecksMet: boolean | import("o1js/dist/node/lib/provable/bool").Bool;
|
|
55
|
+
}) => {
|
|
56
|
+
newPreviousLeaf: LinkedLeafStruct;
|
|
57
|
+
newCurrentLeaf: LinkedLeafStruct;
|
|
58
|
+
allChecksMet: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
59
|
+
};
|
|
60
|
+
toInput: (x: {
|
|
61
|
+
newPreviousLeaf: LinkedLeafStruct;
|
|
62
|
+
newCurrentLeaf: LinkedLeafStruct;
|
|
63
|
+
allChecksMet: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
64
|
+
}) => {
|
|
65
|
+
fields?: import("o1js/dist/node/lib/provable/field").Field[] | undefined;
|
|
66
|
+
packed?: [import("o1js/dist/node/lib/provable/field").Field, number][] | undefined;
|
|
67
|
+
};
|
|
68
|
+
toJSON: (x: {
|
|
69
|
+
newPreviousLeaf: LinkedLeafStruct;
|
|
70
|
+
newCurrentLeaf: LinkedLeafStruct;
|
|
71
|
+
allChecksMet: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
72
|
+
}) => {
|
|
73
|
+
newPreviousLeaf: {
|
|
74
|
+
value: string;
|
|
75
|
+
path: string;
|
|
76
|
+
nextPath: string;
|
|
77
|
+
};
|
|
78
|
+
newCurrentLeaf: {
|
|
79
|
+
value: string;
|
|
80
|
+
path: string;
|
|
81
|
+
nextPath: string;
|
|
82
|
+
};
|
|
83
|
+
allChecksMet: boolean;
|
|
84
|
+
};
|
|
85
|
+
fromJSON: (x: {
|
|
86
|
+
newPreviousLeaf: {
|
|
87
|
+
value: string;
|
|
88
|
+
path: string;
|
|
89
|
+
nextPath: string;
|
|
90
|
+
};
|
|
91
|
+
newCurrentLeaf: {
|
|
92
|
+
value: string;
|
|
93
|
+
path: string;
|
|
94
|
+
nextPath: string;
|
|
95
|
+
};
|
|
96
|
+
allChecksMet: boolean;
|
|
97
|
+
}) => {
|
|
98
|
+
newPreviousLeaf: LinkedLeafStruct;
|
|
99
|
+
newCurrentLeaf: LinkedLeafStruct;
|
|
100
|
+
allChecksMet: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
101
|
+
};
|
|
102
|
+
empty: () => {
|
|
103
|
+
newPreviousLeaf: LinkedLeafStruct;
|
|
104
|
+
newCurrentLeaf: LinkedLeafStruct;
|
|
105
|
+
allChecksMet: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
export class ComputeRootInstruction extends ComputeRootInstruction_base {
|
|
109
|
+
}
|
|
110
|
+
export function applyTreeWrite(root: Field, witness: LinkedMerkleTreeWitness, treeWrite: TreeWrite, index: number): Field;
|
|
111
|
+
export {};
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=LinkedMerkleTreeCircuitOps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkedMerkleTreeCircuitOps.d.ts","sourceRoot":"","sources":["../../../src/trees/lmt/LinkedMerkleTreeCircuitOps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,EAAoB,MAAM,MAAM,CAAC;AAErD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAK3D,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,KAAK,CAAC;IACZ,EAAE,EAAE,KAAK,CAAC;CACX,CAAC;AAEF,yBAAiB,0BAA0B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAU1C,MAAM,OAAO,sBAAuB,SAAQ,2BAI1C;KAAG;IA2HL,MAAM,UAAU,cAAc,CAC5B,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,uBAAuB,EAChC,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,MAAM,GACZ,KAAK,CA4BP;;CACF"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Bool, Field, Provable, Struct } from "o1js";
|
|
2
|
+
import { LinkedLeafStruct } from "./LinkedMerkleTreeTypes";
|
|
3
|
+
export var LinkedMerkleTreeCircuitOps;
|
|
4
|
+
(function (LinkedMerkleTreeCircuitOps) {
|
|
5
|
+
function boolAllTrue(...args) {
|
|
6
|
+
return args.reduce((a, b, i) => {
|
|
7
|
+
// if (!b.toBoolean()) {
|
|
8
|
+
// console.log();
|
|
9
|
+
// }
|
|
10
|
+
return a.and(b);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
class ComputeRootInstruction extends Struct({
|
|
14
|
+
newPreviousLeaf: LinkedLeafStruct,
|
|
15
|
+
newCurrentLeaf: LinkedLeafStruct,
|
|
16
|
+
allChecksMet: Bool,
|
|
17
|
+
}) {
|
|
18
|
+
}
|
|
19
|
+
LinkedMerkleTreeCircuitOps.ComputeRootInstruction = ComputeRootInstruction;
|
|
20
|
+
function chooseInstruction(isUpdate, updateInstruction, insertInstruction) {
|
|
21
|
+
return Provable.if(isUpdate, ComputeRootInstruction, updateInstruction, insertInstruction);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* verifyWitness(current.merkleWitness, current.leaf)
|
|
25
|
+
*
|
|
26
|
+
* st.path == current.leaf.path
|
|
27
|
+
* st.from.value == current.leaf.value
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* updates:
|
|
31
|
+
* ```
|
|
32
|
+
* current := { current.path, current.nextPath, value: st.to.value }
|
|
33
|
+
*/
|
|
34
|
+
function update({ leafCurrent, leafPrevious }, { to, from, path }) {
|
|
35
|
+
const allChecksMet = boolAllTrue(path.equals(leafCurrent.leaf.path), leafCurrent.leaf.value.equals(from));
|
|
36
|
+
return {
|
|
37
|
+
newPreviousLeaf: leafPrevious.leaf,
|
|
38
|
+
newCurrentLeaf: new LinkedLeafStruct({
|
|
39
|
+
...leafCurrent.leaf,
|
|
40
|
+
value: to,
|
|
41
|
+
}),
|
|
42
|
+
allChecksMet,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* st.path == current.leaf.path
|
|
47
|
+
*
|
|
48
|
+
* previous.leaf.nextPath > current.leaf.path
|
|
49
|
+
* previous.leaf.path < current.leaf.path
|
|
50
|
+
* previous.leaf.nextPath == current.leaf.nextPath
|
|
51
|
+
*
|
|
52
|
+
* index(current.merkleWitness) == nextFreeIndex
|
|
53
|
+
*
|
|
54
|
+
* updates:
|
|
55
|
+
* previous := { previous.path, previous.value, nextPath: current.path }
|
|
56
|
+
* current := current.leaf
|
|
57
|
+
*/
|
|
58
|
+
function insert(witness, { path, to }) {
|
|
59
|
+
const { leafPrevious: previous, leafCurrent: current } = witness;
|
|
60
|
+
const allChecksMet = boolAllTrue(
|
|
61
|
+
// Already covered in general checks
|
|
62
|
+
// path.equals(current.leaf.path),
|
|
63
|
+
current.leaf.isDummy(), previous.leaf.nextPath.greaterThan(path), previous.leaf.path.lessThan(path));
|
|
64
|
+
return {
|
|
65
|
+
newPreviousLeaf: new LinkedLeafStruct({
|
|
66
|
+
...previous.leaf,
|
|
67
|
+
nextPath: path,
|
|
68
|
+
}),
|
|
69
|
+
newCurrentLeaf: new LinkedLeafStruct({
|
|
70
|
+
path,
|
|
71
|
+
value: to,
|
|
72
|
+
nextPath: previous.leaf.nextPath,
|
|
73
|
+
}),
|
|
74
|
+
allChecksMet,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function computeRoot(witness, newPreviousLeaf, newCurrentLeaf, isUpdate, isDummy, root) {
|
|
78
|
+
const { leafPrevious, leafCurrent } = witness;
|
|
79
|
+
leafPrevious.merkleWitness
|
|
80
|
+
.calculateRoot(leafPrevious.leaf.hash())
|
|
81
|
+
.equals(root)
|
|
82
|
+
.or(isUpdate)
|
|
83
|
+
.assertTrue("Previous leaf calculation not matching");
|
|
84
|
+
const root1 = leafPrevious.merkleWitness.calculateRoot(newPreviousLeaf.hash());
|
|
85
|
+
const intermediateRoot = Provable.if(isUpdate, root, root1);
|
|
86
|
+
// TODO Make this Provable.if more efficient
|
|
87
|
+
const leafCurrentLeaf = Provable.if(isUpdate, leafCurrent.leaf.hash(), Field(0));
|
|
88
|
+
leafCurrent.merkleWitness
|
|
89
|
+
.calculateRoot(leafCurrentLeaf)
|
|
90
|
+
.equals(intermediateRoot)
|
|
91
|
+
.or(isDummy)
|
|
92
|
+
.assertTrue("Current leaf witness invalid");
|
|
93
|
+
return leafCurrent.merkleWitness.calculateRoot(newCurrentLeaf.hash());
|
|
94
|
+
}
|
|
95
|
+
function applyTreeWrite(root, witness, treeWrite, index) {
|
|
96
|
+
const { leafPrevious, leafCurrent } = witness;
|
|
97
|
+
const isUpdate = leafPrevious.leaf.isDummy();
|
|
98
|
+
const isDummy = leafCurrent.leaf.isDummy().and(isUpdate);
|
|
99
|
+
// For read-only and update
|
|
100
|
+
const updateState = update(witness, treeWrite);
|
|
101
|
+
// For insert
|
|
102
|
+
const insertState = insert(witness, treeWrite);
|
|
103
|
+
const instruction = chooseInstruction(isUpdate, updateState, insertState);
|
|
104
|
+
instruction.allChecksMet
|
|
105
|
+
.or(isDummy)
|
|
106
|
+
.assertTrue(`Not all witness checks have been met: ${index}`);
|
|
107
|
+
const newRoot = computeRoot(witness, instruction.newPreviousLeaf, instruction.newCurrentLeaf, isUpdate, isDummy, root);
|
|
108
|
+
return Provable.if(isDummy, root, newRoot);
|
|
109
|
+
}
|
|
110
|
+
LinkedMerkleTreeCircuitOps.applyTreeWrite = applyTreeWrite;
|
|
111
|
+
})(LinkedMerkleTreeCircuitOps || (LinkedMerkleTreeCircuitOps = {}));
|
|
112
|
+
/* eslint-enable no-inner-declarations */
|
|
113
|
+
//# sourceMappingURL=LinkedMerkleTreeCircuitOps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkedMerkleTreeCircuitOps.js","sourceRoot":"","sources":["../../../src/trees/lmt/LinkedMerkleTreeCircuitOps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAW3D,MAAM,KAAW,0BAA0B,CA2K1C;AA3KD,WAAiB,0BAA0B;IACzC,SAAS,WAAW,CAAC,GAAG,IAAY;QAClC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;YAC7B,wBAAwB;YACxB,mBAAmB;YACnB,IAAI;YACJ,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,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AAa,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,SAAgB,cAAc,CAC5B,IAAW,EACX,OAAgC,EAChC,SAAoB,EACpB,KAAa;QAEb,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAE9C,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAC7C,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAEzD,2BAA2B;QAC3B,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAE/C,aAAa;QACb,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAE/C,MAAM,WAAW,GAAG,iBAAiB,CAAC,QAAQ,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;QAE1E,WAAW,CAAC,YAAY;aACrB,EAAE,CAAC,OAAO,CAAC;aACX,UAAU,CAAC,yCAAyC,KAAK,EAAE,CAAC,CAAC;QAEhE,MAAM,OAAO,GAAG,WAAW,CACzB,OAAO,EACP,WAAW,CAAC,eAAe,EAC3B,WAAW,CAAC,cAAc,EAC1B,QAAQ,EACR,OAAO,EACP,IAAI,CACL,CAAC;QAEF,OAAO,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAjCe,yCAAc,iBAiC7B,CAAA;AACH,CAAC,EA3KgB,0BAA0B,KAA1B,0BAA0B,QA2K1C;AAED,yCAAyC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MerkleTreeStore } from "../sparse/MerkleTreeStore";
|
|
2
|
+
import { LinkedLeafStore } from "./LinkedLinkedStore";
|
|
3
|
+
export interface SyncLinkedMerkleTreeDatabase {
|
|
4
|
+
treeStore: MerkleTreeStore;
|
|
5
|
+
leafStore: LinkedLeafStore;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=LinkedMerkleTreeDatabase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkedMerkleTreeDatabase.d.ts","sourceRoot":"","sources":["../../../src/trees/lmt/LinkedMerkleTreeDatabase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,eAAe,CAAC;IAC3B,SAAS,EAAE,eAAe,CAAC;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkedMerkleTreeDatabase.js","sourceRoot":"","sources":["../../../src/trees/lmt/LinkedMerkleTreeDatabase.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type LinkedLeaf = {
|
|
2
|
+
value: bigint;
|
|
3
|
+
path: bigint;
|
|
4
|
+
nextPath: bigint;
|
|
5
|
+
};
|
|
6
|
+
export type StoredLeaf = {
|
|
7
|
+
leaf: LinkedLeaf;
|
|
8
|
+
index: bigint;
|
|
9
|
+
};
|
|
10
|
+
export interface LinkedLeafStore {
|
|
11
|
+
setLeaf: (index: bigint, value: LinkedLeaf) => void;
|
|
12
|
+
getLeaf: (path: bigint) => StoredLeaf | undefined;
|
|
13
|
+
getLeafLessOrEqual: (path: bigint) => StoredLeaf | undefined;
|
|
14
|
+
getMaximumIndex: () => bigint | undefined;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=LinkedMerkleTreeStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkedMerkleTreeStore.d.ts","sourceRoot":"","sources":["../../../src/trees/lmt/LinkedMerkleTreeStore.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,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,UAAU,GAAG,SAAS,CAAC;IAElD,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,GAAG,SAAS,CAAC;IAE7D,eAAe,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkedMerkleTreeStore.js","sourceRoot":"","sources":["../../../src/trees/lmt/LinkedMerkleTreeStore.ts"],"names":[],"mappings":""}
|