Skip to content

Commit bf8a408

Browse files
committed
feat(voter): update prooffile type
1 parent db5928e commit bf8a408

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

packages/voter/scripts/test_gen_deactivate.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import dotenv from 'dotenv';
44
dotenv.config();
55

66
import * as path from 'path';
7+
import * as fs from 'fs';
78

89
async function main() {
910
const secretKey = process.env.ADMIN_PRIVATE_KEY;
@@ -33,19 +34,29 @@ async function main() {
3334
});
3435

3536
const circuitPower = '2-1-1-5';
37+
38+
const wasmPath = path.join(
39+
process.cwd(),
40+
`add-new-key_v3/${circuitPower}/addKey.wasm`
41+
);
42+
const zkeyPath = path.join(
43+
process.cwd(),
44+
`add-new-key_v3/${circuitPower}/addKey.zkey`
45+
);
46+
47+
const wasmUint8Array = new Uint8Array(fs.readFileSync(wasmPath));
48+
const zkeyUint8Array = new Uint8Array(fs.readFileSync(zkeyPath));
49+
50+
console.log('WASM Length:', wasmUint8Array.length);
51+
console.log('ZKEY Length:', zkeyUint8Array.length);
52+
3653
const genProof = await voterClient.buildPreAddNewKeyPayload({
3754
stateTreeDepth: 2,
3855
operatorPubkey:
3956
15985671812509037697999452079047723323214510694838922960102081803756551067669n,
4057
deactivates,
41-
wasmFile: path.join(
42-
process.cwd(),
43-
`add-new-key_v3/${circuitPower}/addKey.wasm`
44-
),
45-
zkeyFile: path.join(
46-
process.cwd(),
47-
`add-new-key_v3/${circuitPower}/addKey.zkey`
48-
),
58+
wasmFile: wasmUint8Array,
59+
zkeyFile: zkeyUint8Array,
4960
});
5061

5162
console.log(genProof);

packages/voter/src/voter.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import CryptoJS from 'crypto-js';
22
import { solidityPackedSha256 } from 'ethers';
3-
import { groth16 } from 'snarkjs';
3+
import { groth16, ZKArtifact } from 'snarkjs';
44

55
import { MaciAccount } from './account';
66
import {
@@ -210,8 +210,8 @@ export class VoterClient {
210210
stateTreeDepth: number;
211211
operatorPubkey: bigint;
212212
deactivates: DeactivateMessage[];
213-
wasmFile: string;
214-
zkeyFile: string;
213+
wasmFile: ZKArtifact;
214+
zkeyFile: ZKArtifact;
215215
derivePathParams?: DerivePathParams;
216216
}): Promise<{
217217
proof: {
@@ -269,8 +269,8 @@ export class VoterClient {
269269
stateTreeDepth: number;
270270
operatorPubkey: bigint;
271271
deactivates: bigint[][];
272-
wasmFile: string;
273-
zkeyFile: string;
272+
wasmFile: ZKArtifact;
273+
zkeyFile: ZKArtifact;
274274
derivePathParams?: DerivePathParams;
275275
}): Promise<{
276276
proof: {

0 commit comments

Comments
 (0)