-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"vertical slice" of goblin integrating with ACIR and BB. Beginning of goblin ultra honk interface for bb. Can only run a basic test (assert_statement) for now and is not intended for use outside of the CI check that it's still working, for now. - adds bb and bb.js command `prove_and_verify_goblin`. Adds bb.js bindings for goblin prove/verify - modifies ACIR `dsl` folder to be able to take a goblin builder - adds CI calls to bb.js and bb that use `prove_and_verify_goblin` - allowing ability to load grumpkin SRS through memory, needed for bb and (especially) bb.js. This allows an alternate source of points to be used other than the default file-based grumpkin loader, which mostly only works in dev (though revisit: could this work for native bb?) --------- Co-authored-by: ledwards2225 <[email protected]> Co-authored-by: ledwards2225 <[email protected]> Co-authored-by: ludamad <[email protected]> Co-authored-by: ludamad <[email protected]>
- Loading branch information
1 parent
c0a24fb
commit d093266
Showing
93 changed files
with
1,381 additions
and
454 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
VFLAG=${VERBOSE:+-v} | ||
|
||
$BIN prove_and_verify_goblin $VFLAG -c $CRS_PATH -b ./target/acir.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
#include "exec_pipe.hpp" | ||
#include "file_io.hpp" | ||
#include "log.hpp" | ||
#include <barretenberg/ecc/curves/bn254/g1.hpp> | ||
#include <barretenberg/srs/io.hpp> | ||
#include <filesystem> | ||
#include <fstream> | ||
#include <ios> | ||
|
||
std::vector<barretenberg::g1::affine_element> get_bn254_g1_data(const std::filesystem::path& path, size_t num_points); | ||
barretenberg::g2::affine_element get_bn254_g2_data(const std::filesystem::path& path); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include "get_grumpkin_crs.hpp" | ||
|
||
// Gets the transcript URL from the BARRETENBERG_GRUMPKIN_TRANSCRIPT_URL environment variable, if set. | ||
// Otherwise returns the default URL. | ||
namespace { | ||
std::string get_grumpkin_transcript_url() | ||
{ | ||
const char* ENV_VAR_NAME = "BARRETENBERG_GRUMPKIN_TRANSCRIPT_URL"; | ||
const std::string DEFAULT_URL = "https://aztec-ignition.s3.amazonaws.com/TEST%20GRUMPKIN/monomial/transcript00.dat"; | ||
|
||
const char* env_url = std::getenv(ENV_VAR_NAME); | ||
|
||
auto environment_variable_exists = ((env_url != nullptr) && *env_url); | ||
|
||
return environment_variable_exists ? env_url : DEFAULT_URL; | ||
} | ||
} // namespace | ||
|
||
std::vector<uint8_t> download_grumpkin_g1_data(size_t num_points) | ||
{ | ||
size_t g1_start = 28; | ||
size_t g1_end = g1_start + num_points * 64 - 1; | ||
|
||
std::string url = get_grumpkin_transcript_url(); | ||
|
||
std::string command = | ||
"curl -s -H \"Range: bytes=" + std::to_string(g1_start) + "-" + std::to_string(g1_end) + "\" '" + url + "'"; | ||
|
||
auto data = exec_pipe(command); | ||
// Header + num_points * sizeof point. | ||
if (data.size() < g1_end - g1_start) { | ||
throw std::runtime_error("Failed to download grumpkin g1 data."); | ||
} | ||
|
||
return data; | ||
} | ||
|
||
std::vector<curve::Grumpkin::AffineElement> get_grumpkin_g1_data(const std::filesystem::path& path, size_t num_points) | ||
{ | ||
std::filesystem::create_directories(path); | ||
std::ifstream size_file(path / "grumpkin_size"); | ||
size_t size = 0; | ||
if (size_file) { | ||
size_file >> size; | ||
size_file.close(); | ||
} | ||
if (size >= num_points) { | ||
vinfo("using cached crs at: ", path); | ||
auto data = read_file(path / "grumpkin_g1.dat", 28 + num_points * 64); | ||
auto points = std::vector<curve::Grumpkin::AffineElement>(num_points); | ||
auto size_of_points_in_bytes = num_points * 64; | ||
barretenberg::srs::IO<curve::Grumpkin>::read_affine_elements_from_buffer( | ||
points.data(), (char*)data.data(), size_of_points_in_bytes); | ||
return points; | ||
} | ||
|
||
vinfo("downloading grumpkin crs..."); | ||
auto data = download_grumpkin_g1_data(num_points); | ||
write_file(path / "grumpkin_g1.dat", data); | ||
|
||
std::ofstream new_size_file(path / "grumpkin_size"); | ||
if (!new_size_file) { | ||
throw std::runtime_error("Failed to open size file for writing"); | ||
} | ||
new_size_file << num_points; | ||
new_size_file.close(); | ||
|
||
auto points = std::vector<curve::Grumpkin::AffineElement>(num_points); | ||
barretenberg::srs::IO<curve::Grumpkin>::read_affine_elements_from_buffer( | ||
points.data(), (char*)data.data(), data.size()); | ||
return points; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
#include "exec_pipe.hpp" | ||
#include "file_io.hpp" | ||
#include "log.hpp" | ||
#include <barretenberg/ecc/curves/bn254/g1.hpp> | ||
#include <barretenberg/srs/io.hpp> | ||
#include <filesystem> | ||
#include <fstream> | ||
#include <ios> | ||
|
||
std::vector<curve::Grumpkin::AffineElement> get_grumpkin_g1_data(const std::filesystem::path& path, size_t num_points); |
Oops, something went wrong.