mirror of
https://github.com/tornadocash/tornado-core.git
synced 2024-12-25 14:29:22 -05:00
make sure pathIndex is always a number (fixes bug with string concat instead of integer addition)
This commit is contained in:
parent
bc8d0b20fc
commit
1a17e7eea3
@ -1,6 +1,5 @@
|
|||||||
const jsStorage = require('./Storage')
|
const jsStorage = require('./Storage')
|
||||||
const hasherImpl = require('./MiMC')
|
const hasherImpl = require('./MiMC')
|
||||||
const { bigInt } = require('snarkjs')
|
|
||||||
|
|
||||||
class MerkleTree {
|
class MerkleTree {
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ class MerkleTree {
|
|||||||
this.zero_values = []
|
this.zero_values = []
|
||||||
this.totalElements = 0
|
this.totalElements = 0
|
||||||
|
|
||||||
let current_zero_value = bigInt('5702960885942360421128284892092891246826997279710054143430547229469817701242')
|
let current_zero_value = '5702960885942360421128284892092891246826997279710054143430547229469817701242'
|
||||||
this.zero_values.push(current_zero_value)
|
this.zero_values.push(current_zero_value)
|
||||||
for (let i = 0; i < n_levels; i++) {
|
for (let i = 0; i < n_levels; i++) {
|
||||||
current_zero_value = this.hasher.hash(i, current_zero_value, current_zero_value)
|
current_zero_value = this.hasher.hash(i, current_zero_value, current_zero_value)
|
||||||
@ -77,6 +76,7 @@ class MerkleTree {
|
|||||||
this.path_index.push(element_index % 2)
|
this.path_index.push(element_index % 2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
index = Number(index)
|
||||||
let traverser = new PathTraverser(this.prefix, this.storage, this.zero_values)
|
let traverser = new PathTraverser(this.prefix, this.storage, this.zero_values)
|
||||||
const root = await this.storage.get_or_element(
|
const root = await this.storage.get_or_element(
|
||||||
MerkleTree.index_to_key(this.prefix, this.n_levels, 0),
|
MerkleTree.index_to_key(this.prefix, this.n_levels, 0),
|
||||||
|
Loading…
Reference in New Issue
Block a user