Skip to content

Commit

Permalink
Tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
codygunton committed Jul 11, 2024
1 parent be596f7 commit 92015eb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/sh
set -eux
set -eu

VFLAG=${VERBOSE:+-v}
BFLAG="-b ./target/program.json"
FLAGS="-c $CRS_PATH $VFLAG"

# Test we can perform the proof/verify flow.
# This ensures we test independent pk construction through real/garbage witness data paths.
$BIN client_ivc_prove_output_all $FLAGS $BFLAG
$BIN verify_client_ivc $FLAGS
2 changes: 0 additions & 2 deletions barretenberg/cpp/src/barretenberg/bb/file_io.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once
#include <barretenberg/common/log.hpp>
#include <cstdint>
#include <filesystem>
#include <fstream>
#include <ios>
#include <vector>
Expand Down Expand Up @@ -46,7 +45,6 @@ inline void write_file(const std::string& filename, std::vector<uint8_t> const&
{
std::ofstream file(filename, std::ios::binary);
if (!file) {
info("current path: ", std::filesystem::current_path());
throw std::runtime_error("Failed to open data file for writing: " + filename);
}
file.write((char*)data.data(), (std::streamsize)data.size());
Expand Down
33 changes: 12 additions & 21 deletions barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,27 +371,20 @@ void client_ivc_prove_output_all_msgpack(const std::string& bytecodePath,
std::string translatorVkPath = outputDir + "/translator_vk";
std::string eccVkPath = outputDir + "/ecc_vk";

vinfo("output vkPath: ", vkPath);
vinfo("output accPath: ", accPath);
vinfo("output proofPath: ", proofPath);
vinfo("output translatorVkPath: ", translatorVkPath);
vinfo("output eccVkPath: ", eccVkPath);

auto proof = ivc.prove();
auto eccvm_vk = std::make_shared<ECCVMVK>(ivc.goblin.get_eccvm_proving_key());
auto translator_vk = std::make_shared<TranslatorVK>(ivc.goblin.get_translator_proving_key());

auto last_instance = std::make_shared<ClientIVC::VerifierInstance>(ivc.instance_vk);
bool verified = ivc.verify(proof, { ivc.verifier_accumulator, last_instance });
vinfo("ensure valid proof: ", verified);
if (verified) {
vinfo("write proof and vk data to files..");
write_file(proofPath, to_buffer(proof));
write_file(vkPath, to_buffer(ivc.instance_vk));
write_file(accPath, to_buffer(ivc.verifier_accumulator));
write_file(translatorVkPath, to_buffer(translator_vk));
write_file(eccVkPath, to_buffer(eccvm_vk));
}

vinfo("write proof and vk data to files..");
write_file(proofPath, to_buffer(proof));
write_file(vkPath, to_buffer(ivc.instance_vk));
write_file(accPath, to_buffer(ivc.verifier_accumulator));
write_file(translatorVkPath, to_buffer(translator_vk));
write_file(eccVkPath, to_buffer(eccvm_vk));
}

template <typename T> std::shared_ptr<T> read_to_shared_ptr(const std::filesystem::path& path)
Expand Down Expand Up @@ -420,17 +413,15 @@ bool verify_client_ivc(const std::filesystem::path& proof_path,
init_bn254_crs(1 << 24);
init_grumpkin_crs(1 << 14);

using GrumpkinVk = bb::VerifierCommitmentKey<curve::Grumpkin>;
using BN254Vk = bb::VerifierCommitmentKey<curve::BN254>;
/* WORKTODO const */ auto proof = from_buffer<ClientIVC::Proof>(read_file(proof_path));
// Read the proof and verification data from given files
const auto proof = from_buffer<ClientIVC::Proof>(read_file(proof_path));
const auto accumulator = read_to_shared_ptr<ClientIVC::VerifierInstance>(accumulator_path);
accumulator->verification_key->pcs_verification_key = std::make_shared<BN254Vk>();
accumulator->verification_key->pcs_verification_key = std::make_shared<VerifierCommitmentKey<curve::BN254>>();
const auto final_vk = read_to_shared_ptr<ClientIVC::VerificationKey>(final_vk_path);
const auto eccvm_vk = read_to_shared_ptr<ECCVMFlavor::VerificationKey>(eccvm_vk_path);
eccvm_vk->pcs_verification_key = std::make_shared<GrumpkinVk>(eccvm_vk->circuit_size + 1);
eccvm_vk->pcs_verification_key =
std::make_shared<VerifierCommitmentKey<curve::Grumpkin>>(eccvm_vk->circuit_size + 1);
const auto translator_vk = read_to_shared_ptr<TranslatorFlavor::VerificationKey>(translator_vk_path);
translator_vk->pcs_verification_key = std::make_shared<BN254Vk>();
translator_vk->pcs_verification_key = std::make_shared<VerifierCommitmentKey<curve::BN254>>();

const bool verified = ClientIVC::verify(
proof, accumulator, std::make_shared<ClientIVC::VerifierInstance>(final_vk), eccvm_vk, translator_vk);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ bool ClientIVC::verify(const Proof& proof,
ClientIVC::DeciderVerifier decider_verifier(verifier_accumulator);
bool decision = decider_verifier.verify_proof(proof.decider_proof);
return goblin_verified && decision;
};
}

/**
* @brief Verify a full proof of the IVC
Expand Down
3 changes: 0 additions & 3 deletions barretenberg/cpp/src/barretenberg/srs/io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "../ecc/curves/grumpkin/grumpkin.hpp"
#include <concepts>
#include <cstdint>
#include <filesystem>
#include <fstream>
#include <string>
#include <sys/stat.h>
Expand Down Expand Up @@ -308,8 +307,6 @@ template <typename Curve> class IO {

const bool monomial_srs_condition = num_read < degree;
if (monomial_srs_condition) {
info("path when failing to get crs: ", path);
info("filesystem::current_path when failing to get crs: ", std::filesystem::current_path());
throw_or_abort(
format("Only read ",
num_read,
Expand Down
11 changes: 0 additions & 11 deletions proving-systems.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,4 @@
"console": "internalConsole",
}
},
"launch": {
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "attach",
"name": "Attach to running lldb process",
"pid": "${command:pickMyProcess}" // use ${command:pickProcess} to pick other users' processes
}
]
},
}

0 comments on commit 92015eb

Please sign in to comment.