Skip to content

Commit

Permalink
chore: acir tests are no longer base64 encoded (#1854)
Browse files Browse the repository at this point in the history
Please provide a paragraph or two giving a summary of the change,
including relevant motivation and context.

# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).
  • Loading branch information
kevaundray authored and AztecBot committed Sep 5, 2023
1 parent bc93a5f commit 0b24711
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 29 deletions.
4 changes: 1 addition & 3 deletions acir_tests/flows/all_cmds.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/bin/sh
set -eu

NAME=$(basename $PWD)

if [ -n "${VERBOSE:-}" ]; then
VFLAG="-v"
else
VFLAG=""
fi

BFLAG="-b ./target/${NAME}.bytecode"
BFLAG="-b ./target/acir.gz"
FLAGS="-c $CRS_PATH $VFLAG"

# Test we can perform the proof/verify flow.
Expand Down
6 changes: 2 additions & 4 deletions acir_tests/flows/prove_and_verify.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#!/bin/sh
set -eu

NAME=$(basename $PWD)

if [ -n "$VERBOSE" ]; then
$BIN prove_and_verify -v -c $CRS_PATH -b ./target/$NAME.bytecode
$BIN prove_and_verify -v -c $CRS_PATH -b ./target/acir.gz
else
$BIN prove_and_verify -c $CRS_PATH -b ./target/$NAME.bytecode > /dev/null 2>&1
$BIN prove_and_verify -c $CRS_PATH -b ./target/acir.gz > /dev/null 2>&1
fi
12 changes: 6 additions & 6 deletions acir_tests/headless-test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ function formatAndPrintLog(message: string): void {
}

const readBytecodeFile = (path: string): Uint8Array => {
const data = fs.readFileSync(path, "ascii");
const buffer = gunzipSync(Buffer.from(data, "base64"));
const data = fs.readFileSync(path);
const buffer = gunzipSync(data);
return buffer;
};

Expand All @@ -60,13 +60,13 @@ program
)
.option(
"-b, --bytecode-path <path>",
"Specify the bytecode path",
"./target/main.bytecode"
"Specify the path to the gzip encoded ACIR bytecode",
"./target/acir.gz"
)
.option(
"-w, --witness-path <path>",
"Specify the witness path",
"./target/witness.tr"
"Specify the path to the gzip encoded ACIR witness",
"./target/witness.gz"
)
.action(async ({ bytecodePath, witnessPath, recursive }) => {
const acir = readBytecodeFile(bytecodePath);
Expand Down
6 changes: 3 additions & 3 deletions acir_tests/run_acir_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ if [ ! -d acir_tests ]; then
git clone -b $BRANCH --filter=blob:none --no-checkout https://github.com/noir-lang/noir.git
cd noir
git sparse-checkout init --cone
git sparse-checkout set crates/nargo_cli/tests/execution_success
git sparse-checkout set crates/nargo_cli/tests/acir_artifacts
git checkout
cd ..
mv noir/crates/nargo_cli/tests/execution_success acir_tests
mv noir/crates/nargo_cli/tests/acir_artifacts acir_tests
rm -rf noir
fi
fi
Expand Down Expand Up @@ -73,7 +73,7 @@ else
continue
fi

if [[ ! -f ./$TEST_NAME/target/$TEST_NAME.bytecode || ! -f ./$TEST_NAME/target/witness.tr ]]; then
if [[ ! -f ./$TEST_NAME/target/acir.gz || ! -f ./$TEST_NAME/target/witness.gz ]]; then
echo -e "\033[33mSKIPPED\033[0m (uncompiled)"
continue
fi
Expand Down
Binary file added cpp/bin-test/target/acir.gz
Binary file not shown.
Binary file added cpp/bin-test/target/witness.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion cpp/src/barretenberg/bb/get_bytecode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
*/
inline std::vector<uint8_t> get_bytecode(const std::string& bytecodePath)
{
std::string command = "cat " + bytecodePath + " | base64 -d | gunzip";
std::string command = "gunzip -c \"" + bytecodePath + "\"";
return exec_pipe(command);
}
4 changes: 2 additions & 2 deletions cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ int main(int argc, char* argv[])

std::string command = args[0];

std::string bytecode_path = getOption(args, "-b", "./target/main.bytecode");
std::string witness_path = getOption(args, "-w", "./target/witness.tr");
std::string bytecode_path = getOption(args, "-b", "./target/acir.gz");
std::string witness_path = getOption(args, "-w", "./target/witness.gz");
std::string proof_path = getOption(args, "-p", "./proofs/proof");
std::string vk_path = getOption(args, "-k", "./target/vk");
CRS_PATH = getOption(args, "-c", "./crs");
Expand Down
Binary file added ts/bin-test/target/acir.gz
Binary file not shown.
Binary file added ts/bin-test/target/witness.gz
Binary file not shown.
19 changes: 9 additions & 10 deletions ts/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ const debug = createDebug('bb.js');
const MAX_CIRCUIT_SIZE = 2 ** 19;

function getBytecode(bytecodePath: string) {
const encodedCircuit = readFileSync(bytecodePath, 'utf-8');
const buffer = Buffer.from(encodedCircuit, 'base64');
const decompressed = gunzipSync(buffer);
const encodedCircuit = readFileSync(bytecodePath);
const decompressed = gunzipSync(encodedCircuit);
return decompressed;
}

Expand Down Expand Up @@ -250,8 +249,8 @@ function handleGlobalOptions() {
program
.command('prove_and_verify')
.description('Generate a proof and verify it. Process exits with success or failure code.')
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/main.bytecode')
.option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.tr')
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/acir.gz')
.option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
.option('-r, --recursive', 'prove and verify using recursive prover and verifier', false)
.action(async ({ bytecodePath, witnessPath, recursive, crsPath }) => {
handleGlobalOptions();
Expand All @@ -262,8 +261,8 @@ program
program
.command('prove')
.description('Generate a proof and write it to a file.')
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/main.bytecode')
.option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.tr')
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/acir.gz')
.option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
.option('-r, --recursive', 'prove using recursive prover', false)
.option('-o, --output-path <path>', 'Specify the proof output path', './proofs/proof')
.action(async ({ bytecodePath, witnessPath, recursive, outputPath, crsPath }) => {
Expand All @@ -274,7 +273,7 @@ program
program
.command('gates')
.description('Print gate count to standard output.')
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/main.bytecode')
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/acir.gz')
.action(async ({ bytecodePath: bytecodePath }) => {
handleGlobalOptions();
await gateCount(bytecodePath);
Expand All @@ -295,7 +294,7 @@ program
program
.command('contract')
.description('Output solidity verification key contract.')
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/main.bytecode')
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/acir.gz')
.option('-o, --output-path <path>', 'Specify the path to write the contract', './target/contract.sol')
.requiredOption('-k, --vk-path <path>', 'Path to a verification key. avoids recomputation.')
.action(async ({ outputPath, vkPath }) => {
Expand All @@ -306,7 +305,7 @@ program
program
.command('write_vk')
.description('Output verification key.')
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/main.bytecode')
.option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/acir.gz')
.requiredOption('-o, --output-path <path>', 'Specify the path to write the key')
.action(async ({ bytecodePath, outputPath, crsPath }) => {
handleGlobalOptions();
Expand Down

0 comments on commit 0b24711

Please sign in to comment.