tornado-core/lib/MiMC.js

14 lines
315 B
JavaScript
Raw Normal View History

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