Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
feat: update acvm pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant committed Jun 1, 2023
1 parent f4aa834 commit c39987c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 30 deletions.
15 changes: 8 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ thiserror = "1.0.21"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# Native
barretenberg-sys = { git = "https://github.com/noir-lang/barretenberg-sys", optional = true }
barretenberg-sys = { version = "0.2.0", optional = true }

# Wasm
getrandom = { version = "0.2", optional = true }
Expand Down Expand Up @@ -67,4 +67,4 @@ wasm = [
]

[patch.crates-io]
acvm = { git = "https://github.com/noir-lang/acvm", rev = "3c6740af75125afc8ebb4379f781f8274015e2e2" }
acvm = { git = "https://github.com/noir-lang/acvm", rev = "1bd8b981a865a8eea6460721c2526857d7241641" }
2 changes: 0 additions & 2 deletions src/acvm_interop/proof_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ impl ProofSystemCompiler for Barretenberg {
| BlackBoxFunc::HashToField128Security
| BlackBoxFunc::EcdsaSecp256k1
| BlackBoxFunc::FixedBaseScalarMul => true,

BlackBoxFunc::AES => false,
},
}
}
Expand Down
14 changes: 2 additions & 12 deletions src/acvm_interop/pwg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@ use crate::schnorr::SchnorrSig;
use crate::Barretenberg;

impl PartialWitnessGenerator for Barretenberg {
fn aes(
&self,
_initial_witness: &mut WitnessMap,
_inputs: &[FunctionInput],
_outputs: &[Witness],
) -> Result<OpcodeResolution, OpcodeResolutionError> {
Err(OpcodeResolutionError::UnsupportedBlackBoxFunc(
BlackBoxFunc::AES,
))
}

fn schnorr_verify(
&self,
initial_witness: &mut WitnessMap,
Expand Down Expand Up @@ -113,6 +102,7 @@ impl PartialWitnessGenerator for Barretenberg {
&self,
initial_witness: &mut WitnessMap,
inputs: &[FunctionInput],
domain_separator: u32,
outputs: &[Witness],
) -> Result<OpcodeResolution, OpcodeResolutionError> {
let scalars: Result<Vec<_>, _> = inputs
Expand All @@ -121,7 +111,7 @@ impl PartialWitnessGenerator for Barretenberg {
.collect();
let scalars: Vec<_> = scalars?.into_iter().cloned().collect();

let (res_x, res_y) = self.encrypt(scalars, 0).map_err(|err| {
let (res_x, res_y) = self.encrypt(scalars, domain_separator).map_err(|err| {
OpcodeResolutionError::BlackBoxFunctionFailed(BlackBoxFunc::Pedersen, err.to_string())
})?;
initial_witness.insert(outputs[0], res_x);
Expand Down
44 changes: 40 additions & 4 deletions src/barretenberg_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ impl TryFrom<&Circuit> for ConstraintSystem {
let mut blake2s_constraints: Vec<Blake2sConstraint> = Vec::new();
let mut block_constraints: Vec<BlockConstraint> = Vec::new();
let mut keccak_constraints: Vec<Keccak256Constraint> = Vec::new();
let keccak_var_constraints: Vec<Keccak256VarConstraint> = Vec::new();
let mut keccak_var_constraints: Vec<Keccak256VarConstraint> = Vec::new();
let mut pedersen_constraints: Vec<PedersenConstraint> = Vec::new();
let mut schnorr_constraints: Vec<SchnorrConstraint> = Vec::new();
let mut ecdsa_secp256k1_constraints: Vec<EcdsaConstraint> = Vec::new();
Expand Down Expand Up @@ -910,6 +910,7 @@ impl TryFrom<&Circuit> for ConstraintSystem {
}
BlackBoxFuncCall::Pedersen {
inputs: gadget_call_inputs,
domain_separator,
outputs,
} => {
let mut inputs = Vec::new();
Expand All @@ -924,7 +925,7 @@ impl TryFrom<&Circuit> for ConstraintSystem {

let constraint = PedersenConstraint {
inputs,
hash_index: 0,
hash_index: *domain_separator,
result_x,
result_y,
};
Expand Down Expand Up @@ -1062,8 +1063,43 @@ impl TryFrom<&Circuit> for ConstraintSystem {

keccak_constraints.push(keccak_constraint);
}
BlackBoxFuncCall::AES { .. } => {
return Err(Error::UnsupportedBlackBoxFunc(BlackBoxFunc::AES))
BlackBoxFuncCall::Keccak256VariableLength {
inputs,
var_message_size,
outputs,
} => {
let mut keccak_inputs: Vec<(i32, i32)> = Vec::new();
for input in inputs.iter() {
let witness_index = input.witness.witness_index() as i32;
let num_bits = input.num_bits as i32;
keccak_inputs.push((witness_index, num_bits));
}

let var_message_size = var_message_size.witness.witness_index() as i32;

assert_eq!(outputs.len(), 32);

let mut outputs_iter = outputs.iter();
let mut result = [0i32; 32];
for (i, res) in result.iter_mut().enumerate() {
let out_byte =
outputs_iter.next().ok_or_else(|| {
Error::MalformedBlackBoxFunc(
BlackBoxFunc::Keccak256,
format!("Missing rest of output. Tried to get byte {i} but failed"),
)
})?;

let out_byte_index = out_byte.witness_index() as i32;
*res = out_byte_index
}
let keccak_var_constraint = Keccak256VarConstraint {
inputs: keccak_inputs,
var_message_size,
result,
};

keccak_var_constraints.push(keccak_var_constraint);
}
};
}
Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ enum Error {
#[error("Malformed Black Box Function: {0} - {1}")]
MalformedBlackBoxFunc(BlackBoxFunc, String),

#[error("Unsupported Black Box Function: {0}")]
UnsupportedBlackBoxFunc(BlackBoxFunc),

#[error(transparent)]
FromFeature(#[from] FeatureError),

Expand Down

0 comments on commit c39987c

Please sign in to comment.