Skip to content

Commit

Permalink
Missing recursives in calls
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh committed Oct 29, 2024
1 parent ca19dcb commit b57695c
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 12 deletions.
4 changes: 2 additions & 2 deletions barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ bool verify_client_ivc(const std::filesystem::path& proof_path,
return verified;
}

bool foldAndVerifyProgram(const std::string& bytecodePath, const std::string& witnessPath)
bool foldAndVerifyProgram(const std::string& bytecodePath, const bool recursive, const std::string& witnessPath)
{
using Flavor = MegaFlavor; // This is the only option
using Builder = Flavor::CircuitBuilder;
Expand All @@ -467,7 +467,7 @@ bool foldAndVerifyProgram(const std::string& bytecodePath, const std::string& wi

// Construct a bberg circuit from the acir representation
auto builder = acir_format::create_circuit<Builder>(stack_item.constraints,
/*recursive=*/false,
recursive,
0,
stack_item.witness,
/*honk_recursion=*/false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ WASM_EXPORT void acir_create_proof(
}

WASM_EXPORT void acir_prove_and_verify_ultra_honk(uint8_t const* acir_vec,
boolean const* recursive,
bool const* recursive,
uint8_t const* witness_vec,
bool* result)
{
Expand Down
4 changes: 2 additions & 2 deletions barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ WASM_EXPORT void acir_create_proof(in_ptr acir_composer_ptr,
*
*/
WASM_EXPORT void acir_prove_and_verify_ultra_honk(uint8_t const* constraint_system_buf,
uint8_t const* witness_buf,
bool const* recursive,
uint8_t const* witness_buf,
bool* result);

/**
* @brief Construct and verify a MegaHonk proof
*
*/
WASM_EXPORT void acir_prove_and_verify_mega_honk(uint8_t const* constraint_system_buf,
uint8_t const* witness_buf,
bool const* recursive,
uint8_t const* witness_buf,
bool* result);

/**
Expand Down
6 changes: 4 additions & 2 deletions yarn-project/bb-prover/src/prover/bb_private_kernel_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ export class BBNativePrivateKernelProver implements PrivateKernelProver {
return proof;
}

async createClientIvcProof(acirs: Buffer[], witnessStack: WitnessMap[]): Promise<ClientIvcProof> {
async createClientIvcProof(acirs: Buffer[], recursive: boolean, witnessStack: WitnessMap[]): Promise<ClientIvcProof> {
this.log.info(`Generating Client IVC proof`);
const operation = async (directory: string) => {
return await this._createClientIvcProof(directory, acirs, witnessStack);
return await this._createClientIvcProof(directory, acirs, recursive, witnessStack);
};
return await this.runInDirectory(operation);
}
Expand Down Expand Up @@ -296,6 +296,7 @@ export class BBNativePrivateKernelProver implements PrivateKernelProver {
private async computeVerificationKey(
directory: string,
bytecode: Buffer,
recursive: boolean,
circuitType: ClientProtocolArtifact | 'App',
appCircuitName?: string,
): Promise<{
Expand All @@ -311,6 +312,7 @@ export class BBNativePrivateKernelProver implements PrivateKernelProver {
directory,
circuitType,
bytecode,
recursive,
circuitType === 'App' ? 'mega_honk' : getUltraHonkFlavorForCircuit(circuitType),
this.log.debug,
);
Expand Down
9 changes: 5 additions & 4 deletions yarn-project/bb-prover/src/prover/bb_prover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ import { extractAvmVkData, extractVkData } from '../verification_key/verificatio

const logger = createDebugLogger('aztec:bb-prover');

// All `ServerCircuitArtifact` are recursive.
const SERVER_CIRCUIT_RECURSIVE = true;

export interface BBProverConfig extends BBConfig, ACVMConfig {
// list of circuits supported by this prover. defaults to all circuits if empty
circuitFilter?: ServerProtocolArtifact[];
Expand Down Expand Up @@ -504,15 +507,12 @@ export class BBNativeRollupProver implements ServerCircuitProver {
// Now prove the circuit from the generated witness
logger.debug(`Proving ${circuitType}...`);

// All `ServerProtocolArtifact` types are recursive.
const recursive = true;

const provingResult = await generateProof(
this.config.bbBinaryPath,
workingDirectory,
circuitType,
Buffer.from(artifact.bytecode, 'base64'),
recursive,
SERVER_CIRCUIT_RECURSIVE,
outputWitnessFile,
getUltraHonkFlavorForCircuit(circuitType),
logger.debug,
Expand Down Expand Up @@ -865,6 +865,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
this.config.bbWorkingDirectory,
circuitType,
ServerCircuitArtifacts[circuitType],
SERVER_CIRCUIT_RECURSIVE,
flavor,
logger.debug,
).then(result => {
Expand Down
26 changes: 26 additions & 0 deletions yarn-project/bb-prover/src/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,29 @@ export function mapProtocolArtifactNameToCircuitName(
}
}
}

export function isProtocolArtifactRecursive(
artifact: ServerProtocolArtifact | ClientProtocolArtifact,
): boolean {
switch (artifact) {
case 'EmptyNestedArtifact':
case 'PrivateKernelEmptyArtifact':
case 'BaseParityArtifact':
case 'RootParityArtifact':
case 'PrivateBaseRollupArtifact':
case 'PublicBaseRollupArtifact':
case 'MergeRollupArtifact':
case 'BlockRootRollupArtifact':
case 'EmptyBlockRootRollupArtifact':
case 'BlockMergeRollupArtifact':
case 'RootRollupArtifact':
return true;
default: {
if (artifact.startsWith('PrivateKernel')) {
return false;
}
throw new Error(`Unknown circuit type: ${artifact}`);
}
}
}

4 changes: 3 additions & 1 deletion yarn-project/bb-prover/src/verifier/bb_verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from '../bb/execute.js';
import { type BBConfig } from '../config.js';
import { type UltraKeccakHonkProtocolArtifact, getUltraHonkFlavorForCircuit } from '../honk.js';
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
import { mapProtocolArtifactNameToCircuitName, isProtocolArtifactRecursive } from '../stats.js';
import { extractVkData } from '../verification_key/verification_key_data.js';

export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
Expand Down Expand Up @@ -63,6 +63,7 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
workingDirectory,
circuit,
ProtocolCircuitArtifacts[circuit],
isProtocolArtifactRecursive(circuit),
getUltraHonkFlavorForCircuit(circuit),
logFn,
).then(result => {
Expand Down Expand Up @@ -133,6 +134,7 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
this.config.bbWorkingDirectory,
circuit,
ProtocolCircuitArtifacts[circuit],
isProtocolArtifactRecursive(circuit),
contractName,
this.logger.debug,
);
Expand Down

0 comments on commit b57695c

Please sign in to comment.