@enbox/dwn-sdk-js 0.0.6 → 0.0.7
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/browser.mjs +8 -8
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/generated/precompiled-validators.js +1 -2
- package/dist/esm/generated/precompiled-validators.js.map +1 -1
- package/dist/esm/src/core/abstract-message.js +4 -0
- package/dist/esm/src/core/abstract-message.js.map +1 -1
- package/dist/esm/src/core/auth.js +22 -33
- package/dist/esm/src/core/auth.js.map +1 -1
- package/dist/esm/src/core/dwn-constant.js +7 -7
- package/dist/esm/src/core/dwn-constant.js.map +1 -1
- package/dist/esm/src/core/dwn-error.js +1 -0
- package/dist/esm/src/core/dwn-error.js.map +1 -1
- package/dist/esm/src/core/grant-authorization.js +37 -52
- package/dist/esm/src/core/grant-authorization.js.map +1 -1
- package/dist/esm/src/core/message.js +85 -116
- package/dist/esm/src/core/message.js.map +1 -1
- package/dist/esm/src/core/messages-grant-authorization.js +63 -78
- package/dist/esm/src/core/messages-grant-authorization.js.map +1 -1
- package/dist/esm/src/core/protocol-authorization-action.js +266 -0
- package/dist/esm/src/core/protocol-authorization-action.js.map +1 -0
- package/dist/esm/src/core/protocol-authorization-validation.js +254 -0
- package/dist/esm/src/core/protocol-authorization-validation.js.map +1 -0
- package/dist/esm/src/core/protocol-authorization.js +122 -740
- package/dist/esm/src/core/protocol-authorization.js.map +1 -1
- package/dist/esm/src/core/protocols-grant-authorization.js +24 -38
- package/dist/esm/src/core/protocols-grant-authorization.js.map +1 -1
- package/dist/esm/src/core/record-chain.js +64 -0
- package/dist/esm/src/core/record-chain.js.map +1 -0
- package/dist/esm/src/core/records-grant-authorization.js +55 -72
- package/dist/esm/src/core/records-grant-authorization.js.map +1 -1
- package/dist/esm/src/core/resumable-task-manager.js +50 -65
- package/dist/esm/src/core/resumable-task-manager.js.map +1 -1
- package/dist/esm/src/core/tenant-gate.js +2 -13
- package/dist/esm/src/core/tenant-gate.js.map +1 -1
- package/dist/esm/src/dwn.js +69 -86
- package/dist/esm/src/dwn.js.map +1 -1
- package/dist/esm/src/event-stream/event-emitter-stream.js +17 -31
- package/dist/esm/src/event-stream/event-emitter-stream.js.map +1 -1
- package/dist/esm/src/handlers/messages-read.js +67 -77
- package/dist/esm/src/handlers/messages-read.js.map +1 -1
- package/dist/esm/src/handlers/messages-subscribe.js +51 -61
- package/dist/esm/src/handlers/messages-subscribe.js.map +1 -1
- package/dist/esm/src/handlers/messages-sync.js +75 -85
- package/dist/esm/src/handlers/messages-sync.js.map +1 -1
- package/dist/esm/src/handlers/protocols-configure.js +135 -155
- package/dist/esm/src/handlers/protocols-configure.js.map +1 -1
- package/dist/esm/src/handlers/protocols-query.js +52 -51
- package/dist/esm/src/handlers/protocols-query.js.map +1 -1
- package/dist/esm/src/handlers/records-count.js +96 -82
- package/dist/esm/src/handlers/records-count.js.map +1 -1
- package/dist/esm/src/handlers/records-delete.js +78 -88
- package/dist/esm/src/handlers/records-delete.js.map +1 -1
- package/dist/esm/src/handlers/records-query.js +116 -101
- package/dist/esm/src/handlers/records-query.js.map +1 -1
- package/dist/esm/src/handlers/records-read.js +124 -131
- package/dist/esm/src/handlers/records-read.js.map +1 -1
- package/dist/esm/src/handlers/records-subscribe.js +150 -103
- package/dist/esm/src/handlers/records-subscribe.js.map +1 -1
- package/dist/esm/src/handlers/records-write.js +250 -259
- package/dist/esm/src/handlers/records-write.js.map +1 -1
- package/dist/esm/src/interfaces/messages-read.js +24 -32
- package/dist/esm/src/interfaces/messages-read.js.map +1 -1
- package/dist/esm/src/interfaces/messages-subscribe.js +27 -41
- package/dist/esm/src/interfaces/messages-subscribe.js.map +1 -1
- package/dist/esm/src/interfaces/messages-sync.js +26 -40
- package/dist/esm/src/interfaces/messages-sync.js.map +1 -1
- package/dist/esm/src/interfaces/protocols-configure.js +63 -63
- package/dist/esm/src/interfaces/protocols-configure.js.map +1 -1
- package/dist/esm/src/interfaces/protocols-query.js +55 -68
- package/dist/esm/src/interfaces/protocols-query.js.map +1 -1
- package/dist/esm/src/interfaces/records-count.js +50 -66
- package/dist/esm/src/interfaces/records-count.js.map +1 -1
- package/dist/esm/src/interfaces/records-delete.js +45 -55
- package/dist/esm/src/interfaces/records-delete.js.map +1 -1
- package/dist/esm/src/interfaces/records-query.js +60 -76
- package/dist/esm/src/interfaces/records-query.js.map +1 -1
- package/dist/esm/src/interfaces/records-read.js +51 -67
- package/dist/esm/src/interfaces/records-read.js.map +1 -1
- package/dist/esm/src/interfaces/records-subscribe.js +52 -68
- package/dist/esm/src/interfaces/records-subscribe.js.map +1 -1
- package/dist/esm/src/interfaces/records-write-query.js +102 -0
- package/dist/esm/src/interfaces/records-write-query.js.map +1 -0
- package/dist/esm/src/interfaces/records-write-signing.js +92 -0
- package/dist/esm/src/interfaces/records-write-signing.js.map +1 -0
- package/dist/esm/src/interfaces/records-write.js +407 -602
- package/dist/esm/src/interfaces/records-write.js.map +1 -1
- package/dist/esm/src/jose/algorithms/signing/ed25519.js +10 -19
- package/dist/esm/src/jose/algorithms/signing/ed25519.js.map +1 -1
- package/dist/esm/src/jose/jws/general/builder.js +23 -35
- package/dist/esm/src/jose/jws/general/builder.js.map +1 -1
- package/dist/esm/src/jose/jws/general/verifier.js +56 -69
- package/dist/esm/src/jose/jws/general/verifier.js.map +1 -1
- package/dist/esm/src/protocols/permission-grant.js +44 -15
- package/dist/esm/src/protocols/permission-grant.js.map +1 -1
- package/dist/esm/src/protocols/permission-request.js +29 -15
- package/dist/esm/src/protocols/permission-request.js.map +1 -1
- package/dist/esm/src/protocols/permissions.js +216 -226
- package/dist/esm/src/protocols/permissions.js.map +1 -1
- package/dist/esm/src/smt/smt-store-level.js +42 -64
- package/dist/esm/src/smt/smt-store-level.js.map +1 -1
- package/dist/esm/src/smt/smt-store-memory.js +19 -45
- package/dist/esm/src/smt/smt-store-memory.js.map +1 -1
- package/dist/esm/src/smt/smt-utils.js +28 -45
- package/dist/esm/src/smt/smt-utils.js.map +1 -1
- package/dist/esm/src/smt/sparse-merkle-tree.js +426 -471
- package/dist/esm/src/smt/sparse-merkle-tree.js.map +1 -1
- package/dist/esm/src/state-index/state-index-level.js +115 -150
- package/dist/esm/src/state-index/state-index-level.js.map +1 -1
- package/dist/esm/src/store/blockstore-level.js +54 -156
- package/dist/esm/src/store/blockstore-level.js.map +1 -1
- package/dist/esm/src/store/blockstore-mock.js +48 -153
- package/dist/esm/src/store/blockstore-mock.js.map +1 -1
- package/dist/esm/src/store/data-store-level.js +59 -99
- package/dist/esm/src/store/data-store-level.js.map +1 -1
- package/dist/esm/src/store/index-level-compound.js +246 -0
- package/dist/esm/src/store/index-level-compound.js.map +1 -0
- package/dist/esm/src/store/index-level.js +295 -713
- package/dist/esm/src/store/index-level.js.map +1 -1
- package/dist/esm/src/store/level-wrapper.js +143 -244
- package/dist/esm/src/store/level-wrapper.js.map +1 -1
- package/dist/esm/src/store/message-store-level.js +71 -94
- package/dist/esm/src/store/message-store-level.js.map +1 -1
- package/dist/esm/src/store/resumable-task-store-level.js +62 -101
- package/dist/esm/src/store/resumable-task-store-level.js.map +1 -1
- package/dist/esm/src/store/storage-controller.js +129 -144
- package/dist/esm/src/store/storage-controller.js.map +1 -1
- package/dist/esm/src/utils/abort.js +8 -19
- package/dist/esm/src/utils/abort.js.map +1 -1
- package/dist/esm/src/utils/array.js +15 -49
- package/dist/esm/src/utils/array.js.map +1 -1
- package/dist/esm/src/utils/cid.js +29 -77
- package/dist/esm/src/utils/cid.js.map +1 -1
- package/dist/esm/src/utils/data-stream.js +37 -65
- package/dist/esm/src/utils/data-stream.js.map +1 -1
- package/dist/esm/src/utils/encryption.js +136 -162
- package/dist/esm/src/utils/encryption.js.map +1 -1
- package/dist/esm/src/utils/filter.js +1 -12
- package/dist/esm/src/utils/filter.js.map +1 -1
- package/dist/esm/src/utils/hd-key.js +45 -63
- package/dist/esm/src/utils/hd-key.js.map +1 -1
- package/dist/esm/src/utils/jws.js +9 -20
- package/dist/esm/src/utils/jws.js.map +1 -1
- package/dist/esm/src/utils/memory-cache.js +12 -23
- package/dist/esm/src/utils/memory-cache.js.map +1 -1
- package/dist/esm/src/utils/messages.js +9 -3
- package/dist/esm/src/utils/messages.js.map +1 -1
- package/dist/esm/src/utils/private-key-signer.js +9 -17
- package/dist/esm/src/utils/private-key-signer.js.map +1 -1
- package/dist/esm/src/utils/protocols.js +62 -70
- package/dist/esm/src/utils/protocols.js.map +1 -1
- package/dist/esm/src/utils/records.js +100 -125
- package/dist/esm/src/utils/records.js.map +1 -1
- package/dist/esm/src/utils/secp256k1.js +60 -96
- package/dist/esm/src/utils/secp256k1.js.map +1 -1
- package/dist/esm/src/utils/secp256r1.js +54 -71
- package/dist/esm/src/utils/secp256r1.js.map +1 -1
- package/dist/esm/src/utils/time.js +5 -18
- package/dist/esm/src/utils/time.js.map +1 -1
- package/dist/esm/src/utils/url.js +3 -3
- package/dist/esm/src/utils/url.js.map +1 -1
- package/dist/esm/tests/core/auth.spec.js +3 -12
- package/dist/esm/tests/core/auth.spec.js.map +1 -1
- package/dist/esm/tests/core/message.spec.js +50 -59
- package/dist/esm/tests/core/message.spec.js.map +1 -1
- package/dist/esm/tests/core/protocol-authorization.spec.js +9 -18
- package/dist/esm/tests/core/protocol-authorization.spec.js.map +1 -1
- package/dist/esm/tests/dwn.spec.js +45 -58
- package/dist/esm/tests/dwn.spec.js.map +1 -1
- package/dist/esm/tests/event-stream/event-emitter-stream.spec.js +24 -33
- package/dist/esm/tests/event-stream/event-emitter-stream.spec.js.map +1 -1
- package/dist/esm/tests/event-stream/event-stream.spec.js +46 -55
- package/dist/esm/tests/event-stream/event-stream.spec.js.map +1 -1
- package/dist/esm/tests/features/author-delegated-grant.spec.js +326 -343
- package/dist/esm/tests/features/author-delegated-grant.spec.js.map +1 -1
- package/dist/esm/tests/features/owner-delegated-grant.spec.js +153 -169
- package/dist/esm/tests/features/owner-delegated-grant.spec.js.map +1 -1
- package/dist/esm/tests/features/owner-signature.spec.js +67 -78
- package/dist/esm/tests/features/owner-signature.spec.js.map +1 -1
- package/dist/esm/tests/features/permissions.spec.js +446 -181
- package/dist/esm/tests/features/permissions.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-composition.spec.js +346 -356
- package/dist/esm/tests/features/protocol-composition.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-create-action.spec.js +42 -51
- package/dist/esm/tests/features/protocol-create-action.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-delete-action.spec.js +94 -103
- package/dist/esm/tests/features/protocol-delete-action.spec.js.map +1 -1
- package/dist/esm/tests/features/protocol-update-action.spec.js +105 -114
- package/dist/esm/tests/features/protocol-update-action.spec.js.map +1 -1
- package/dist/esm/tests/features/records-prune.spec.js +175 -191
- package/dist/esm/tests/features/records-prune.spec.js.map +1 -1
- package/dist/esm/tests/features/records-tags.spec.js +441 -460
- package/dist/esm/tests/features/records-tags.spec.js.map +1 -1
- package/dist/esm/tests/features/resumable-tasks.spec.js +82 -91
- package/dist/esm/tests/features/resumable-tasks.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-read.spec.js +206 -207
- package/dist/esm/tests/handlers/messages-read.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-subscribe.spec.js +145 -154
- package/dist/esm/tests/handlers/messages-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/handlers/messages-sync.spec.js +174 -183
- package/dist/esm/tests/handlers/messages-sync.spec.js.map +1 -1
- package/dist/esm/tests/handlers/protocols-configure.spec.js +244 -238
- package/dist/esm/tests/handlers/protocols-configure.spec.js.map +1 -1
- package/dist/esm/tests/handlers/protocols-query.spec.js +156 -169
- package/dist/esm/tests/handlers/protocols-query.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-count.spec.js +93 -102
- package/dist/esm/tests/handlers/records-count.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-delete.spec.js +252 -264
- package/dist/esm/tests/handlers/records-delete.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-query.spec.js +917 -988
- package/dist/esm/tests/handlers/records-query.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-read.spec.js +549 -564
- package/dist/esm/tests/handlers/records-read.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-subscribe.spec.js +269 -278
- package/dist/esm/tests/handlers/records-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/handlers/records-write.spec.js +1057 -1082
- package/dist/esm/tests/handlers/records-write.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/messages-get.spec.js +39 -48
- package/dist/esm/tests/interfaces/messages-get.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/messages-subscribe.spec.js +4 -13
- package/dist/esm/tests/interfaces/messages-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/protocols-configure.spec.js +212 -88
- package/dist/esm/tests/interfaces/protocols-configure.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/protocols-query.spec.js +8 -17
- package/dist/esm/tests/interfaces/protocols-query.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-delete.spec.js +8 -17
- package/dist/esm/tests/interfaces/records-delete.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-query.spec.js +20 -29
- package/dist/esm/tests/interfaces/records-query.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-read.spec.js +42 -51
- package/dist/esm/tests/interfaces/records-read.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-subscribe.spec.js +16 -25
- package/dist/esm/tests/interfaces/records-subscribe.spec.js.map +1 -1
- package/dist/esm/tests/interfaces/records-write.spec.js +152 -165
- package/dist/esm/tests/interfaces/records-write.spec.js.map +1 -1
- package/dist/esm/tests/jose/jws/general.spec.js +36 -45
- package/dist/esm/tests/jose/jws/general.spec.js.map +1 -1
- package/dist/esm/tests/protocols/permission-grant.spec.js +44 -50
- package/dist/esm/tests/protocols/permission-grant.spec.js.map +1 -1
- package/dist/esm/tests/protocols/permission-request.spec.js +23 -32
- package/dist/esm/tests/protocols/permission-request.spec.js.map +1 -1
- package/dist/esm/tests/protocols/permissions.spec.js +49 -55
- package/dist/esm/tests/protocols/permissions.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/aggregator.spec.js +124 -135
- package/dist/esm/tests/scenarios/aggregator.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/deleted-record.spec.js +23 -32
- package/dist/esm/tests/scenarios/deleted-record.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js +52 -61
- package/dist/esm/tests/scenarios/end-to-end-tests.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/nested-roles.spec.js +63 -73
- package/dist/esm/tests/scenarios/nested-roles.spec.js.map +1 -1
- package/dist/esm/tests/scenarios/subscriptions.spec.js +377 -333
- package/dist/esm/tests/scenarios/subscriptions.spec.js.map +1 -1
- package/dist/esm/tests/smt/smt-store-level.spec.js +76 -87
- package/dist/esm/tests/smt/smt-store-level.spec.js.map +1 -1
- package/dist/esm/tests/smt/sparse-merkle-tree.spec.js +344 -353
- package/dist/esm/tests/smt/sparse-merkle-tree.spec.js.map +1 -1
- package/dist/esm/tests/state-index/state-index-level.spec.js +117 -126
- package/dist/esm/tests/state-index/state-index-level.spec.js.map +1 -1
- package/dist/esm/tests/store/blockstore-level.spec.js +44 -99
- package/dist/esm/tests/store/blockstore-level.spec.js.map +1 -1
- package/dist/esm/tests/store/blockstore-mock.spec.js +40 -120
- package/dist/esm/tests/store/blockstore-mock.spec.js.map +1 -1
- package/dist/esm/tests/store/data-store-level.spec.js +86 -95
- package/dist/esm/tests/store/data-store-level.spec.js.map +1 -1
- package/dist/esm/tests/store/index-level.spec.js +404 -414
- package/dist/esm/tests/store/index-level.spec.js.map +1 -1
- package/dist/esm/tests/store/message-store-level.spec.js +13 -22
- package/dist/esm/tests/store/message-store-level.spec.js.map +1 -1
- package/dist/esm/tests/store/message-store.spec.js +229 -238
- package/dist/esm/tests/store/message-store.spec.js.map +1 -1
- package/dist/esm/tests/test-event-stream.js +3 -3
- package/dist/esm/tests/test-event-stream.js.map +1 -1
- package/dist/esm/tests/test-stores.js +16 -13
- package/dist/esm/tests/test-stores.js.map +1 -1
- package/dist/esm/tests/test-suite.js +2 -11
- package/dist/esm/tests/test-suite.js.map +1 -1
- package/dist/esm/tests/utils/cid.spec.js +24 -33
- package/dist/esm/tests/utils/cid.spec.js.map +1 -1
- package/dist/esm/tests/utils/data-stream.spec.js +48 -57
- package/dist/esm/tests/utils/data-stream.spec.js.map +1 -1
- package/dist/esm/tests/utils/encryption-callbacks.spec.js +45 -54
- package/dist/esm/tests/utils/encryption-callbacks.spec.js.map +1 -1
- package/dist/esm/tests/utils/encryption.spec.js +229 -82
- package/dist/esm/tests/utils/encryption.spec.js.map +1 -1
- package/dist/esm/tests/utils/filters.spec.js +46 -55
- package/dist/esm/tests/utils/filters.spec.js.map +1 -1
- package/dist/esm/tests/utils/hd-key.spec.js +10 -19
- package/dist/esm/tests/utils/hd-key.spec.js.map +1 -1
- package/dist/esm/tests/utils/jws.spec.js +3 -12
- package/dist/esm/tests/utils/jws.spec.js.map +1 -1
- package/dist/esm/tests/utils/memory-cache.spec.js +9 -18
- package/dist/esm/tests/utils/memory-cache.spec.js.map +1 -1
- package/dist/esm/tests/utils/messages.spec.js +6 -15
- package/dist/esm/tests/utils/messages.spec.js.map +1 -1
- package/dist/esm/tests/utils/poller.js +22 -33
- package/dist/esm/tests/utils/poller.js.map +1 -1
- package/dist/esm/tests/utils/private-key-signer.spec.js +15 -24
- package/dist/esm/tests/utils/private-key-signer.spec.js.map +1 -1
- package/dist/esm/tests/utils/records.spec.js +10 -19
- package/dist/esm/tests/utils/records.spec.js.map +1 -1
- package/dist/esm/tests/utils/secp256k1.spec.js +16 -25
- package/dist/esm/tests/utils/secp256k1.spec.js.map +1 -1
- package/dist/esm/tests/utils/secp256r1.spec.js +18 -27
- package/dist/esm/tests/utils/secp256r1.spec.js.map +1 -1
- package/dist/esm/tests/utils/test-data-generator.js +414 -468
- package/dist/esm/tests/utils/test-data-generator.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/definitions.spec.js +2 -11
- package/dist/esm/tests/validation/json-schemas/definitions.spec.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/jwk/general-jwk.spec.js +4 -13
- package/dist/esm/tests/validation/json-schemas/jwk/general-jwk.spec.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/jwk/public-jwk.spec.js +8 -17
- package/dist/esm/tests/validation/json-schemas/jwk/public-jwk.spec.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/jwk-verification-method.spec.js +3 -12
- package/dist/esm/tests/validation/json-schemas/jwk-verification-method.spec.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js +4 -13
- package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/records/records-query.spec.js +2 -11
- package/dist/esm/tests/validation/json-schemas/records/records-query.spec.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/records/records-read.spec.js +2 -11
- package/dist/esm/tests/validation/json-schemas/records/records-read.spec.js.map +1 -1
- package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js +7 -16
- package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js.map +1 -1
- package/dist/types/src/core/protocol-authorization-action.d.ts +42 -0
- package/dist/types/src/core/protocol-authorization-action.d.ts.map +1 -0
- package/dist/types/src/core/protocol-authorization-validation.d.ts +60 -0
- package/dist/types/src/core/protocol-authorization-validation.d.ts.map +1 -0
- package/dist/types/src/core/protocol-authorization.d.ts +10 -100
- package/dist/types/src/core/protocol-authorization.d.ts.map +1 -1
- package/dist/types/src/core/record-chain.d.ts +24 -0
- package/dist/types/src/core/record-chain.d.ts.map +1 -0
- package/dist/types/src/handlers/records-write.d.ts +2 -1
- package/dist/types/src/handlers/records-write.d.ts.map +1 -1
- package/dist/types/src/interfaces/protocols-configure.d.ts.map +1 -1
- package/dist/types/src/interfaces/records-write-query.d.ts +33 -0
- package/dist/types/src/interfaces/records-write-query.d.ts.map +1 -0
- package/dist/types/src/interfaces/records-write-signing.d.ts +35 -0
- package/dist/types/src/interfaces/records-write-signing.d.ts.map +1 -0
- package/dist/types/src/interfaces/records-write.d.ts +10 -44
- package/dist/types/src/interfaces/records-write.d.ts.map +1 -1
- package/dist/types/src/store/index-level-compound.d.ts +70 -0
- package/dist/types/src/store/index-level-compound.d.ts.map +1 -0
- package/dist/types/src/store/index-level.d.ts +0 -58
- package/dist/types/src/store/index-level.d.ts.map +1 -1
- package/dist/types/src/utils/protocols.d.ts +5 -0
- package/dist/types/src/utils/protocols.d.ts.map +1 -1
- package/dist/types/tests/features/permissions.spec.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/core/protocol-authorization-action.ts +377 -0
- package/src/core/protocol-authorization-validation.ts +391 -0
- package/src/core/protocol-authorization.ts +60 -849
- package/src/core/record-chain.ts +99 -0
- package/src/handlers/records-read.ts +1 -1
- package/src/handlers/records-write.ts +37 -21
- package/src/interfaces/protocols-configure.ts +33 -5
- package/src/interfaces/records-write-query.ts +139 -0
- package/src/interfaces/records-write-signing.ts +143 -0
- package/src/interfaces/records-write.ts +49 -221
- package/src/store/index-level-compound.ts +324 -0
- package/src/store/index-level.ts +24 -306
- package/src/utils/protocols.ts +8 -0
- package/src/utils/records.ts +1 -1
|
@@ -13,17 +13,10 @@
|
|
|
13
13
|
* - Supports inclusion and non-inclusion proofs
|
|
14
14
|
* - Root hash provides a fingerprint of the entire set for O(1) comparison
|
|
15
15
|
*/
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
16
|
import { getBit, hashChildren, hashEquals, hashKey, hashLeaf, initDefaultHashes, SMT_DEPTH } from './smt-utils.js';
|
|
26
17
|
export class SparseMerkleTree {
|
|
18
|
+
store;
|
|
19
|
+
defaultHashes;
|
|
27
20
|
constructor(store) {
|
|
28
21
|
this.store = store;
|
|
29
22
|
}
|
|
@@ -31,39 +24,31 @@ export class SparseMerkleTree {
|
|
|
31
24
|
* Initialize the SMT. Must be called before any operations.
|
|
32
25
|
* Opens the store and precomputes default hashes.
|
|
33
26
|
*/
|
|
34
|
-
initialize() {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.defaultHashes = yield initDefaultHashes();
|
|
38
|
-
});
|
|
27
|
+
async initialize() {
|
|
28
|
+
await this.store.open();
|
|
29
|
+
this.defaultHashes = await initDefaultHashes();
|
|
39
30
|
}
|
|
40
31
|
/**
|
|
41
32
|
* Close the underlying store.
|
|
42
33
|
*/
|
|
43
|
-
close() {
|
|
44
|
-
|
|
45
|
-
yield this.store.close();
|
|
46
|
-
});
|
|
34
|
+
async close() {
|
|
35
|
+
await this.store.close();
|
|
47
36
|
}
|
|
48
37
|
/**
|
|
49
38
|
* Clear all data from the tree.
|
|
50
39
|
*/
|
|
51
|
-
clear() {
|
|
52
|
-
|
|
53
|
-
yield this.store.clear();
|
|
54
|
-
});
|
|
40
|
+
async clear() {
|
|
41
|
+
await this.store.clear();
|
|
55
42
|
}
|
|
56
43
|
/**
|
|
57
44
|
* Get the current root hash. Returns the default empty root if no root is set.
|
|
58
45
|
*/
|
|
59
|
-
getRoot() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return root;
|
|
66
|
-
});
|
|
46
|
+
async getRoot() {
|
|
47
|
+
const root = await this.store.getRoot();
|
|
48
|
+
if (root === undefined) {
|
|
49
|
+
return this.defaultHashes[0];
|
|
50
|
+
}
|
|
51
|
+
return root;
|
|
67
52
|
}
|
|
68
53
|
/**
|
|
69
54
|
* Insert a messageCid into the tree.
|
|
@@ -71,57 +56,49 @@ export class SparseMerkleTree {
|
|
|
71
56
|
*
|
|
72
57
|
* @returns the new root hash after insertion
|
|
73
58
|
*/
|
|
74
|
-
insert(messageCid) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return newRoot;
|
|
90
|
-
});
|
|
59
|
+
async insert(messageCid) {
|
|
60
|
+
const keyHash = await hashKey(messageCid);
|
|
61
|
+
const leafHash = await hashLeaf(keyHash, messageCid);
|
|
62
|
+
const leafNode = {
|
|
63
|
+
type: 'leaf',
|
|
64
|
+
keyHash: keyHash,
|
|
65
|
+
valueCid: messageCid,
|
|
66
|
+
};
|
|
67
|
+
// Store the leaf node
|
|
68
|
+
await this.store.putNode(leafHash, leafNode);
|
|
69
|
+
// Walk down the tree from root to leaf position, collecting the path
|
|
70
|
+
const currentRoot = await this.getRoot();
|
|
71
|
+
const newRoot = await this.insertAtNode(currentRoot, keyHash, leafHash, leafNode, 0);
|
|
72
|
+
await this.store.setRoot(newRoot);
|
|
73
|
+
return newRoot;
|
|
91
74
|
}
|
|
92
75
|
/**
|
|
93
76
|
* Delete a messageCid from the tree.
|
|
94
77
|
*
|
|
95
78
|
* @returns the new root hash after deletion
|
|
96
79
|
*/
|
|
97
|
-
delete(messageCid) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return newRoot;
|
|
104
|
-
});
|
|
80
|
+
async delete(messageCid) {
|
|
81
|
+
const keyHash = await hashKey(messageCid);
|
|
82
|
+
const currentRoot = await this.getRoot();
|
|
83
|
+
const newRoot = await this.deleteAtNode(currentRoot, keyHash, 0);
|
|
84
|
+
await this.store.setRoot(newRoot);
|
|
85
|
+
return newRoot;
|
|
105
86
|
}
|
|
106
87
|
/**
|
|
107
88
|
* Check if a messageCid exists in the tree.
|
|
108
89
|
*/
|
|
109
|
-
has(messageCid) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return this.existsAtNode(currentRoot, keyHash, 0);
|
|
114
|
-
});
|
|
90
|
+
async has(messageCid) {
|
|
91
|
+
const keyHash = await hashKey(messageCid);
|
|
92
|
+
const currentRoot = await this.getRoot();
|
|
93
|
+
return this.existsAtNode(currentRoot, keyHash, 0);
|
|
115
94
|
}
|
|
116
95
|
/**
|
|
117
96
|
* Generate a membership proof (inclusion or non-inclusion) for a messageCid.
|
|
118
97
|
*/
|
|
119
|
-
getProof(messageCid) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return this.generateProof(currentRoot, keyHash, 0);
|
|
124
|
-
});
|
|
98
|
+
async getProof(messageCid) {
|
|
99
|
+
const keyHash = await hashKey(messageCid);
|
|
100
|
+
const currentRoot = await this.getRoot();
|
|
101
|
+
return this.generateProof(currentRoot, keyHash, 0);
|
|
125
102
|
}
|
|
126
103
|
/**
|
|
127
104
|
* Get the hash of a subtree at a given bit prefix.
|
|
@@ -130,71 +107,67 @@ export class SparseMerkleTree {
|
|
|
130
107
|
* @param prefix - array of booleans representing the path (false=left, true=right)
|
|
131
108
|
* @returns the hash of the subtree at that prefix
|
|
132
109
|
*/
|
|
133
|
-
getSubtreeHash(prefix) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return this.computeSubtreeHashForLeaf(node, i, prefix);
|
|
149
|
-
}
|
|
150
|
-
return this.defaultHashes[prefix.length];
|
|
151
|
-
}
|
|
152
|
-
const internalNode = node;
|
|
153
|
-
if (prefix[i]) {
|
|
154
|
-
currentHash = internalNode.rightHash;
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
currentHash = internalNode.leftHash;
|
|
110
|
+
async getSubtreeHash(prefix) {
|
|
111
|
+
let currentHash = await this.getRoot();
|
|
112
|
+
for (let i = 0; i < prefix.length; i++) {
|
|
113
|
+
if (hashEquals(currentHash, this.defaultHashes[i])) {
|
|
114
|
+
// Empty subtree — return the default hash at the target depth
|
|
115
|
+
return this.defaultHashes[prefix.length];
|
|
116
|
+
}
|
|
117
|
+
const node = await this.store.getNode(currentHash);
|
|
118
|
+
if (node === undefined || node.type === 'leaf') {
|
|
119
|
+
// Leaf reached before prefix exhausted — need to compute what the
|
|
120
|
+
// subtree hash would be if this leaf were pushed down to the prefix depth.
|
|
121
|
+
// For simplicity, if we've hit a leaf, the subtree at this prefix
|
|
122
|
+
// either contains this leaf or is empty.
|
|
123
|
+
if (node !== undefined && node.type === 'leaf') {
|
|
124
|
+
return this.computeSubtreeHashForLeaf(node, i, prefix);
|
|
158
125
|
}
|
|
126
|
+
return this.defaultHashes[prefix.length];
|
|
159
127
|
}
|
|
160
|
-
|
|
161
|
-
|
|
128
|
+
const internalNode = node;
|
|
129
|
+
if (prefix[i]) {
|
|
130
|
+
currentHash = internalNode.rightHash;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
currentHash = internalNode.leftHash;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return currentHash;
|
|
162
137
|
}
|
|
163
138
|
/**
|
|
164
139
|
* Get all leaf messageCids under a given prefix.
|
|
165
140
|
* Used by the sync protocol for tree walking.
|
|
166
141
|
*/
|
|
167
|
-
getLeaves(prefix) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return [node.valueCid];
|
|
184
|
-
}
|
|
185
|
-
return [];
|
|
186
|
-
}
|
|
187
|
-
const internalNode = node;
|
|
188
|
-
if (prefix[i]) {
|
|
189
|
-
currentHash = internalNode.rightHash;
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
currentHash = internalNode.leftHash;
|
|
142
|
+
async getLeaves(prefix) {
|
|
143
|
+
let currentHash = await this.getRoot();
|
|
144
|
+
// Navigate to the subtree at the prefix
|
|
145
|
+
for (let i = 0; i < prefix.length; i++) {
|
|
146
|
+
if (hashEquals(currentHash, this.defaultHashes[i])) {
|
|
147
|
+
return [];
|
|
148
|
+
}
|
|
149
|
+
const node = await this.store.getNode(currentHash);
|
|
150
|
+
if (node === undefined) {
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
if (node.type === 'leaf') {
|
|
154
|
+
// Check if this leaf's key hash matches the prefix
|
|
155
|
+
const leafMatchesPrefix = this.leafMatchesPrefix(node.keyHash, prefix);
|
|
156
|
+
if (leafMatchesPrefix) {
|
|
157
|
+
return [node.valueCid];
|
|
193
158
|
}
|
|
159
|
+
return [];
|
|
194
160
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
161
|
+
const internalNode = node;
|
|
162
|
+
if (prefix[i]) {
|
|
163
|
+
currentHash = internalNode.rightHash;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
currentHash = internalNode.leftHash;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Collect all leaves in this subtree
|
|
170
|
+
return this.collectLeaves(currentHash, prefix.length);
|
|
198
171
|
}
|
|
199
172
|
/**
|
|
200
173
|
* Compute a local diff between this tree and another tree's state,
|
|
@@ -203,80 +176,76 @@ export class SparseMerkleTree {
|
|
|
203
176
|
* This is used for same-process diffing (e.g., in tests or local operations).
|
|
204
177
|
* For remote diffing, the sync protocol exchanges subtree hashes via messages.
|
|
205
178
|
*/
|
|
206
|
-
diff(other) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return { onlyLocal, onlyRemote };
|
|
217
|
-
});
|
|
179
|
+
async diff(other) {
|
|
180
|
+
const localRoot = await this.getRoot();
|
|
181
|
+
const remoteRoot = await other.getRoot();
|
|
182
|
+
if (hashEquals(localRoot, remoteRoot)) {
|
|
183
|
+
return { onlyLocal: [], onlyRemote: [] };
|
|
184
|
+
}
|
|
185
|
+
const onlyLocal = [];
|
|
186
|
+
const onlyRemote = [];
|
|
187
|
+
await this.diffAtNode(localRoot, remoteRoot, 0, this, other, onlyLocal, onlyRemote);
|
|
188
|
+
return { onlyLocal, onlyRemote };
|
|
218
189
|
}
|
|
219
190
|
// ─── Private methods ──────────────────────────────────────────────────────
|
|
220
191
|
/**
|
|
221
192
|
* Recursively insert a leaf into the tree, returning the new hash for the subtree at `depth`.
|
|
222
193
|
*/
|
|
223
|
-
insertAtNode(currentHash, keyHash, leafHash, leafNode, depth) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
194
|
+
async insertAtNode(currentHash, keyHash, leafHash, leafNode, depth) {
|
|
195
|
+
// Base case: reached the maximum depth
|
|
196
|
+
if (depth >= SMT_DEPTH) {
|
|
197
|
+
return leafHash;
|
|
198
|
+
}
|
|
199
|
+
// If the current subtree is empty (default hash at this depth), just return the leaf hash.
|
|
200
|
+
// But we need to handle the case where the leaf might need to be pushed down further
|
|
201
|
+
// because we're at an intermediate depth.
|
|
202
|
+
if (hashEquals(currentHash, this.defaultHashes[depth])) {
|
|
203
|
+
// Place the leaf here — the leaf implicitly represents its position via keyHash
|
|
204
|
+
return leafHash;
|
|
205
|
+
}
|
|
206
|
+
// Load the node at currentHash
|
|
207
|
+
const node = await this.store.getNode(currentHash);
|
|
208
|
+
if (node === undefined) {
|
|
209
|
+
// Shouldn't happen for a well-formed tree, but handle gracefully
|
|
210
|
+
return leafHash;
|
|
211
|
+
}
|
|
212
|
+
if (node.type === 'leaf') {
|
|
213
|
+
// There's an existing leaf at this position
|
|
214
|
+
if (hashEquals(node.keyHash, keyHash)) {
|
|
215
|
+
// Same key — replace the value. Delete old leaf node.
|
|
216
|
+
await this.store.deleteNode(currentHash);
|
|
240
217
|
return leafHash;
|
|
241
218
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
rightHash: newRightHash,
|
|
273
|
-
};
|
|
274
|
-
yield this.store.putNode(newHash, newNode);
|
|
275
|
-
// Clean up old internal node
|
|
276
|
-
yield this.store.deleteNode(currentHash);
|
|
277
|
-
}
|
|
278
|
-
return newHash;
|
|
279
|
-
});
|
|
219
|
+
// Different key — need to push both leaves down until their paths diverge
|
|
220
|
+
return this.splitLeaves(node, currentHash, leafNode, leafHash, depth);
|
|
221
|
+
}
|
|
222
|
+
// Internal node — recurse into the appropriate child
|
|
223
|
+
const internalNode = node;
|
|
224
|
+
const goRight = getBit(keyHash, depth);
|
|
225
|
+
let newLeftHash;
|
|
226
|
+
let newRightHash;
|
|
227
|
+
if (goRight) {
|
|
228
|
+
newLeftHash = internalNode.leftHash;
|
|
229
|
+
newRightHash = await this.insertAtNode(internalNode.rightHash, keyHash, leafHash, leafNode, depth + 1);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
newLeftHash = await this.insertAtNode(internalNode.leftHash, keyHash, leafHash, leafNode, depth + 1);
|
|
233
|
+
newRightHash = internalNode.rightHash;
|
|
234
|
+
}
|
|
235
|
+
// Compute the new internal node hash
|
|
236
|
+
const newHash = await hashChildren(newLeftHash, newRightHash);
|
|
237
|
+
// Store the new internal node (if it differs from the old one)
|
|
238
|
+
if (!hashEquals(newHash, currentHash)) {
|
|
239
|
+
const newNode = {
|
|
240
|
+
type: 'internal',
|
|
241
|
+
leftHash: newLeftHash,
|
|
242
|
+
rightHash: newRightHash,
|
|
243
|
+
};
|
|
244
|
+
await this.store.putNode(newHash, newNode);
|
|
245
|
+
// Clean up old internal node
|
|
246
|
+
await this.store.deleteNode(currentHash);
|
|
247
|
+
}
|
|
248
|
+
return newHash;
|
|
280
249
|
}
|
|
281
250
|
/**
|
|
282
251
|
* When two leaves collide at the same position in the tree, push them down
|
|
@@ -287,211 +256,201 @@ export class SparseMerkleTree {
|
|
|
287
256
|
* 0, 1, and 2 (where one child is the chain and the other is a default hash),
|
|
288
257
|
* plus the divergence node at depth 3 where the two leaves split.
|
|
289
258
|
*/
|
|
290
|
-
splitLeaves(existingLeaf, existingLeafHash, newLeaf, newLeafHash, startDepth) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
259
|
+
async splitLeaves(existingLeaf, existingLeafHash, newLeaf, newLeafHash, startDepth) {
|
|
260
|
+
// Find the depth where the two keys diverge
|
|
261
|
+
let divergeDepth = startDepth;
|
|
262
|
+
while (divergeDepth < SMT_DEPTH && getBit(existingLeaf.keyHash, divergeDepth) === getBit(newLeaf.keyHash, divergeDepth)) {
|
|
263
|
+
divergeDepth++;
|
|
264
|
+
}
|
|
265
|
+
if (divergeDepth >= SMT_DEPTH) {
|
|
266
|
+
// Keys are identical (shouldn't happen with SHA-256 on different inputs)
|
|
267
|
+
return newLeafHash;
|
|
268
|
+
}
|
|
269
|
+
// At the divergence depth, the bits differ — one goes left, the other goes right
|
|
270
|
+
const existingGoesRight = getBit(existingLeaf.keyHash, divergeDepth);
|
|
271
|
+
let leftHash;
|
|
272
|
+
let rightHash;
|
|
273
|
+
if (existingGoesRight) {
|
|
274
|
+
leftHash = newLeafHash;
|
|
275
|
+
rightHash = existingLeafHash;
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
leftHash = existingLeafHash;
|
|
279
|
+
rightHash = newLeafHash;
|
|
280
|
+
}
|
|
281
|
+
// Create the divergence node
|
|
282
|
+
let currentHash = await hashChildren(leftHash, rightHash);
|
|
283
|
+
await this.store.putNode(currentHash, {
|
|
284
|
+
type: 'internal',
|
|
285
|
+
leftHash: leftHash,
|
|
286
|
+
rightHash: rightHash,
|
|
287
|
+
});
|
|
288
|
+
// Build internal nodes back up from (divergeDepth - 1) to startDepth.
|
|
289
|
+
// At each intermediate depth, one child is the chain (currentHash) and
|
|
290
|
+
// the other is the default empty hash for that depth + 1.
|
|
291
|
+
for (let d = divergeDepth - 1; d >= startDepth; d--) {
|
|
292
|
+
const bit = getBit(existingLeaf.keyHash, d); // both keys share this bit
|
|
293
|
+
const defaultChild = this.defaultHashes[d + 1];
|
|
294
|
+
let newLeft;
|
|
295
|
+
let newRight;
|
|
296
|
+
if (bit) {
|
|
297
|
+
newLeft = defaultChild;
|
|
298
|
+
newRight = currentHash;
|
|
308
299
|
}
|
|
309
300
|
else {
|
|
310
|
-
|
|
311
|
-
|
|
301
|
+
newLeft = currentHash;
|
|
302
|
+
newRight = defaultChild;
|
|
312
303
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
yield this.store.putNode(currentHash, {
|
|
304
|
+
currentHash = await hashChildren(newLeft, newRight);
|
|
305
|
+
await this.store.putNode(currentHash, {
|
|
316
306
|
type: 'internal',
|
|
317
|
-
leftHash:
|
|
318
|
-
rightHash:
|
|
307
|
+
leftHash: newLeft,
|
|
308
|
+
rightHash: newRight,
|
|
319
309
|
});
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
// the other is the default empty hash for that depth + 1.
|
|
323
|
-
for (let d = divergeDepth - 1; d >= startDepth; d--) {
|
|
324
|
-
const bit = getBit(existingLeaf.keyHash, d); // both keys share this bit
|
|
325
|
-
const defaultChild = this.defaultHashes[d + 1];
|
|
326
|
-
let newLeft;
|
|
327
|
-
let newRight;
|
|
328
|
-
if (bit) {
|
|
329
|
-
newLeft = defaultChild;
|
|
330
|
-
newRight = currentHash;
|
|
331
|
-
}
|
|
332
|
-
else {
|
|
333
|
-
newLeft = currentHash;
|
|
334
|
-
newRight = defaultChild;
|
|
335
|
-
}
|
|
336
|
-
currentHash = yield hashChildren(newLeft, newRight);
|
|
337
|
-
yield this.store.putNode(currentHash, {
|
|
338
|
-
type: 'internal',
|
|
339
|
-
leftHash: newLeft,
|
|
340
|
-
rightHash: newRight,
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
return currentHash;
|
|
344
|
-
});
|
|
310
|
+
}
|
|
311
|
+
return currentHash;
|
|
345
312
|
}
|
|
346
313
|
/**
|
|
347
314
|
* Recursively delete a key from the tree, returning the new hash for the subtree at `depth`.
|
|
348
315
|
*/
|
|
349
|
-
deleteAtNode(currentHash, keyHash, depth) {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
if (node.
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
yield this.store.deleteNode(currentHash);
|
|
366
|
-
return this.defaultHashes[depth];
|
|
367
|
-
}
|
|
368
|
-
// Wrong leaf — key not in tree
|
|
369
|
-
return currentHash;
|
|
370
|
-
}
|
|
371
|
-
// Internal node — recurse into the appropriate child
|
|
372
|
-
const internalNode = node;
|
|
373
|
-
const goRight = getBit(keyHash, depth);
|
|
374
|
-
let newLeftHash;
|
|
375
|
-
let newRightHash;
|
|
376
|
-
if (goRight) {
|
|
377
|
-
newLeftHash = internalNode.leftHash;
|
|
378
|
-
newRightHash = yield this.deleteAtNode(internalNode.rightHash, keyHash, depth + 1);
|
|
379
|
-
}
|
|
380
|
-
else {
|
|
381
|
-
newLeftHash = yield this.deleteAtNode(internalNode.leftHash, keyHash, depth + 1);
|
|
382
|
-
newRightHash = internalNode.rightHash;
|
|
383
|
-
}
|
|
384
|
-
// If both children are now default (empty), this node becomes empty too
|
|
385
|
-
if (hashEquals(newLeftHash, this.defaultHashes[depth + 1]) && hashEquals(newRightHash, this.defaultHashes[depth + 1])) {
|
|
386
|
-
yield this.store.deleteNode(currentHash);
|
|
316
|
+
async deleteAtNode(currentHash, keyHash, depth) {
|
|
317
|
+
if (depth >= SMT_DEPTH) {
|
|
318
|
+
return this.defaultHashes[SMT_DEPTH];
|
|
319
|
+
}
|
|
320
|
+
// Empty subtree — nothing to delete
|
|
321
|
+
if (hashEquals(currentHash, this.defaultHashes[depth])) {
|
|
322
|
+
return currentHash;
|
|
323
|
+
}
|
|
324
|
+
const node = await this.store.getNode(currentHash);
|
|
325
|
+
if (node === undefined) {
|
|
326
|
+
return this.defaultHashes[depth];
|
|
327
|
+
}
|
|
328
|
+
if (node.type === 'leaf') {
|
|
329
|
+
if (hashEquals(node.keyHash, keyHash)) {
|
|
330
|
+
// Found the leaf to delete
|
|
331
|
+
await this.store.deleteNode(currentHash);
|
|
387
332
|
return this.defaultHashes[depth];
|
|
388
333
|
}
|
|
389
|
-
//
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
334
|
+
// Wrong leaf — key not in tree
|
|
335
|
+
return currentHash;
|
|
336
|
+
}
|
|
337
|
+
// Internal node — recurse into the appropriate child
|
|
338
|
+
const internalNode = node;
|
|
339
|
+
const goRight = getBit(keyHash, depth);
|
|
340
|
+
let newLeftHash;
|
|
341
|
+
let newRightHash;
|
|
342
|
+
if (goRight) {
|
|
343
|
+
newLeftHash = internalNode.leftHash;
|
|
344
|
+
newRightHash = await this.deleteAtNode(internalNode.rightHash, keyHash, depth + 1);
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
newLeftHash = await this.deleteAtNode(internalNode.leftHash, keyHash, depth + 1);
|
|
348
|
+
newRightHash = internalNode.rightHash;
|
|
349
|
+
}
|
|
350
|
+
// If both children are now default (empty), this node becomes empty too
|
|
351
|
+
if (hashEquals(newLeftHash, this.defaultHashes[depth + 1]) && hashEquals(newRightHash, this.defaultHashes[depth + 1])) {
|
|
352
|
+
await this.store.deleteNode(currentHash);
|
|
353
|
+
return this.defaultHashes[depth];
|
|
354
|
+
}
|
|
355
|
+
// If one child is default and the other is a leaf, collapse upward
|
|
356
|
+
// (the internal node is unnecessary — just return the leaf hash directly)
|
|
357
|
+
const leftIsDefault = hashEquals(newLeftHash, this.defaultHashes[depth + 1]);
|
|
358
|
+
const rightIsDefault = hashEquals(newRightHash, this.defaultHashes[depth + 1]);
|
|
359
|
+
if (leftIsDefault || rightIsDefault) {
|
|
360
|
+
const survivingHash = leftIsDefault ? newRightHash : newLeftHash;
|
|
361
|
+
const survivingNode = await this.store.getNode(survivingHash);
|
|
362
|
+
if (survivingNode !== undefined && survivingNode.type === 'leaf') {
|
|
363
|
+
// Collapse: remove the internal node, return the leaf hash directly
|
|
364
|
+
await this.store.deleteNode(currentHash);
|
|
365
|
+
return survivingHash;
|
|
412
366
|
}
|
|
413
|
-
|
|
414
|
-
|
|
367
|
+
}
|
|
368
|
+
// Recompute internal node hash
|
|
369
|
+
const newHash = await hashChildren(newLeftHash, newRightHash);
|
|
370
|
+
if (!hashEquals(newHash, currentHash)) {
|
|
371
|
+
const newNode = {
|
|
372
|
+
type: 'internal',
|
|
373
|
+
leftHash: newLeftHash,
|
|
374
|
+
rightHash: newRightHash,
|
|
375
|
+
};
|
|
376
|
+
await this.store.putNode(newHash, newNode);
|
|
377
|
+
await this.store.deleteNode(currentHash);
|
|
378
|
+
}
|
|
379
|
+
return newHash;
|
|
415
380
|
}
|
|
416
381
|
/**
|
|
417
382
|
* Check if a key exists at the given node.
|
|
418
383
|
*/
|
|
419
|
-
existsAtNode(currentHash, keyHash, depth) {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
}
|
|
442
|
-
});
|
|
384
|
+
async existsAtNode(currentHash, keyHash, depth) {
|
|
385
|
+
if (depth >= SMT_DEPTH) {
|
|
386
|
+
return false;
|
|
387
|
+
}
|
|
388
|
+
if (hashEquals(currentHash, this.defaultHashes[depth])) {
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
const node = await this.store.getNode(currentHash);
|
|
392
|
+
if (node === undefined) {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
if (node.type === 'leaf') {
|
|
396
|
+
return hashEquals(node.keyHash, keyHash);
|
|
397
|
+
}
|
|
398
|
+
const internalNode = node;
|
|
399
|
+
const goRight = getBit(keyHash, depth);
|
|
400
|
+
if (goRight) {
|
|
401
|
+
return this.existsAtNode(internalNode.rightHash, keyHash, depth + 1);
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
return this.existsAtNode(internalNode.leftHash, keyHash, depth + 1);
|
|
405
|
+
}
|
|
443
406
|
}
|
|
444
407
|
/**
|
|
445
408
|
* Generate a proof for the given key at the given node.
|
|
446
409
|
*/
|
|
447
|
-
generateProof(currentHash, keyHash, depth) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
return childProof;
|
|
477
|
-
});
|
|
410
|
+
async generateProof(currentHash, keyHash, depth) {
|
|
411
|
+
if (depth >= SMT_DEPTH) {
|
|
412
|
+
return { siblings: [], leafNode: undefined, depth };
|
|
413
|
+
}
|
|
414
|
+
if (hashEquals(currentHash, this.defaultHashes[depth])) {
|
|
415
|
+
return { siblings: [], leafNode: undefined, depth };
|
|
416
|
+
}
|
|
417
|
+
const node = await this.store.getNode(currentHash);
|
|
418
|
+
if (node === undefined) {
|
|
419
|
+
return { siblings: [], leafNode: undefined, depth };
|
|
420
|
+
}
|
|
421
|
+
if (node.type === 'leaf') {
|
|
422
|
+
return { siblings: [], leafNode: node, depth };
|
|
423
|
+
}
|
|
424
|
+
const internalNode = node;
|
|
425
|
+
const goRight = getBit(keyHash, depth);
|
|
426
|
+
let childHash;
|
|
427
|
+
let siblingHash;
|
|
428
|
+
if (goRight) {
|
|
429
|
+
childHash = internalNode.rightHash;
|
|
430
|
+
siblingHash = internalNode.leftHash;
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
childHash = internalNode.leftHash;
|
|
434
|
+
siblingHash = internalNode.rightHash;
|
|
435
|
+
}
|
|
436
|
+
const childProof = await this.generateProof(childHash, keyHash, depth + 1);
|
|
437
|
+
childProof.siblings.unshift(siblingHash);
|
|
438
|
+
return childProof;
|
|
478
439
|
}
|
|
479
440
|
/**
|
|
480
441
|
* Compute the subtree hash for a leaf that exists above the target prefix depth.
|
|
481
442
|
* The leaf's effective position is determined by its keyHash bits.
|
|
482
443
|
*/
|
|
483
|
-
computeSubtreeHashForLeaf(leaf, currentDepth, prefix) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
return this.defaultHashes[prefix.length];
|
|
490
|
-
}
|
|
444
|
+
async computeSubtreeHashForLeaf(leaf, currentDepth, prefix) {
|
|
445
|
+
// Check if the leaf's key matches the remaining prefix bits
|
|
446
|
+
for (let i = currentDepth; i < prefix.length; i++) {
|
|
447
|
+
if (getBit(leaf.keyHash, i) !== prefix[i]) {
|
|
448
|
+
// Leaf is not under this prefix
|
|
449
|
+
return this.defaultHashes[prefix.length];
|
|
491
450
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
451
|
+
}
|
|
452
|
+
// Leaf is under this prefix — recompute its hash
|
|
453
|
+
return await hashLeaf(leaf.keyHash, leaf.valueCid);
|
|
495
454
|
}
|
|
496
455
|
/**
|
|
497
456
|
* Check if a leaf's keyHash matches a given prefix.
|
|
@@ -507,116 +466,112 @@ export class SparseMerkleTree {
|
|
|
507
466
|
/**
|
|
508
467
|
* Collect all leaf messageCids in the subtree rooted at the given hash.
|
|
509
468
|
*/
|
|
510
|
-
collectLeaves(nodeHash, depth) {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
return [...leftLeaves, ...rightLeaves];
|
|
526
|
-
});
|
|
469
|
+
async collectLeaves(nodeHash, depth) {
|
|
470
|
+
if (depth >= SMT_DEPTH || hashEquals(nodeHash, this.defaultHashes[depth])) {
|
|
471
|
+
return [];
|
|
472
|
+
}
|
|
473
|
+
const node = await this.store.getNode(nodeHash);
|
|
474
|
+
if (node === undefined) {
|
|
475
|
+
return [];
|
|
476
|
+
}
|
|
477
|
+
if (node.type === 'leaf') {
|
|
478
|
+
return [node.valueCid];
|
|
479
|
+
}
|
|
480
|
+
const internalNode = node;
|
|
481
|
+
const leftLeaves = await this.collectLeaves(internalNode.leftHash, depth + 1);
|
|
482
|
+
const rightLeaves = await this.collectLeaves(internalNode.rightHash, depth + 1);
|
|
483
|
+
return [...leftLeaves, ...rightLeaves];
|
|
527
484
|
}
|
|
528
485
|
/**
|
|
529
486
|
* Recursively diff two subtrees, collecting leaves that exist only in one or the other.
|
|
530
487
|
*/
|
|
531
|
-
diffAtNode(localHash, remoteHash, depth, localTree, remoteTree, onlyLocal, onlyRemote) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
if ((localNode
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
onlyRemote.push(cid);
|
|
585
|
-
}
|
|
488
|
+
async diffAtNode(localHash, remoteHash, depth, localTree, remoteTree, onlyLocal, onlyRemote) {
|
|
489
|
+
// If hashes match, subtrees are identical — skip
|
|
490
|
+
if (hashEquals(localHash, remoteHash)) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
// If we've reached max depth, something is wrong — bail out
|
|
494
|
+
if (depth >= SMT_DEPTH) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
const localIsDefault = hashEquals(localHash, this.defaultHashes[depth]);
|
|
498
|
+
const remoteIsDefault = hashEquals(remoteHash, this.defaultHashes[depth]);
|
|
499
|
+
// If local is empty but remote is not, all remote leaves are "onlyRemote"
|
|
500
|
+
if (localIsDefault && !remoteIsDefault) {
|
|
501
|
+
const remoteLeaves = await remoteTree.collectLeaves(remoteHash, depth);
|
|
502
|
+
onlyRemote.push(...remoteLeaves);
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
// If remote is empty but local is not, all local leaves are "onlyLocal"
|
|
506
|
+
if (!localIsDefault && remoteIsDefault) {
|
|
507
|
+
const localLeaves = await localTree.collectLeaves(localHash, depth);
|
|
508
|
+
onlyLocal.push(...localLeaves);
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
// Both are non-default and non-equal — load nodes and recurse
|
|
512
|
+
const localNode = await localTree.store.getNode(localHash);
|
|
513
|
+
const remoteNode = await remoteTree.store.getNode(remoteHash);
|
|
514
|
+
// Handle cases where one or both are leaves
|
|
515
|
+
if (localNode?.type === 'leaf' && remoteNode?.type === 'leaf') {
|
|
516
|
+
if (!hashEquals(localNode.keyHash, remoteNode.keyHash)) {
|
|
517
|
+
// Different keys — both are unique to their respective trees
|
|
518
|
+
onlyLocal.push(localNode.valueCid);
|
|
519
|
+
onlyRemote.push(remoteNode.valueCid);
|
|
520
|
+
}
|
|
521
|
+
else if (localNode.valueCid !== remoteNode.valueCid) {
|
|
522
|
+
// Same key, different value — treat as update
|
|
523
|
+
onlyLocal.push(localNode.valueCid);
|
|
524
|
+
onlyRemote.push(remoteNode.valueCid);
|
|
525
|
+
}
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
// One is a leaf and the other is internal — expand the leaf side
|
|
529
|
+
if (localNode?.type === 'leaf') {
|
|
530
|
+
// Local is a single leaf; remote is a subtree
|
|
531
|
+
// All remote leaves are potentially onlyRemote; check if the local leaf exists in remote
|
|
532
|
+
const remoteLeaves = await remoteTree.collectLeaves(remoteHash, depth);
|
|
533
|
+
const localCid = localNode.valueCid;
|
|
534
|
+
const remoteSet = new Set(remoteLeaves);
|
|
535
|
+
if (!remoteSet.has(localCid)) {
|
|
536
|
+
onlyLocal.push(localCid);
|
|
537
|
+
}
|
|
538
|
+
for (const cid of remoteLeaves) {
|
|
539
|
+
if (cid !== localCid) {
|
|
540
|
+
onlyRemote.push(cid);
|
|
586
541
|
}
|
|
587
|
-
return;
|
|
588
542
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
if (remoteNode?.type === 'leaf') {
|
|
546
|
+
// Remote is a single leaf; local is a subtree
|
|
547
|
+
const localLeaves = await localTree.collectLeaves(localHash, depth);
|
|
548
|
+
const remoteCid = remoteNode.valueCid;
|
|
549
|
+
const localSet = new Set(localLeaves);
|
|
550
|
+
if (!localSet.has(remoteCid)) {
|
|
551
|
+
onlyRemote.push(remoteCid);
|
|
552
|
+
}
|
|
553
|
+
for (const cid of localLeaves) {
|
|
554
|
+
if (cid !== remoteCid) {
|
|
555
|
+
onlyLocal.push(cid);
|
|
601
556
|
}
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
// Both are internal nodes — recurse into children
|
|
605
|
-
if ((localNode === null || localNode === void 0 ? void 0 : localNode.type) === 'internal' && (remoteNode === null || remoteNode === void 0 ? void 0 : remoteNode.type) === 'internal') {
|
|
606
|
-
yield this.diffAtNode(localNode.leftHash, remoteNode.leftHash, depth + 1, localTree, remoteTree, onlyLocal, onlyRemote);
|
|
607
|
-
yield this.diffAtNode(localNode.rightHash, remoteNode.rightHash, depth + 1, localTree, remoteTree, onlyLocal, onlyRemote);
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
// Fallback: if a node is missing, collect all from the other side
|
|
611
|
-
if (localNode === undefined) {
|
|
612
|
-
const remoteLeaves = yield remoteTree.collectLeaves(remoteHash, depth);
|
|
613
|
-
onlyRemote.push(...remoteLeaves);
|
|
614
|
-
}
|
|
615
|
-
if (remoteNode === undefined) {
|
|
616
|
-
const localLeaves = yield localTree.collectLeaves(localHash, depth);
|
|
617
|
-
onlyLocal.push(...localLeaves);
|
|
618
557
|
}
|
|
619
|
-
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
// Both are internal nodes — recurse into children
|
|
561
|
+
if (localNode?.type === 'internal' && remoteNode?.type === 'internal') {
|
|
562
|
+
await this.diffAtNode(localNode.leftHash, remoteNode.leftHash, depth + 1, localTree, remoteTree, onlyLocal, onlyRemote);
|
|
563
|
+
await this.diffAtNode(localNode.rightHash, remoteNode.rightHash, depth + 1, localTree, remoteTree, onlyLocal, onlyRemote);
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
// Fallback: if a node is missing, collect all from the other side
|
|
567
|
+
if (localNode === undefined) {
|
|
568
|
+
const remoteLeaves = await remoteTree.collectLeaves(remoteHash, depth);
|
|
569
|
+
onlyRemote.push(...remoteLeaves);
|
|
570
|
+
}
|
|
571
|
+
if (remoteNode === undefined) {
|
|
572
|
+
const localLeaves = await localTree.collectLeaves(localHash, depth);
|
|
573
|
+
onlyLocal.push(...localLeaves);
|
|
574
|
+
}
|
|
620
575
|
}
|
|
621
576
|
}
|
|
622
577
|
//# sourceMappingURL=sparse-merkle-tree.js.map
|