Skip to content

Commit 6a24b6f

Browse files
committed
Merge branch 'main' into dark-pool
1 parent a99c9b4 commit 6a24b6f

File tree

3 files changed

+30
-24
lines changed

3 files changed

+30
-24
lines changed

packages/contracts/sdk/NativeUltraHonkBackend.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import type { ProofData } from "@aztec/bb.js";
22
import type { CompiledCircuit } from "@noir-lang/noir_js";
3-
import { chunk } from "lodash-es";
43
import { spawn } from "node:child_process";
54
import fs from "node:fs";
65
import path from "node:path";
7-
import { Hex } from "ox";
8-
import { assert } from "ts-essentials";
6+
import { readNativeHonkProof } from "./utils.js";
97

108
export class NativeUltraHonkBackend {
119
constructor(
@@ -62,22 +60,7 @@ export class NativeUltraHonkBackend {
6260
reject(new Error(`Process exited with code ${code}`));
6361
return;
6462
}
65-
66-
const proof = fs.readFileSync(path.join(proofOutputPath, "proof"));
67-
const publicInputs = fs.readFileSync(
68-
path.join(proofOutputPath, "public_inputs"),
69-
);
70-
assert(
71-
publicInputs.length % 32 === 0,
72-
"publicInputs length must be divisible by 32",
73-
);
74-
resolve({
75-
proof,
76-
// TODO: not sure if this publicInputs decoding is correct
77-
publicInputs: chunk(Array.from(publicInputs), 32).map((x) =>
78-
Hex.fromBytes(Uint8Array.from(x)),
79-
),
80-
});
63+
resolve(readNativeHonkProof(proofOutputPath));
8164
});
8265

8366
bbProcess.on("error", (err) => {

packages/contracts/sdk/mpc/MpcNetworkService.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import fs from "node:fs";
66
import os from "node:os";
77
import path from "node:path";
88
import PQueue, { type QueueAddOptions } from "p-queue";
9-
import { decodeNativeHonkProof, promiseWithResolvers } from "../utils.js";
9+
import { promiseWithResolvers } from "../utils.js";
1010
import { inWorkingDir, makeRunCommand, splitInput } from "./utils.js";
1111

1212
export class MpcProverService {
@@ -161,10 +161,11 @@ async function proveAsParty(params: {
161161
params.partyIndex,
162162
]);
163163

164-
const { proof, publicInputs } = decodeNativeHonkProof(
165-
fs.readFileSync(
166-
path.join(workingDir, `proof.${params.partyIndex}.proof`),
167-
),
164+
const proof = fs.readFileSync(
165+
path.join(workingDir, `proof.${params.partyIndex}.proof`),
166+
);
167+
const publicInputs = JSON.parse(
168+
fs.readFileSync(path.join(workingDir, "public-input.json"), "utf-8"),
168169
);
169170

170171
// pre-verify proof

packages/contracts/sdk/utils.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import type { Fr } from "@aztec/aztec.js";
22
import type { InputMap } from "@noir-lang/noir_js";
33
import { ethers } from "ethers";
4+
import { chunk } from "lodash-es";
5+
import fs from "node:fs";
6+
import path from "node:path";
7+
import { Hex } from "ox";
48
import { assert } from "ts-essentials";
59
import type { NoirAndBackend } from "./sdk.js";
610

@@ -90,3 +94,21 @@ export function promiseWithResolvers<T>(): {
9094
});
9195
return ret;
9296
}
97+
98+
export function readNativeHonkProof(pathToProofDir: string) {
99+
const proof = fs.readFileSync(path.join(pathToProofDir, "proof"));
100+
const publicInputs = fs.readFileSync(
101+
path.join(pathToProofDir, "public_inputs"),
102+
);
103+
assert(
104+
publicInputs.length % 32 === 0,
105+
"publicInputs length must be divisible by 32",
106+
);
107+
return {
108+
proof,
109+
// TODO: not sure if this publicInputs decoding is correct
110+
publicInputs: chunk(Array.from(publicInputs), 32).map((x) =>
111+
Hex.fromBytes(Uint8Array.from(x)),
112+
),
113+
};
114+
}

0 commit comments

Comments
 (0)