@chainsafe/persistent-merkle-tree
Advanced tools
Comparing version 0.4.2 to 0.5.0
@@ -6,2 +6,9 @@ # Change Log | ||
## [0.5.0](https://github.com/ChainSafe/ssz/compare/persistent-merkle-tree-v0.4.2...persistent-merkle-tree-v0.5.0) (2023-01-24) | ||
### Features | ||
* compact multiproof ([#292](https://github.com/ChainSafe/ssz/issues/292)) ([5f1ea99](https://github.com/ChainSafe/ssz/commit/5f1ea9914d0796cf0c9a8c2f9622fc5e459a12f2)) | ||
## [0.4.2](https://github.com/ChainSafe/persistent-merkle-tree/compare/@chainsafe/persistent-merkle-tree@0.4.1...@chainsafe/persistent-merkle-tree@0.4.2) (2022-05-31) | ||
@@ -8,0 +15,0 @@ |
import { Gindex } from "../gindex"; | ||
import { Node } from "../node"; | ||
export { computeDescriptor, descriptorToBitlist } from "./compactMulti"; | ||
export declare enum ProofType { | ||
single = "single", | ||
treeOffset = "treeOffset", | ||
multi = "multi" | ||
multi = "multi", | ||
compactMulti = "compactMulti" | ||
} | ||
@@ -43,3 +45,8 @@ /** | ||
} | ||
export declare type Proof = SingleProof | TreeOffsetProof | MultiProof; | ||
export interface CompactMultiProof { | ||
type: ProofType.compactMulti; | ||
leaves: Uint8Array[]; | ||
descriptor: Uint8Array; | ||
} | ||
export declare type Proof = SingleProof | TreeOffsetProof | MultiProof | CompactMultiProof; | ||
export interface SingleProofInput { | ||
@@ -57,3 +64,7 @@ type: ProofType.single; | ||
} | ||
export declare type ProofInput = SingleProofInput | TreeOffsetProofInput | MultiProofInput; | ||
export interface CompactMultiProofInput { | ||
type: ProofType.compactMulti; | ||
descriptor: Uint8Array; | ||
} | ||
export declare type ProofInput = SingleProofInput | TreeOffsetProofInput | MultiProofInput | CompactMultiProofInput; | ||
export declare function createProof(rootNode: Node, input: ProofInput): Proof; | ||
@@ -60,0 +71,0 @@ export declare function createNodeFromProof(proof: Proof): Node; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.deserializeProof = exports.serializeProof = exports.createNodeFromProof = exports.createProof = exports.ProofTypeSerialized = exports.ProofType = void 0; | ||
exports.deserializeProof = exports.serializeProof = exports.createNodeFromProof = exports.createProof = exports.ProofTypeSerialized = exports.ProofType = exports.descriptorToBitlist = exports.computeDescriptor = void 0; | ||
const multi_1 = require("./multi"); | ||
const compactMulti_1 = require("./compactMulti"); | ||
const single_1 = require("./single"); | ||
const treeOffset_1 = require("./treeOffset"); | ||
var compactMulti_2 = require("./compactMulti"); | ||
Object.defineProperty(exports, "computeDescriptor", { enumerable: true, get: function () { return compactMulti_2.computeDescriptor; } }); | ||
Object.defineProperty(exports, "descriptorToBitlist", { enumerable: true, get: function () { return compactMulti_2.descriptorToBitlist; } }); | ||
var ProofType; | ||
@@ -12,2 +16,3 @@ (function (ProofType) { | ||
ProofType["multi"] = "multi"; | ||
ProofType["compactMulti"] = "compactMulti"; | ||
})(ProofType = exports.ProofType || (exports.ProofType = {})); | ||
@@ -20,3 +25,4 @@ /** | ||
ProofType.treeOffset, | ||
ProofType.multi, // 2 | ||
ProofType.multi, | ||
ProofType.compactMulti, // 3 | ||
]; | ||
@@ -51,2 +57,10 @@ function createProof(rootNode, input) { | ||
} | ||
case ProofType.compactMulti: { | ||
const leaves = compactMulti_1.createCompactMultiProof(rootNode, input.descriptor); | ||
return { | ||
type: ProofType.compactMulti, | ||
leaves, | ||
descriptor: input.descriptor, | ||
}; | ||
} | ||
default: | ||
@@ -65,2 +79,4 @@ throw new Error("Invalid proof type"); | ||
return multi_1.createNodeFromMultiProof(proof.leaves, proof.witnesses, proof.gindices); | ||
case ProofType.compactMulti: | ||
return compactMulti_1.createNodeFromCompactMultiProof(proof.leaves, proof.descriptor); | ||
default: | ||
@@ -67,0 +83,0 @@ throw new Error("Invalid proof type"); |
{ | ||
"name": "@chainsafe/persistent-merkle-tree", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"description": "Merkle tree implemented as a persistent datastructure", | ||
@@ -10,8 +10,9 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"check-types": "tsc --noEmit", | ||
"build": "tsc", | ||
"lint": "eslint --color --ext .ts src/", | ||
"check-types": "run -T tsc --noEmit", | ||
"clean": "rm -rf lib", | ||
"build": "run -T tsc", | ||
"lint": "run -T eslint --color --ext .ts src/", | ||
"benchmark": "node --max-old-space-size=4096 --expose-gc -r ts-node/register ./node_modules/.bin/benchmark 'test/perf/*.perf.ts'", | ||
"benchmark:local": "yarn benchmark --local", | ||
"test": "mocha -r ts-node/register 'test/unit/**/*.test.ts'" | ||
"test": "run -T mocha -r ts-node/register 'test/unit/**/*.test.ts'" | ||
}, | ||
@@ -39,4 +40,3 @@ "pre-push": [ | ||
"@chainsafe/as-sha256": "^0.3.1" | ||
}, | ||
"gitHead": "2199073977689e7949428561a1df970812ac668b" | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
119461
32
2639