tornado-nova/lib/mimc.js

18 lines
417 B
JavaScript
Raw Normal View History

2020-04-09 20:38:10 +02:00
const circomlib = require('circomlib')
const mimcsponge = circomlib.mimcsponge
const snarkjs = require('snarkjs')
const bigInt = snarkjs.bigInt
class MimcSpongeHasher {
hash(level, left, right) {
return mimcsponge.multiHash([bigInt(left), bigInt(right)]).toString()
}
hashArray(items) {
return mimcsponge.multiHash(items.map(item => bigInt(item))).toString()
}
}
module.exports = MimcSpongeHasher