Skip to content

Commit

Permalink
Progresson Ultra; vk length error
Browse files Browse the repository at this point in the history
  • Loading branch information
codygunton committed Jan 3, 2025
1 parent 8bed9aa commit 837fdff
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
9 changes: 6 additions & 3 deletions barretenberg/ts/src/barretenberg/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,16 @@ export class UltraHonkBackend {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_numOfPublicInputs: number,
): Promise<{ proofAsFields: string[]; vkAsFields: string[]; vkHash: string }> {
console.log(`instantiating...`);
await this.instantiate();
console.log(`instanted`);
// TODO(https://github.com/noir-lang/noir/issues/5661): This needs to be updated to handle recursive aggregation.
// There is still a proofAsFields method but we could consider getting rid of it as the proof itself
// is a list of field elements.
// UltraHonk also does not have public inputs directly prepended to the proof and they are still instead
// inserted at an offset.
// const proof = reconstructProofWithPublicInputs(proofData);
const proof = await this.api.acirProofAsFieldsUltraHonk(_proof);
console.log(`converted proof`);
// const proofAsFields = (await this.api.acirProofAsFieldsUltraHonk(proof)).slice(numOfPublicInputs);

// TODO: perhaps we should put this in the init function. Need to benchmark
Expand All @@ -281,12 +284,12 @@ export class UltraHonkBackend {

return {
// TODO(https://github.com/noir-lang/noir/issues/5661)
proofAsFields: [],
proofAsFields: proof.map(proof=>proof.toString()),
vkAsFields: vk.map(vk => vk.toString()),
// We use an empty string for the vk hash here as it is unneeded as part of the recursive artifacts
// The user can be expected to hash the vk inside their circuit to check whether the vk is the circuit
// they expect
vkHash: '',
vkHash: '0x404',
};
}

Expand Down
3 changes: 3 additions & 0 deletions barretenberg/ts/src/barretenberg_api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,11 @@ export class BarretenbergApi {
}

async acirProofAsFieldsUltraHonk(proofBuf: Uint8Array): Promise<Fr[]> {
console.log("defining inArgs");
const inArgs = [proofBuf].map(serializeBufferable);
console.log("defining outTypes");
const outTypes: OutputType[] = [VectorDeserializer(Fr)];
console.log("calling wasm export");
const result = await this.wasm.callWasmExport(
'acir_proof_as_fields_ultra_honk',
inArgs,
Expand Down
11 changes: 4 additions & 7 deletions yarn-project/bb-bench/browser/src/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UltraPlonkBackend } from '@aztec/bb.js';
import { UltraHonkBackend } from '@aztec/bb.js';

import { Noir } from '@noir-lang/noir_js';

Expand All @@ -18,7 +18,7 @@ document.getElementById('bbProveSingle').addEventListener('click', async () => {
const prove = async threads => {
console.log(`Running with ${threads} threads`);
try {
var backend = new UltraPlonkBackend(main.bytecode, { threads }, { recursive: true });
var backend = new UltraHonkBackend(main.bytecode, { threads }, { recursive: true });
var noir = new Noir(main);
const baseInput = {
x: 1,
Expand All @@ -43,13 +43,10 @@ const prove = async threads => {
var isValid = await backend.verifyProof(baseProof);
if (isValid) console.log('Verifying base proof... ✅');

const proofArtifacts = await backend.generateRecursiveProofArtifacts(
baseProof,
1, // 1 public input
);
const proofArtifacts = await backend.generateRecursiveProofArtifacts(baseProof.proof, baseProof.publicInputs);

// generate the recursion proof
backend = new UltraPlonkBackend(recursion.bytecode, { threads: threads }, { recursive: false });
backend = new UltraHonkBackend(recursion.bytecode, { threads: threads }, { recursive: false });
noir = new Noir(recursion);
const { publicInputs } = baseProof;
const { vkAsFields, proofAsFields, vkHash } = proofArtifacts;
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/bb-bench/recursion/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ fn main(
proof,
public_inputs,
key_hash,
0 // PROOF_TYPE_PLONK
1 // PROOF_TYPE_HONK
);
}

0 comments on commit 837fdff

Please sign in to comment.