Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Sync commits from aztec-packages #4144

Merged
merged 99 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
6743afc
feat: Aztec CI files in Noir (#3430)
ludamad Nov 27, 2023
5b5046b
Merge branch 'master' into aztec
kevaundray Nov 28, 2023
7f1b857
Merge remote-tracking branch 'origin/master' into aztec
sirasistant Nov 29, 2023
454b140
feat: Pull latest noir for brillig optimizations (#3464)
sirasistant Nov 29, 2023
fc00722
Merge branch 'master' into aztec
kevaundray Dec 10, 2023
0ad7ba5
Merge branch 'master' into aztec
sirasistant Dec 15, 2023
2d265b4
Merge branch 'master' into aztec-packages
sirasistant Dec 18, 2023
d788414
Merge branch 'master' into aztec-packages
sirasistant Dec 19, 2023
f06ab9c
feat: update to latest noir and update noir compiler (#3696)
Thunkar Dec 19, 2023
29ff6ce
chore: revert unwanted changes
TomAFrench Dec 19, 2023
d144743
chore: Cleanup recursion interface (#3744)
vezenovm Dec 19, 2023
20f1652
feat!: updated note hash and nullifier macro (#3777)
benesjan Jan 2, 2024
ce02b01
fix: event macro (#3784)
benesjan Jan 2, 2024
50925ea
feat!: moving `compute_selector` to `FunctionSelector` (#3806)
benesjan Jan 3, 2024
338cb57
chore: Just nargo compile. (#3775)
charlielye Jan 3, 2024
717f1fa
Merge branch 'master' into aztec-packages
sirasistant Jan 4, 2024
1005f32
chore: delete extraneous gzips
sirasistant Jan 4, 2024
50cb28c
chore: fix clippy and fmt
sirasistant Jan 4, 2024
a6289a5
chore: noir sync (#3884)
ludamad Jan 8, 2024
c0826b5
chore!: Remove aggregation objects from RecursionConstraint (#3885)
vezenovm Jan 8, 2024
3521d28
feat: update BB version
sirasistant Jan 9, 2024
a3366d6
test: fix serialization and bb tests
sirasistant Jan 9, 2024
16a4f50
Merge branch 'master' into aztec-packages
sirasistant Jan 9, 2024
c6bc062
fix: remove extraneous usage of hash to field
sirasistant Jan 9, 2024
e9405f0
style: fmt
sirasistant Jan 9, 2024
4178e74
chore: update serialized bytecodes
sirasistant Jan 9, 2024
ad7e3b1
chore: update bbjs
sirasistant Jan 9, 2024
404ffbf
fix: intermediate proof artifacts returns proof without public inputs
sirasistant Jan 9, 2024
0886b1b
Try to fix recursion test and remove unused codegen
sirasistant Jan 9, 2024
812576b
Remove test-cargo workflow
sirasistant Jan 9, 2024
3c8f83e
chore: remove now unused bb abstraction leaks
sirasistant Jan 9, 2024
89bf498
chore: fix builds of `noir_js_backend_barretenberg`
TomAFrench Jan 9, 2024
9affee6
Revert "chore: remove now unused bb abstraction leaks"
TomAFrench Jan 9, 2024
1725e70
chore: clippy fix
TomAFrench Jan 9, 2024
394154e
Revert "chore: fix builds of `noir_js_backend_barretenberg`"
TomAFrench Jan 9, 2024
39d4bfa
fix: avoid decoding public inputs
sirasistant Jan 9, 2024
04f2bf4
Merge branch 'aztec-packages' of github.com:noir-lang/noir into aztec…
sirasistant Jan 9, 2024
5b64df3
Revert "fix: avoid decoding public inputs"
sirasistant Jan 9, 2024
9ec2e07
fix: possible workaround for the hidden public inputs issue
sirasistant Jan 9, 2024
ee2e6c0
test: fix test
sirasistant Jan 9, 2024
742e940
test: fix noir_js_backend_bb test
sirasistant Jan 9, 2024
61c2b9b
fix: output public inputs vector + function to recover a witness map
sirasistant Jan 9, 2024
114aa6f
chore: fix formatting
sirasistant Jan 9, 2024
ee802c9
Merge branch 'master' into aztec-packages
TomAFrench Jan 9, 2024
3f6a24d
Merge branch 'master' into aztec-packages
TomAFrench Jan 11, 2024
f4bbe21
Merge branch 'master' into aztec-packages
TomAFrench Jan 11, 2024
75c8334
Merge branch 'master' into aztec-packages
TomAFrench Jan 11, 2024
3416229
Merge branch 'master' into aztec-packages
TomAFrench Jan 11, 2024
5646354
chore: git subrepo commit (merge) noir (#3955)
ludamad Jan 11, 2024
7c357e4
feat!: implement keccakf1600 in brillig (#3914)
TomAFrench Jan 11, 2024
b5a1eb5
chore!: define key type in maps (#3841)
Thunkar Jan 12, 2024
5162b33
chore: fix rust tests (#3963)
TomAFrench Jan 12, 2024
55aa96f
chore: fix formatter tests
TomAFrench Jan 12, 2024
d7c4c66
Merge branch 'master' into aztec-packages
sirasistant Jan 12, 2024
563c704
feat: Update noir (#3979)
sirasistant Jan 12, 2024
787ccdc
Merge branch 'master' into aztec-packages
TomAFrench Jan 13, 2024
e7da1ab
Merge branch 'master' into aztec-packages
TomAFrench Jan 15, 2024
7f22446
Merge branch 'master' into aztec-packages
TomAFrench Jan 15, 2024
0f38b22
Merge branch 'master' into aztec-packages
TomAFrench Jan 15, 2024
2d92108
chore: sync noir (#4025)
TomAFrench Jan 15, 2024
001b8e0
chore: replace `AztecU128` with `U128` (#3951)
TomAFrench Jan 15, 2024
5e51255
fix: dont spam logs with yarn install (#4027)
ludamad Jan 15, 2024
45165d1
fix: Start witness of ACIR generated by Noir start at zero not one (#…
vezenovm Jan 16, 2024
4980553
chore: bump `bb` version to 0.18.0
TomAFrench Jan 16, 2024
4300ce2
chore: cargo fmt
TomAFrench Jan 16, 2024
9995d2b
Merge branch 'master' into aztec-packages
TomAFrench Jan 16, 2024
a4b6635
chore: sync from noir repo (#4047)
TomAFrench Jan 16, 2024
0c185c2
Merge branch 'master' into aztec-packages
sirasistant Jan 17, 2024
e6d3e73
chore: bump version
TomAFrench Jan 17, 2024
3541dd0
chore: bump bb.js
TomAFrench Jan 17, 2024
0858aa4
feat!: Unify ABIs between nargo and yarn-project (#3989)
spalladino Jan 17, 2024
8ac47e5
git subrepo pull (merge) noir
spalladino Jan 17, 2024
5a1b2bb
fix: Nargo destination path in bootstrap cache (#4103)
spalladino Jan 17, 2024
13f93d5
chore: Fixes many broken urls (#4109)
jzaki Jan 17, 2024
88ecd78
Merge branch 'master' into aztec-packages
TomAFrench Jan 18, 2024
40c2dc3
chore: formatting fix
TomAFrench Jan 18, 2024
3558c72
Merge branch 'master' into aztec-packages
TomAFrench Jan 18, 2024
b26dba8
Merge branch 'master' into aztec-packages
TomAFrench Jan 18, 2024
727473c
Merge branch 'master' of github.com:noir-lang/noir into aztec-packages
Thunkar Jan 18, 2024
602f23f
Merge branch 'master' into aztec-packages
sirasistant Jan 22, 2024
7dba0a1
feat!: Add big int opcodes (without implementation) (#4050)
guipublic Jan 24, 2024
914403d
feat: implement bigint in Noir, using bigint opcodes (#4198)
guipublic Jan 25, 2024
9debf5c
feat: Implement Embedded EC add and double opcodes (#3982)
guipublic Jan 25, 2024
af203d6
feat!: remove ec_double opcode (#4210)
guipublic Jan 25, 2024
435d041
feat!: add opcode for poseidon2 permutation (#4214)
guipublic Jan 25, 2024
e470b94
refactor: delete C++ PK circuits (#4219)
ludamad Jan 25, 2024
2c463bc
feat!: add opcode for sha256 compression function (#4229)
guipublic Jan 26, 2024
52fc077
Merge branch 'master' into aztec-packages
Thunkar Jan 29, 2024
031c534
Merge branch 'master' of github.com:noir-lang/noir into aztec-packages
Thunkar Jan 29, 2024
ea6aebc
Merge branch 'aztec-packages' of github.com:noir-lang/noir into aztec…
Thunkar Jan 29, 2024
14d491b
Update noir_stdlib/src/scalar_mul.nr
TomAFrench Jan 29, 2024
7b50fd9
Update noir_stdlib/src/scalar_mul.nr
TomAFrench Jan 29, 2024
1f246fa
Merge branch 'master' into aztec-packages
TomAFrench Jan 30, 2024
68c05f6
chore: update bb with latest release
sirasistant Jan 30, 2024
6bc7107
chore: disable stdlib functions for unimplemented functionality
TomAFrench Jan 30, 2024
1e43b32
fix: underscore prefix unused vars
sirasistant Jan 30, 2024
aa163e0
Merge branch 'aztec-packages' of github.com:noir-lang/noir into aztec…
sirasistant Jan 30, 2024
5503531
feat: implement `Add` and `double` method on `EmbeddedCurvePoint`
TomAFrench Jan 30, 2024
2badd02
fix: use new add and double methods
sirasistant Jan 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,312 changes: 1,030 additions & 282 deletions acvm-repo/acir/codegen/acir.cpp

Large diffs are not rendered by default.

42 changes: 36 additions & 6 deletions acvm-repo/acir/src/circuit/black_box_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,22 @@ pub enum BlackBoxFunc {
RecursiveAggregation,
/// Addition over the embedded curve on which [`FieldElement`][acir_field::FieldElement] is defined.
EmbeddedCurveAdd,
/// Point doubling over the embedded curve on which [`FieldElement`][acir_field::FieldElement] is defined.
EmbeddedCurveDouble,
/// BigInt addition
BigIntAdd,
/// BigInt subtraction
BigIntNeg,
/// BigInt multiplication
BigIntMul,
/// BigInt division
BigIntDiv,
/// BigInt from le bytes
BigIntFromLeBytes,
/// BigInt to le bytes
BigIntToLeBytes,
/// Permutation function of Poseidon2
Poseidon2Permutation,
/// SHA256 compression function
Sha256Compression,
}

impl std::fmt::Display for BlackBoxFunc {
Expand All @@ -68,17 +82,25 @@ impl BlackBoxFunc {
BlackBoxFunc::PedersenHash => "pedersen_hash",
BlackBoxFunc::EcdsaSecp256k1 => "ecdsa_secp256k1",
BlackBoxFunc::FixedBaseScalarMul => "fixed_base_scalar_mul",
BlackBoxFunc::EmbeddedCurveAdd => "ec_add",
BlackBoxFunc::EmbeddedCurveDouble => "ec_double",
BlackBoxFunc::EmbeddedCurveAdd => "embedded_curve_add",
BlackBoxFunc::AND => "and",
BlackBoxFunc::XOR => "xor",
BlackBoxFunc::RANGE => "range",
BlackBoxFunc::Keccak256 => "keccak256",
BlackBoxFunc::Keccakf1600 => "keccakf1600",
BlackBoxFunc::RecursiveAggregation => "recursive_aggregation",
BlackBoxFunc::EcdsaSecp256r1 => "ecdsa_secp256r1",
BlackBoxFunc::BigIntAdd => "bigint_add",
BlackBoxFunc::BigIntNeg => "bigint_neg",
BlackBoxFunc::BigIntMul => "bigint_mul",
BlackBoxFunc::BigIntDiv => "bigint_div",
BlackBoxFunc::BigIntFromLeBytes => "bigint_from_le_bytes",
BlackBoxFunc::BigIntToLeBytes => "bigint_to_le_bytes",
BlackBoxFunc::Poseidon2Permutation => "poseidon2_permutation",
BlackBoxFunc::Sha256Compression => "sha256_compression",
}
}

pub fn lookup(op_name: &str) -> Option<BlackBoxFunc> {
match op_name {
"sha256" => Some(BlackBoxFunc::SHA256),
Expand All @@ -90,17 +112,25 @@ impl BlackBoxFunc {
"ecdsa_secp256k1" => Some(BlackBoxFunc::EcdsaSecp256k1),
"ecdsa_secp256r1" => Some(BlackBoxFunc::EcdsaSecp256r1),
"fixed_base_scalar_mul" => Some(BlackBoxFunc::FixedBaseScalarMul),
"ec_add" => Some(BlackBoxFunc::EmbeddedCurveAdd),
"ec_double" => Some(BlackBoxFunc::EmbeddedCurveDouble),
"embedded_curve_add" => Some(BlackBoxFunc::EmbeddedCurveAdd),
"and" => Some(BlackBoxFunc::AND),
"xor" => Some(BlackBoxFunc::XOR),
"range" => Some(BlackBoxFunc::RANGE),
"keccak256" => Some(BlackBoxFunc::Keccak256),
"keccakf1600" => Some(BlackBoxFunc::Keccakf1600),
"recursive_aggregation" => Some(BlackBoxFunc::RecursiveAggregation),
"bigint_add" => Some(BlackBoxFunc::BigIntAdd),
"bigint_neg" => Some(BlackBoxFunc::BigIntNeg),
"bigint_mul" => Some(BlackBoxFunc::BigIntMul),
"bigint_div" => Some(BlackBoxFunc::BigIntDiv),
"bigint_from_le_bytes" => Some(BlackBoxFunc::BigIntFromLeBytes),
"bigint_to_le_bytes" => Some(BlackBoxFunc::BigIntToLeBytes),
"poseidon2_permutation" => Some(BlackBoxFunc::Poseidon2Permutation),
"sha256_compression" => Some(BlackBoxFunc::Sha256Compression),
_ => None,
}
}

pub fn is_valid_black_box_func_name(op_name: &str) -> bool {
BlackBoxFunc::lookup(op_name).is_some()
}
Expand Down
100 changes: 85 additions & 15 deletions acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ pub enum BlackBoxFuncCall {
input2_y: FunctionInput,
outputs: (Witness, Witness),
},
EmbeddedCurveDouble {
input_x: FunctionInput,
input_y: FunctionInput,
outputs: (Witness, Witness),
},
Keccak256 {
inputs: Vec<FunctionInput>,
outputs: Vec<Witness>,
Expand Down Expand Up @@ -120,6 +115,61 @@ pub enum BlackBoxFuncCall {
/// key provided to the circuit matches the key produced by the circuit creator
key_hash: FunctionInput,
},
BigIntAdd {
lhs: u32,
rhs: u32,
output: u32,
},
BigIntNeg {
lhs: u32,
rhs: u32,
output: u32,
},
BigIntMul {
lhs: u32,
rhs: u32,
output: u32,
},
BigIntDiv {
lhs: u32,
rhs: u32,
output: u32,
},
BigIntFromLeBytes {
inputs: Vec<FunctionInput>,
modulus: Vec<u8>,
output: u32,
},
BigIntToLeBytes {
input: u32,
outputs: Vec<Witness>,
},
/// Applies the Poseidon2 permutation function to the given state,
/// outputting the permuted state.
Poseidon2Permutation {
/// Input state for the permutation of Poseidon2
inputs: Vec<FunctionInput>,
/// Permuted state
outputs: Vec<Witness>,
/// State length (in number of field elements)
/// It is the length of inputs and outputs vectors
len: u32,
},
/// Applies the SHA-256 compression function to the input message
///
/// # Arguments
///
/// * `inputs` - input message block
/// * `hash_values` - state from the previous compression
/// * `outputs` - result of the input compressed into 256 bits
Sha256Compression {
/// 512 bits of the input message, represented by 16 u32s
inputs: Vec<FunctionInput>,
/// Vector of 8 u32s used to compress the input
hash_values: Vec<FunctionInput>,
/// Output of the compression, represented by 8 u32s
outputs: Vec<Witness>,
},
}

impl BlackBoxFuncCall {
Expand All @@ -138,11 +188,18 @@ impl BlackBoxFuncCall {
BlackBoxFuncCall::EcdsaSecp256r1 { .. } => BlackBoxFunc::EcdsaSecp256r1,
BlackBoxFuncCall::FixedBaseScalarMul { .. } => BlackBoxFunc::FixedBaseScalarMul,
BlackBoxFuncCall::EmbeddedCurveAdd { .. } => BlackBoxFunc::EmbeddedCurveAdd,
BlackBoxFuncCall::EmbeddedCurveDouble { .. } => BlackBoxFunc::EmbeddedCurveDouble,
BlackBoxFuncCall::Keccak256 { .. } => BlackBoxFunc::Keccak256,
BlackBoxFuncCall::Keccak256VariableLength { .. } => BlackBoxFunc::Keccak256,
BlackBoxFuncCall::Keccakf1600 { .. } => BlackBoxFunc::Keccakf1600,
BlackBoxFuncCall::RecursiveAggregation { .. } => BlackBoxFunc::RecursiveAggregation,
BlackBoxFuncCall::BigIntAdd { .. } => BlackBoxFunc::BigIntAdd,
BlackBoxFuncCall::BigIntNeg { .. } => BlackBoxFunc::BigIntNeg,
BlackBoxFuncCall::BigIntMul { .. } => BlackBoxFunc::BigIntMul,
BlackBoxFuncCall::BigIntDiv { .. } => BlackBoxFunc::BigIntDiv,
BlackBoxFuncCall::BigIntFromLeBytes { .. } => BlackBoxFunc::BigIntFromLeBytes,
BlackBoxFuncCall::BigIntToLeBytes { .. } => BlackBoxFunc::BigIntToLeBytes,
BlackBoxFuncCall::Poseidon2Permutation { .. } => BlackBoxFunc::Poseidon2Permutation,
BlackBoxFuncCall::Sha256Compression { .. } => BlackBoxFunc::Sha256Compression,
}
}

Expand All @@ -158,17 +215,22 @@ impl BlackBoxFuncCall {
| BlackBoxFuncCall::Keccak256 { inputs, .. }
| BlackBoxFuncCall::Keccakf1600 { inputs, .. }
| BlackBoxFuncCall::PedersenCommitment { inputs, .. }
| BlackBoxFuncCall::PedersenHash { inputs, .. } => inputs.to_vec(),
| BlackBoxFuncCall::PedersenHash { inputs, .. }
| BlackBoxFuncCall::BigIntFromLeBytes { inputs, .. }
| BlackBoxFuncCall::Poseidon2Permutation { inputs, .. }
| BlackBoxFuncCall::Sha256Compression { inputs, .. } => inputs.to_vec(),
BlackBoxFuncCall::AND { lhs, rhs, .. } | BlackBoxFuncCall::XOR { lhs, rhs, .. } => {
vec![*lhs, *rhs]
}
BlackBoxFuncCall::BigIntAdd { .. }
| BlackBoxFuncCall::BigIntNeg { .. }
| BlackBoxFuncCall::BigIntMul { .. }
| BlackBoxFuncCall::BigIntDiv { .. }
| BlackBoxFuncCall::BigIntToLeBytes { .. } => Vec::new(),
BlackBoxFuncCall::FixedBaseScalarMul { low, high, .. } => vec![*low, *high],
BlackBoxFuncCall::EmbeddedCurveAdd {
input1_x, input1_y, input2_x, input2_y, ..
} => vec![*input1_x, *input1_y, *input2_x, *input2_y],
BlackBoxFuncCall::EmbeddedCurveDouble { input_x, input_y, .. } => {
vec![*input_x, *input_y]
}
BlackBoxFuncCall::RANGE { input } => vec![*input],
BlackBoxFuncCall::SchnorrVerify {
public_key_x,
Expand Down Expand Up @@ -249,7 +311,10 @@ impl BlackBoxFuncCall {
| BlackBoxFuncCall::Blake2s { outputs, .. }
| BlackBoxFuncCall::Blake3 { outputs, .. }
| BlackBoxFuncCall::Keccak256 { outputs, .. }
| BlackBoxFuncCall::Keccakf1600 { outputs, .. } => outputs.to_vec(),
| BlackBoxFuncCall::Keccakf1600 { outputs, .. }
| BlackBoxFuncCall::Keccak256VariableLength { outputs, .. }
| BlackBoxFuncCall::Poseidon2Permutation { outputs, .. }
| BlackBoxFuncCall::Sha256Compression { outputs, .. } => outputs.to_vec(),
BlackBoxFuncCall::AND { output, .. }
| BlackBoxFuncCall::XOR { output, .. }
| BlackBoxFuncCall::SchnorrVerify { output, .. }
Expand All @@ -258,12 +323,17 @@ impl BlackBoxFuncCall {
| BlackBoxFuncCall::EcdsaSecp256r1 { output, .. } => vec![*output],
BlackBoxFuncCall::FixedBaseScalarMul { outputs, .. }
| BlackBoxFuncCall::PedersenCommitment { outputs, .. }
| BlackBoxFuncCall::EmbeddedCurveAdd { outputs, .. }
| BlackBoxFuncCall::EmbeddedCurveDouble { outputs, .. } => vec![outputs.0, outputs.1],
BlackBoxFuncCall::RANGE { .. } | BlackBoxFuncCall::RecursiveAggregation { .. } => {
| BlackBoxFuncCall::EmbeddedCurveAdd { outputs, .. } => vec![outputs.0, outputs.1],
BlackBoxFuncCall::RANGE { .. }
| BlackBoxFuncCall::RecursiveAggregation { .. }
| BlackBoxFuncCall::BigIntFromLeBytes { .. }
| BlackBoxFuncCall::BigIntAdd { .. }
| BlackBoxFuncCall::BigIntNeg { .. }
| BlackBoxFuncCall::BigIntMul { .. }
| BlackBoxFuncCall::BigIntDiv { .. } => {
vec![]
}
BlackBoxFuncCall::Keccak256VariableLength { outputs, .. } => outputs.to_vec(),
BlackBoxFuncCall::BigIntToLeBytes { outputs, .. } => outputs.to_vec(),
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions acvm-repo/acvm/src/pwg/blackbox/fixed_base_scalar_mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,24 @@ pub(super) fn fixed_base_scalar_mul(

Ok(())
}

pub(super) fn embedded_curve_add(
backend: &impl BlackBoxFunctionSolver,
initial_witness: &mut WitnessMap,
input1_x: FunctionInput,
input1_y: FunctionInput,
input2_x: FunctionInput,
input2_y: FunctionInput,
outputs: (Witness, Witness),
) -> Result<(), OpcodeResolutionError> {
let input1_x = witness_to_value(initial_witness, input1_x.witness)?;
let input1_y = witness_to_value(initial_witness, input1_y.witness)?;
let input2_x = witness_to_value(initial_witness, input2_x.witness)?;
let input2_y = witness_to_value(initial_witness, input2_y.witness)?;
let (res_x, res_y) = backend.ec_add(input1_x, input1_y, input2_x, input2_y)?;

insert_value(&outputs.0, res_x, initial_witness)?;
insert_value(&outputs.1, res_y, initial_witness)?;

Ok(())
}
25 changes: 19 additions & 6 deletions acvm-repo/acvm/src/pwg/blackbox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod pedersen;
mod range;
mod signature;

use fixed_base_scalar_mul::fixed_base_scalar_mul;
use fixed_base_scalar_mul::{embedded_curve_add, fixed_base_scalar_mul};
// Hash functions should eventually be exposed for external consumers.
use hash::solve_generic_256_hash_opcode;
use logic::{and, xor};
Expand Down Expand Up @@ -177,13 +177,26 @@ pub(crate) fn solve(
BlackBoxFuncCall::FixedBaseScalarMul { low, high, outputs } => {
fixed_base_scalar_mul(backend, initial_witness, *low, *high, *outputs)
}
BlackBoxFuncCall::EmbeddedCurveAdd { .. } => {
todo!();
}
BlackBoxFuncCall::EmbeddedCurveDouble { .. } => {
todo!();
BlackBoxFuncCall::EmbeddedCurveAdd { input1_x, input1_y, input2_x, input2_y, outputs } => {
embedded_curve_add(
backend,
initial_witness,
*input1_x,
*input1_y,
*input2_x,
*input2_y,
*outputs,
)
}
// Recursive aggregation will be entirely handled by the backend and is not solved by the ACVM
BlackBoxFuncCall::RecursiveAggregation { .. } => Ok(()),
BlackBoxFuncCall::BigIntAdd { .. } => todo!(),
BlackBoxFuncCall::BigIntNeg { .. } => todo!(),
BlackBoxFuncCall::BigIntMul { .. } => todo!(),
BlackBoxFuncCall::BigIntDiv { .. } => todo!(),
BlackBoxFuncCall::BigIntFromLeBytes { .. } => todo!(),
BlackBoxFuncCall::BigIntToLeBytes { .. } => todo!(),
BlackBoxFuncCall::Poseidon2Permutation { .. } => todo!(),
BlackBoxFuncCall::Sha256Compression { .. } => todo!(),
}
}
12 changes: 0 additions & 12 deletions acvm-repo/blackbox_solver/src/curve_specific_solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ pub trait BlackBoxFunctionSolver {
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;
Expand Down Expand Up @@ -94,11 +89,4 @@ impl BlackBoxFunctionSolver for StubbedBlackBoxSolver {
) -> 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))
}
}
20 changes: 20 additions & 0 deletions acvm-repo/bn254_blackbox_solver/src/fixed_base_scalar_mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ pub fn fixed_base_scalar_mul(
}
}

pub fn embedded_curve_add(
input1_x: FieldElement,
input1_y: FieldElement,
input2_x: FieldElement,
input2_y: FieldElement,
) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError> {
let mut point1 = grumpkin::SWAffine::new(input1_x.into_repr(), input1_y.into_repr());
let point2 = grumpkin::SWAffine::new(input2_x.into_repr(), input2_y.into_repr());
let res = point1 + point2;
point1 = res.into();
if let Some((res_x, res_y)) = point1.xy() {
Ok((FieldElement::from_repr(*res_x), FieldElement::from_repr(*res_y)))
} else {
Err(BlackBoxResolutionError::Failed(
BlackBoxFunc::EmbeddedCurveAdd,
"Point is not on curve".to_string(),
))
}
}

#[cfg(test)]
mod grumpkin_fixed_base_scalar_mul {
use ark_ff::BigInteger;
Expand Down
20 changes: 6 additions & 14 deletions acvm-repo/bn254_blackbox_solver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use acvm_blackbox_solver::{BlackBoxFunctionSolver, BlackBoxResolutionError};
mod fixed_base_scalar_mul;
mod wasm;

pub use fixed_base_scalar_mul::fixed_base_scalar_mul;
pub use fixed_base_scalar_mul::{embedded_curve_add, fixed_base_scalar_mul};
use wasm::Barretenberg;

use self::wasm::{Pedersen, SchnorrSig};
Expand Down Expand Up @@ -90,19 +90,11 @@ impl BlackBoxFunctionSolver for Bn254BlackBoxSolver {

fn ec_add(
&self,
_input1_x: &FieldElement,
_input1_y: &FieldElement,
_input2_x: &FieldElement,
_input2_y: &FieldElement,
input1_x: &FieldElement,
input1_y: &FieldElement,
input2_x: &FieldElement,
input2_y: &FieldElement,
) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError> {
todo!();
}

fn ec_double(
&self,
_input_x: &FieldElement,
_input_y: &FieldElement,
) -> Result<(FieldElement, FieldElement), BlackBoxResolutionError> {
todo!();
embedded_curve_add(*input1_x, *input1_y, *input2_x, *input2_y)
}
}
Loading
Loading