tornado-core/lib/MiMC.js

14 lines
315 B
JavaScript
Raw Normal View History

2019-07-16 13:27:20 -04:00
const circomlib = require('circomlib')
const mimcsponge = circomlib.mimcsponge
const snarkjs = require('snarkjs')
2019-07-11 06:38:22 -04:00
2019-07-16 13:27:20 -04:00
const bigInt = snarkjs.bigInt
2019-07-11 06:38:22 -04:00
class MimcSpongeHasher {
2019-07-16 13:27:20 -04:00
hash(level, left, right) {
return mimcsponge.multiHash([bigInt(left), bigInt(right)]).toString()
}
2019-07-11 06:38:22 -04:00
}
2019-07-16 13:27:20 -04:00
module.exports = MimcSpongeHasher