classic-ui-dev/services/mimc.js

19 lines
368 B
JavaScript
Raw Normal View History

2022-04-21 23:05:56 -04:00
import { buildMimcSponge } from 'circomlibjs'
class Mimc {
constructor() {
this.sponge = null
this.hash = null
this.initMimc()
}
async initMimc() {
this.sponge = await buildMimcSponge()
this.hash = (left, right) => this.sponge.F.toString(this.sponge.multiHash([BigInt(left), BigInt(right)]))
}
}
const mimc = new Mimc()
export { mimc }