1 Commits

5 changed files with 6277 additions and 146 deletions

1
.npmrc Normal file
View File

@@ -0,0 +1 @@
@tornado:registry=https://git.tornado.ws/api/packages/tornado-packages/npm/

6399
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,12 @@
{
"name": "fixed-merkle-tree",
"version": "0.5.0",
"name": "@tornado/fixed-merkle-tree",
"version": "0.4.0",
"description": "Fixed depth merkle tree implementation with sequential inserts",
"main": "src/merkleTree.js",
"repository": {
"type": "git",
"url": "https://git.tornado.ws/tornado-packages/fixed-merkle-tree.git"
},
"scripts": {
"test": "mocha",
"lint": "eslint ."
@@ -18,8 +22,8 @@
"src/*"
],
"dependencies": {
"snarkjs": "git+https://github.com/tornadocash/snarkjs.git#869181cfaf7526fe8972073d31655493a04326d5",
"circomlib": "git+https://github.com/tornadocash/circomlib.git#5beb6aee94923052faeecea40135d45b6ce6172c"
"@tornado/circomlib": "^0.0.21",
"@tornado/snarkjs": "^0.1.20"
},
"devDependencies": {
"babel-eslint": "^10.1.0",

View File

@@ -161,6 +161,8 @@ class MerkleTree {
serialize() {
return {
levels: this.levels,
capacity: this.capacity,
zeroElement: this.zeroElement,
_zeros: this._zeros,
_layers: this._layers,
}
@@ -178,8 +180,6 @@ class MerkleTree {
static deserialize(data, hashFunction) {
const instance = Object.assign(Object.create(this.prototype), data)
instance._hash = hashFunction || defaultHash
instance.capacity = 1 << instance.levels
instance.zeroElement = instance._zeros[0]
return instance
}
}

View File

@@ -1,3 +1,4 @@
const { mimcsponge } = require('circomlib')
const { bigInt } = require('snarkjs')
module.exports = (left, right) => mimcsponge.multiHash([bigInt(left), bigInt(right)]).toString()
const { mimcsponge } = require("@tornado/circomlib");
const { bigInt } = require("@tornado/snarkjs");
module.exports = (left, right) =>
mimcsponge.multiHash([bigInt(left), bigInt(right)]).toString();