-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into aztec-packages
* master: feat: add `noir-compiler` checks to `aztec_macros` (#4031) chore: remove unnecessary visibility modifiers from u128 trait impls (#4023) chore(ci): install fixed version of `wasm-pack` in CI (#4034) chore: remove `release-tests` package (#4032) chore(docs): bumping playground version (#4030) fix: allow ast when macro errors (#4005) chore: provide a canonical "failing" `BlackBoxFunctionSolver` (#4028) feat: assert maximum bit size when creating a U128 from an integer (#4024)
- Loading branch information
Showing
23 changed files
with
211 additions
and
777 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
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,104 @@ | ||
use acir::{BlackBoxFunc, FieldElement}; | ||
|
||
use crate::BlackBoxResolutionError; | ||
|
||
/// This component will generate outputs for Blackbox function calls where the underlying [`acir::BlackBoxFunc`] | ||
/// doesn't have a canonical Rust implementation. | ||
/// | ||
/// Returns an [`BlackBoxResolutionError`] if the backend does not support the given [`acir::BlackBoxFunc`]. | ||
pub trait BlackBoxFunctionSolver { | ||
fn schnorr_verify( | ||
&self, | ||
public_key_x: &FieldElement, | ||
public_key_y: &FieldElement, | ||
signature: &[u8], | ||
message: &[u8], | ||
) -> Result<bool, BlackBoxResolutionError>; | ||
fn pedersen_commitment( | ||
&self, | ||
inputs: &[FieldElement], | ||
domain_separator: u32, | ||
) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError>; | ||
fn pedersen_hash( | ||
&self, | ||
inputs: &[FieldElement], | ||
domain_separator: u32, | ||
) -> Result<FieldElement, BlackBoxResolutionError>; | ||
fn fixed_base_scalar_mul( | ||
&self, | ||
low: &FieldElement, | ||
high: &FieldElement, | ||
) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError>; | ||
fn ec_add( | ||
&self, | ||
input1_x: &FieldElement, | ||
input1_y: &FieldElement, | ||
input2_x: &FieldElement, | ||
input2_y: &FieldElement, | ||
) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError>; | ||
fn ec_double( | ||
&self, | ||
input_x: &FieldElement, | ||
input_x: &FieldElement, | ||
) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError>; | ||
} | ||
|
||
pub struct StubbedBlackBoxSolver; | ||
|
||
impl StubbedBlackBoxSolver { | ||
fn fail(black_box_function: BlackBoxFunc) -> BlackBoxResolutionError { | ||
BlackBoxResolutionError::Failed( | ||
black_box_function, | ||
format!("{} is not supported", black_box_function.name()), | ||
) | ||
} | ||
} | ||
|
||
impl BlackBoxFunctionSolver for StubbedBlackBoxSolver { | ||
fn schnorr_verify( | ||
&self, | ||
_public_key_x: &FieldElement, | ||
_public_key_y: &FieldElement, | ||
_signature: &[u8], | ||
_message: &[u8], | ||
) -> Result<bool, BlackBoxResolutionError> { | ||
Err(Self::fail(BlackBoxFunc::SchnorrVerify)) | ||
} | ||
fn pedersen_commitment( | ||
&self, | ||
_inputs: &[FieldElement], | ||
_domain_separator: u32, | ||
) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError> { | ||
Err(Self::fail(BlackBoxFunc::PedersenCommitment)) | ||
} | ||
fn pedersen_hash( | ||
&self, | ||
_inputs: &[FieldElement], | ||
_domain_separator: u32, | ||
) -> Result<FieldElement, BlackBoxResolutionError> { | ||
Err(Self::fail(BlackBoxFunc::PedersenHash)) | ||
} | ||
fn fixed_base_scalar_mul( | ||
&self, | ||
_low: &FieldElement, | ||
_high: &FieldElement, | ||
) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError> { | ||
Err(Self::fail(BlackBoxFunc::FixedBaseScalarMul)) | ||
} | ||
fn ec_add( | ||
&self, | ||
_input1_x: &FieldElement, | ||
_input1_y: &FieldElement, | ||
_input2_x: &FieldElement, | ||
_input2_y: &FieldElement, | ||
) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError> { | ||
Err(Self::fail(BlackBoxFunc::EmbeddedCurveAdd)) | ||
} | ||
fn ec_double( | ||
&self, | ||
_input_x: &FieldElement, | ||
_input_y: &FieldElement, | ||
) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError> { | ||
Err(Self::fail(BlackBoxFunc::EmbeddedCurveDouble)) | ||
} | ||
} |
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.