Skip to content

Commit

Permalink
chore: standardize StubbedBlackBoxSolver error
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Jan 12, 2024
1 parent 8f4d96e commit d142d30
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions acvm-repo/blackbox_solver/src/curve_specific_solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ pub trait BlackBoxFunctionSolver {

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,
Expand All @@ -41,39 +50,27 @@ impl BlackBoxFunctionSolver for StubbedBlackBoxSolver {
_signature: &[u8],
_message: &[u8],
) -> Result<bool, BlackBoxResolutionError> {
Err(BlackBoxResolutionError::Failed(
BlackBoxFunc::SchnorrVerify,
"SchnorrVerify is not supported".to_string(),
))
Err(Self::fail(BlackBoxFunc::SchnorrVerify))
}
fn pedersen_commitment(
&self,
_inputs: &[FieldElement],
_domain_separator: u32,
) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError> {
Err(BlackBoxResolutionError::Failed(
BlackBoxFunc::PedersenCommitment,
"PedersenCommitment is not supported".to_string(),
))
Err(Self::fail(BlackBoxFunc::PedersenCommitment))
}
fn pedersen_hash(
&self,
_inputs: &[FieldElement],
_domain_separator: u32,
) -> Result<FieldElement, BlackBoxResolutionError> {
Err(BlackBoxResolutionError::Failed(
BlackBoxFunc::PedersenHash,
"PedersenHash is not supported".to_string(),
))
Err(Self::fail(BlackBoxFunc::PedersenHash))
}
fn fixed_base_scalar_mul(
&self,
_low: &FieldElement,
_high: &FieldElement,
) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError> {
Err(BlackBoxResolutionError::Failed(
BlackBoxFunc::FixedBaseScalarMul,
"FixedBaseScalarMul is not supported".to_string(),
))
Err(Self::fail(BlackBoxFunc::FixedBaseScalarMul))
}
}

0 comments on commit d142d30

Please sign in to comment.