Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@chainsafe/persistent-merkle-tree
Advanced tools
Merkle tree implemented as a persistent datastructure
A binary merkle tree implemented as a persistent data structure.
When dealing with large datasets, it is very expensive to merkleize them in their entirety. In cases where large datasets are remerkleized often between updates and additions, using ephemeral structures for intermediate hashes results in significant duplicated work, as many intermediate hashes will be recomputed and thrown away on each merkleization. In these cases, maintaining structures for the entire tree, intermediate nodes included, can mitigate these issues and allow for additional usecases (eg: proof generation). This implementation also uses the known immutability of nodes to share data between common subtrees across different versions of the data.
The tree is represented as a linked tree of Node
s, currently either BranchNode
s or LeafNode
s.
A BranchNode
has a left
and right
child Node
, and a root
, 32 byte Uint8Array
.
A LeafNode
has a root
.
The root
of a Node
is not computed until requested, and cached thereafter.
Any update to a tree (either to a leaf or intermediate node) is performed as a rebinding that yields a new, updated tree that maximally shares data between versions. Garbage collection allows memory from unused nodes to be eventually reclaimed.
A Tree
object wraps Node
and provides an API for tree navigation and transparent rebinding on updates.
Apache-2.0
FAQs
Merkle tree implemented as a persistent datastructure
The npm package @chainsafe/persistent-merkle-tree receives a total of 82,737 weekly downloads. As such, @chainsafe/persistent-merkle-tree popularity was classified as popular.
We found that @chainsafe/persistent-merkle-tree demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.