Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
Maddiaa0 committed Nov 3, 2023
1 parent 9552303 commit eb7096b
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 20 deletions.
30 changes: 30 additions & 0 deletions barretenberg/acir_tests/prove.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
building circuit...building circuit...

gates: 3872
gates: 3872
using cached crs at: "/mnt/user-data/sean/.bb-crs"
using cached crs at: "/mnt/user-data/sean/.bb-crs"
computing proving key...
computing proving key...
building circuit with witness...
building circuit with witness...
gates: 3872
creating proof...
gates: 3872
creating proof...
done.
computing verification key...done.
computing verification key...

done.
computing verification key...
done.
computing verification key...
done.
done.
0x557d2dddcd80
running non recursive verif
0x557d2dddcd80
running non recursive verif
verified: 1
verified: 1
38 changes: 24 additions & 14 deletions barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ bool proveAndVerify(const std::string& bytecodePath, const std::string& witnessP

Timer proof_timer;
auto proof = acir_composer.create_proof(constraint_system, witness, recursive);
write_file("./proof_proveAndVerify", proof);
write_benchmark("proof_construction_time", proof_timer.milliseconds(), "acir_test", current_dir);

Timer vk_timer;
Expand All @@ -103,26 +104,35 @@ bool proveAndVerify(const std::string& bytecodePath, const std::string& witnessP
// todo:
// build vk
// try verify proof
auto read_proof = read_file("./proof");
ASSERT(proof == read_proof);
auto read_proof = read_file("./proof_prove");
// ASSERT(proof == read_proof);

// auto vk = acir_composer.init_verification_key();
info("shas");
info(sha256::sha256(proof));
info(sha256::sha256(read_proof));
info(sha256::sha256(proof) == sha256::sha256(read_proof));

auto vk = acir_composer.init_verification_key();
info(vk->as_data().hash_native());
auto composer_2 = init(constraint_system);

auto vk_data = from_buffer<plonk::verification_key_data>(read_file("./vk"));
info(vk_data);
// info(vk_data);

// note: was moved
// auto data = vk->as_data();
// ASSERT(vk_data == data);
auto data = vk->as_data();
ASSERT(vk_data == data);

// info(data);
// info(proof == read_proof);
composer_2.load_verification_key(std::move(vk_data));
auto verified = composer_2.verify_proof(read_proof, recursive);
// auto verified = acir_composer.verify_proof(read, recursive);

auto verified_2 = composer_2.verify_proof(proof, recursive);

auto verified = acir_composer.verify_proof(read_proof, recursive);

vinfo("verified: ", verified);
vinfo("verified_2: ", verified_2);
ASSERT(verified == verified_2);

return verified;
}

Expand Down Expand Up @@ -152,7 +162,7 @@ void prove(const std::string& bytecodePath,
writeRawBytesToStdout(proof);
vinfo("proof written to stdout");
} else {
write_file(outputPath, proof);
write_file(outputPath + "_prove", proof);
vinfo("proof written to: ", outputPath);
}
}
Expand Down Expand Up @@ -197,11 +207,11 @@ bool verify(const std::string& proof_path, bool recursive, const std::string& vk
{
auto acir_composer = init();
auto vk_data = from_buffer<plonk::verification_key_data>(read_file(vk_path));
info(vk_data);
info(vk_data.hash_native());

auto proof = read_file(proof_path);
info(proof_path);
info(proof);
// info(proof_path);
// info(proof);
acir_composer.load_verification_key(std::move(vk_data));
auto verified = acir_composer.verify_proof(proof, recursive);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ template <typename settings> void ProverBase<settings>::execute_preamble_round()
const size_t w_randomness = 3;
ASSERT(w_randomness < settings::num_roots_cut_out_of_vanishing_polynomial);
for (size_t k = 0; k < w_randomness; ++k) {
wire_lagrange.at(circuit_size - settings::num_roots_cut_out_of_vanishing_polynomial + k) = fr::zero();
wire_lagrange.at(circuit_size - settings::num_roots_cut_out_of_vanishing_polynomial + k) = fr::one();
}

key->polynomial_store.put(wire_tag + "_lagrange", std::move(wire_lagrange));
Expand Down Expand Up @@ -297,7 +297,7 @@ template <typename settings> void ProverBase<settings>::execute_second_round()
ASSERT(w_randomness < settings::num_roots_cut_out_of_vanishing_polynomial);
for (size_t k = 0; k < w_randomness; ++k) {
// Blinding
w_4_lagrange.at(circuit_size - settings::num_roots_cut_out_of_vanishing_polynomial + k) = fr::zero();
w_4_lagrange.at(circuit_size - settings::num_roots_cut_out_of_vanishing_polynomial + k) = fr::one();
}

// compute poly w_4 from w_4_lagrange and add it to the cache
Expand Down Expand Up @@ -464,7 +464,7 @@ template <typename settings> void ProverBase<settings>::add_blinding_to_quotient
// For details, please head to: https://hackmd.io/JiyexiqRQJW55TMRrBqp1g.
for (size_t i = 0; i < settings::program_width - 1; i++) {
// Note that only program_width-1 random elements are required for full blinding
fr quotient_randomness = fr::zero();
fr quotient_randomness = fr::one();

key->quotient_polynomial_parts[i][key->circuit_size] +=
quotient_randomness; // update coefficient of X^n'th term
Expand Down
7 changes: 4 additions & 3 deletions barretenberg/cpp/src/barretenberg/transcript/transcript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,12 @@ std::vector<uint8_t> Transcript::export_transcript() const
ASSERT(manifest_element.num_bytes == element_data.size());
}
if (!manifest_element.derived_by_verifier) {
// printf("writing element %s ", manifest_element.name.c_str());

info("writing element %s ", manifest_element.name.c_str());
// for (size_t j = 0; j < element_data.size(); ++j) {
// printf("%x", element_data[j]);
// info("%x", element_data[j]);
// }
// printf("\n");
// info("\n");
buffer.insert(buffer.end(), element_data.begin(), element_data.end());
}
}
Expand Down

0 comments on commit eb7096b

Please sign in to comment.