-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: encapsulate abstraction leaks from
bb
into new crate (#2747)
- Loading branch information
1 parent
ddb05ab
commit fb9ee4f
Showing
39 changed files
with
122 additions
and
90 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,17 @@ | ||
[package] | ||
name = "bb_abstraction_leaks" | ||
description = "A crate which encapsulates knowledge about Barretenberg which is currently leaking into Nargo" | ||
version = "0.11.0" | ||
authors.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
license.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
acvm.workspace = true | ||
|
||
[build-dependencies] | ||
build-target = "0.4.0" | ||
const_format = "0.2.30" |
File renamed without changes.
File renamed without changes.
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,34 @@ | ||
#![warn(unused_crate_dependencies, unused_extern_crates)] | ||
#![warn(unreachable_pub)] | ||
|
||
use acvm::FieldElement; | ||
|
||
pub const ACVM_BACKEND_BARRETENBERG: &str = "acvm-backend-barretenberg"; | ||
pub const BB_DOWNLOAD_URL: &str = env!("BB_BINARY_URL"); | ||
|
||
/// Embed the Solidity verifier file | ||
const ULTRA_VERIFIER_CONTRACT: &str = include_str!("contract.sol"); | ||
|
||
pub fn complete_barretenberg_verifier_contract(contract: String) -> String { | ||
format!("{contract}{ULTRA_VERIFIER_CONTRACT}") | ||
} | ||
|
||
/// Removes the public inputs which are prepended to a proof by Barretenberg. | ||
pub fn remove_public_inputs(num_pub_inputs: usize, proof: &[u8]) -> Vec<u8> { | ||
// Barretenberg prepends the public inputs onto the proof so we need to remove | ||
// the first `num_pub_inputs` field elements. | ||
let num_bytes_to_remove = num_pub_inputs * (FieldElement::max_num_bytes() as usize); | ||
proof[num_bytes_to_remove..].to_vec() | ||
} | ||
|
||
/// Prepends a set of public inputs to a proof. | ||
pub fn prepend_public_inputs(proof: Vec<u8>, public_inputs: Vec<FieldElement>) -> Vec<u8> { | ||
if public_inputs.is_empty() { | ||
return proof; | ||
} | ||
|
||
let public_inputs_bytes = | ||
public_inputs.into_iter().flat_map(|assignment| assignment.to_be_bytes()); | ||
|
||
public_inputs_bytes.chain(proof).collect() | ||
} |
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
Oops, something went wrong.