Skip to content

Commit

Permalink
addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasxia01 committed Sep 12, 2024
1 parent 9826685 commit 031a656
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
29 changes: 8 additions & 21 deletions barretenberg/ts/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,23 @@ async function initUltraPlonk(bytecodePath: string, crsPath: string, subgroupSiz
return { api, acirComposer, circuitSize, subgroupSize };
}

async function initUltraHonk(bytecodePath: string, crsPath: string, subgroupSizeOverride = -1) {
async function initUltraHonk(bytecodePath: string, crsPath: string) {
const api = await Barretenberg.new({ threads });

const circuitSize = await getGatesUltra(bytecodePath, /*honkRecursion=*/ true, api);
// TODO(https://github.com/AztecProtocol/barretenberg/issues/811): remove subgroupSizeOverride hack for goblin
const subgroupSize = Math.max(subgroupSizeOverride, Math.pow(2, Math.ceil(Math.log2(circuitSize))));
const dyadicCircuitSize = Math.pow(2, Math.ceil(Math.log2(circuitSize)));

debug(`circuit size: ${circuitSize}`);
debug(`subgroup size: ${subgroupSize}`);
debug(`dyadic circuit size size: ${dyadicCircuitSize}`);
debug('loading crs...');
// Plus 1 needed! (Move +1 into Crs?)
const crs = await Crs.new(subgroupSize + 1, crsPath);
const crs = await Crs.new(dyadicCircuitSize + 1, crsPath);

// Load CRS into wasm global CRS state.
// TODO: Make RawBuffer be default behavior, and have a specific Vector type for when wanting length prefixed.
await api.srsInitSrs(new RawBuffer(crs.getG1Data()), crs.numPoints, new RawBuffer(crs.getG2Data()));
return { api, circuitSize, subgroupSize };
return { api, circuitSize, dyadicCircuitSize };
}

async function initClientIVC(bytecodePath: string, crsPath: string) {
Expand All @@ -103,9 +103,6 @@ async function initClientIVC(bytecodePath: string, crsPath: string) {
const crs = await Crs.new(2 ** 18 + 1, crsPath);
const grumpkinCrs = await GrumpkinCrs.new(8192 + 1, crsPath);

// Important to init slab allocator as first thing, to ensure maximum memory efficiency.
// await api.commonInitSlabAllocator(subgroupSize);

// Load CRS into wasm global CRS state.
// TODO: Make RawBuffer be default behavior, and have a specific Vector type for when wanting length prefixed.
await api.srsInitSrs(new RawBuffer(crs.getG1Data()), crs.numPoints, new RawBuffer(crs.getG2Data()));
Expand Down Expand Up @@ -158,7 +155,7 @@ export async function proveAndVerify(bytecodePath: string, witnessPath: string,

export async function proveAndVerifyUltraHonk(bytecodePath: string, witnessPath: string, crsPath: string) {
/* eslint-disable camelcase */
const { api } = await initUltraHonk(bytecodePath, crsPath, -1);
const { api } = await initUltraHonk(bytecodePath, crsPath);
try {
const bytecode = getBytecode(bytecodePath);
const witness = getWitness(witnessPath);
Expand Down Expand Up @@ -363,7 +360,7 @@ export async function vkAsFields(vkPath: string, vkeyOutputPath: string) {
}

export async function proveUltraHonk(bytecodePath: string, witnessPath: string, crsPath: string, outputPath: string) {
const { api } = await initUltraHonk(bytecodePath, crsPath, -1);
const { api } = await initUltraHonk(bytecodePath, crsPath);
try {
debug(`creating proof...`);
const bytecode = getBytecode(bytecodePath);
Expand All @@ -384,7 +381,7 @@ export async function proveUltraHonk(bytecodePath: string, witnessPath: string,
}

export async function writeVkUltraHonk(bytecodePath: string, crsPath: string, outputPath: string) {
const { api } = await initUltraHonk(bytecodePath, crsPath, -1);
const { api } = await initUltraHonk(bytecodePath, crsPath);
try {
const bytecode = getBytecode(bytecodePath);
debug('initing verification key...');
Expand Down Expand Up @@ -532,16 +529,6 @@ program
await gateCountUltra(bytecodePath, honkRecursion);
});

// program
// .command('mega_gates')
// .description('Print Mega Builder gate count to standard output.')
// .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
// .option('-hr, --honk-recursion', 'Specify whether to use UltraHonk recursion', false)
// .action(async ({ bytecodePath: bytecodePath, honkRecursion: honkRecursion }) => {
// handleGlobalOptions();
// await gateCountMega(bytecodePath, honkRecursion);
// });

program
.command('verify')
.description('Verify a proof. Process exists with success or failure code.')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// This circuit aggregates two proofs from `assert_statement_recursive`.
// This circuit aggregates one proof from `assert_statement_recursive`.
fn main(
verification_key: [Field; 114],
// This is the proof without public inputs attached.
Expand Down

0 comments on commit 031a656

Please sign in to comment.