tornado-core/lib/Poseidon.js

14 lines
314 B
JavaScript
Raw Permalink Normal View History

2019-10-04 15:36:17 +03:00
const poseidon = require('circomlib/src/poseidon')
const snarkjs = require('snarkjs')
const bigInt = snarkjs.bigInt
class PoseidonHasher {
hash(level, left, right) {
2019-10-06 05:56:39 +03:00
const hash = poseidon.createHash(3, 8, 57)
2019-10-04 15:36:17 +03:00
return hash([bigInt(left), bigInt(right)]).toString()
}
}
module.exports = PoseidonHasher