classic-ui/services/mimc.js
Danil Kovtonyuk 44f31f8b9f
init
2022-04-22 13:14:19 +10:00

19 lines
368 B
JavaScript

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 }