|
|
|
@ -1,5 +1,3 @@ |
|
|
|
|
import { ethers, BigNumber } from 'ethers' |
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
|
|
|
const snarkjs = require('snarkjs'); |
|
|
|
|
|
|
|
|
@ -8,17 +6,6 @@ const logger = { |
|
|
|
|
debug: (...args) => console.log(...args) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Creates a keccak256 hash of a message compatible with the SNARK scalar modulus. |
|
|
|
|
* @param message The message to be hashed. |
|
|
|
|
* @returns The message digest. |
|
|
|
|
*/ |
|
|
|
|
function hash(message: any): bigint { |
|
|
|
|
message = BigNumber.from(message).toTwos(256).toHexString() |
|
|
|
|
message = ethers.utils.zeroPad(message, 32) |
|
|
|
|
return BigInt(ethers.utils.keccak256(message)) >> BigInt(8) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
(async () => { |
|
|
|
|
try { |
|
|
|
|
// @ts-ignore
|
|
|
|
|