-
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.
Merge branch 'master' into michaeljklein/mod-nr-entrypoint
* master: chore: replace cached `in_contract` with `in_contract()` method (#5324) fix: fix usage of `#[abi(tag)]` attribute with elaborator (#5298) fix: don't benchmark the "prove" command as it doesn't exist anymore (#5323) feat(stdlib): Update stdlib to use explicit numeric generics (#5306) feat: let `should_fail_with` check that the failure reason contains the expected message (#5319) chore: bump `bb` to 0.43.0 (#5321) feat(frontend): Explicit numeric generics and type kinds (#5155) feat(frontend): Where clause on impl (#5320) chore: add back Pedersen blackbox functions (revert PR 5221) (#5318) fix: skip emission of brillig calls which will never be executed (#5314) feat: Make macros operate on token streams instead of AST nodes (#5301) chore: Bundle SSA Evaluator Options (#5317) fix: Replace panic in monomorphization with an error (#5305) fix(nargo_fmt): Account for spaces before the generic list of a function (#5303)
- Loading branch information
Showing
131 changed files
with
2,847 additions
and
1,196 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use acir::{ | ||
circuit::opcodes::FunctionInput, | ||
native_types::{Witness, WitnessMap}, | ||
AcirField, | ||
}; | ||
|
||
use crate::{ | ||
pwg::{insert_value, witness_to_value, OpcodeResolutionError}, | ||
BlackBoxFunctionSolver, | ||
}; | ||
|
||
pub(super) fn pedersen<F: AcirField>( | ||
backend: &impl BlackBoxFunctionSolver<F>, | ||
initial_witness: &mut WitnessMap<F>, | ||
inputs: &[FunctionInput], | ||
domain_separator: u32, | ||
outputs: (Witness, Witness), | ||
) -> Result<(), OpcodeResolutionError<F>> { | ||
let scalars: Result<Vec<_>, _> = | ||
inputs.iter().map(|input| witness_to_value(initial_witness, input.witness)).collect(); | ||
let scalars: Vec<_> = scalars?.into_iter().cloned().collect(); | ||
|
||
let (res_x, res_y) = backend.pedersen_commitment(&scalars, domain_separator)?; | ||
|
||
insert_value(&outputs.0, res_x, initial_witness)?; | ||
insert_value(&outputs.1, res_y, initial_witness)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub(super) fn pedersen_hash<F: AcirField>( | ||
backend: &impl BlackBoxFunctionSolver<F>, | ||
initial_witness: &mut WitnessMap<F>, | ||
inputs: &[FunctionInput], | ||
domain_separator: u32, | ||
output: Witness, | ||
) -> Result<(), OpcodeResolutionError<F>> { | ||
let scalars: Result<Vec<_>, _> = | ||
inputs.iter().map(|input| witness_to_value(initial_witness, input.witness)).collect(); | ||
let scalars: Vec<_> = scalars?.into_iter().cloned().collect(); | ||
|
||
let res = backend.pedersen_hash(&scalars, domain_separator)?; | ||
|
||
insert_value(&output, res, initial_witness)?; | ||
|
||
Ok(()) | ||
} |
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.