11import type { ProofData } from "@aztec/bb.js" ;
22import type { CompiledCircuit } from "@noir-lang/noir_js" ;
3+ import { chunk } from "lodash-es" ;
34import { spawn } from "node:child_process" ;
45import fs from "node:fs" ;
56import path from "node:path" ;
6- import { decodeNativeHonkProof } from "./utils.js" ;
7+ import { Hex } from "ox" ;
8+ import { assert } from "ts-essentials" ;
79
810export class NativeUltraHonkBackend {
911 constructor (
@@ -32,13 +34,17 @@ export class NativeUltraHonkBackend {
3234 fs . writeFileSync ( circuitJsonPath , JSON . stringify ( this . circuit ) ) ;
3335 fs . writeFileSync ( witnessOutputPath , witness ) ;
3436 const args = [
35- "prove_ultra_keccak_honk" ,
37+ "prove" ,
38+ "--scheme" ,
39+ "ultra_honk" ,
3640 "-b" ,
3741 circuitJsonPath ,
3842 "-w" ,
3943 witnessOutputPath ,
4044 "-o" ,
4145 proofOutputPath ,
46+ "--oracle_hash" ,
47+ "keccak" ,
4248 ] ;
4349
4450 const bbProcess = spawn ( this . bbPath , args ) ;
@@ -57,10 +63,21 @@ export class NativeUltraHonkBackend {
5763 return ;
5864 }
5965
60- const proofData = decodeNativeHonkProof (
61- fs . readFileSync ( proofOutputPath ) ,
66+ const proof = fs . readFileSync ( path . join ( proofOutputPath , "proof" ) ) ;
67+ const publicInputs = fs . readFileSync (
68+ path . join ( proofOutputPath , "public_inputs" ) ,
6269 ) ;
63- resolve ( proofData ) ;
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+ } ) ;
6481 } ) ;
6582
6683 bbProcess . on ( "error" , ( err ) => {
0 commit comments