classic-ui/services/mimc.js

19 lines
368 B
JavaScript
Raw Permalink Normal View History

2022-04-22 06:05:56 +03: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 }