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 from aztec-packages #6861

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .aztec-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5e4b46d577ebf63114a5a5a1c5b6d2947d3b2567
51d82aaf62b84885eb388b1565c1a119c60d849e
14 changes: 9 additions & 5 deletions acvm-repo/acir/codegen/acir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,9 @@ namespace Program {
struct ToRadix {
Program::MemoryAddress input;
Program::MemoryAddress radix;
Program::HeapArray output;
bool output_bits;
Program::MemoryAddress output_pointer;
Program::MemoryAddress num_limbs;
Program::MemoryAddress output_bits;

friend bool operator==(const ToRadix&, const ToRadix&);
std::vector<uint8_t> bincodeSerialize() const;
Expand Down Expand Up @@ -3898,7 +3899,8 @@ namespace Program {
inline bool operator==(const BlackBoxOp::ToRadix &lhs, const BlackBoxOp::ToRadix &rhs) {
if (!(lhs.input == rhs.input)) { return false; }
if (!(lhs.radix == rhs.radix)) { return false; }
if (!(lhs.output == rhs.output)) { return false; }
if (!(lhs.output_pointer == rhs.output_pointer)) { return false; }
if (!(lhs.num_limbs == rhs.num_limbs)) { return false; }
if (!(lhs.output_bits == rhs.output_bits)) { return false; }
return true;
}
Expand All @@ -3925,7 +3927,8 @@ template <typename Serializer>
void serde::Serializable<Program::BlackBoxOp::ToRadix>::serialize(const Program::BlackBoxOp::ToRadix &obj, Serializer &serializer) {
serde::Serializable<decltype(obj.input)>::serialize(obj.input, serializer);
serde::Serializable<decltype(obj.radix)>::serialize(obj.radix, serializer);
serde::Serializable<decltype(obj.output)>::serialize(obj.output, serializer);
serde::Serializable<decltype(obj.output_pointer)>::serialize(obj.output_pointer, serializer);
serde::Serializable<decltype(obj.num_limbs)>::serialize(obj.num_limbs, serializer);
serde::Serializable<decltype(obj.output_bits)>::serialize(obj.output_bits, serializer);
}

Expand All @@ -3935,7 +3938,8 @@ Program::BlackBoxOp::ToRadix serde::Deserializable<Program::BlackBoxOp::ToRadix>
Program::BlackBoxOp::ToRadix obj;
obj.input = serde::Deserializable<decltype(obj.input)>::deserialize(deserializer);
obj.radix = serde::Deserializable<decltype(obj.radix)>::deserialize(deserializer);
obj.output = serde::Deserializable<decltype(obj.output)>::deserialize(deserializer);
obj.output_pointer = serde::Deserializable<decltype(obj.output_pointer)>::deserialize(deserializer);
obj.num_limbs = serde::Deserializable<decltype(obj.num_limbs)>::deserialize(deserializer);
obj.output_bits = serde::Deserializable<decltype(obj.output_bits)>::deserialize(deserializer);
return obj;
}
Expand Down
5 changes: 3 additions & 2 deletions acvm-repo/brillig/src/black_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ pub enum BlackBoxOp {
ToRadix {
input: MemoryAddress,
radix: MemoryAddress,
output: HeapArray,
output_bits: bool,
output_pointer: MemoryAddress,
num_limbs: MemoryAddress,
output_bits: MemoryAddress,
},
}
16 changes: 11 additions & 5 deletions acvm-repo/brillig_vm/src/black_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@
to_u8_vec(read_heap_array(memory, key)).try_into().map_err(|_| {
BlackBoxResolutionError::Failed(bb_func, "Invalid key length".to_string())
})?;
let ciphertext = aes128_encrypt(&inputs, iv, key)?;

Check warning on line 62 in acvm-repo/brillig_vm/src/black_box.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (ciphertext)

memory.write(outputs.size, ciphertext.len().into());

Check warning on line 64 in acvm-repo/brillig_vm/src/black_box.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (ciphertext)
memory.write_slice(memory.read_ref(outputs.pointer), &to_value_vec(&ciphertext));

Check warning on line 65 in acvm-repo/brillig_vm/src/black_box.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (ciphertext)

Ok(())
}
Expand Down Expand Up @@ -310,21 +310,27 @@
memory.write_slice(memory.read_ref(output.pointer), &state);
Ok(())
}
BlackBoxOp::ToRadix { input, radix, output, output_bits } => {
BlackBoxOp::ToRadix { input, radix, output_pointer, num_limbs, output_bits } => {
let input: F = *memory.read(*input).extract_field().expect("ToRadix input not a field");
let radix = memory
.read(*radix)
.expect_integer_with_bit_size(IntegerBitSize::U32)
.expect("ToRadix opcode's radix bit size does not match expected bit size 32");
let num_limbs = memory.read(*num_limbs).to_usize();
let output_bits = !memory
.read(*output_bits)
.expect_integer_with_bit_size(IntegerBitSize::U1)
.expect("ToRadix opcode's output_bits size does not match expected bit size 1")
.is_zero();

let mut input = BigUint::from_bytes_be(&input.to_be_bytes());
let radix = BigUint::from_bytes_be(&radix.to_be_bytes());

let mut limbs: Vec<MemoryValue<F>> = vec![MemoryValue::default(); output.size];
let mut limbs: Vec<MemoryValue<F>> = vec![MemoryValue::default(); num_limbs];

for i in (0..output.size).rev() {
for i in (0..num_limbs).rev() {
let limb = &input % &radix;
if *output_bits {
if output_bits {
limbs[i] = MemoryValue::new_integer(
if limb.is_zero() { 0 } else { 1 },
IntegerBitSize::U1,
Expand All @@ -336,7 +342,7 @@
input /= &radix;
}

memory.write_slice(memory.read_ref(output.pointer), &limbs);
memory.write_slice(memory.read_ref(*output_pointer), &limbs);

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0"
},
"dependencies": {
"@aztec/bb.js": "0.66.0",
"@aztec/bb.js": "0.67.1",
"@noir-lang/noir_js": "workspace:*",
"@noir-lang/noir_wasm": "workspace:*",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,27 @@ impl<F: AcirField + DebugToString, Registers: RegisterAllocator> BrilligContext<
assert!(source_field.bit_size == F::max_num_bits());
assert!(radix.bit_size == 32);

let bits_register = self.make_constant_instruction(output_bits.into(), 1);
self.codegen_initialize_array(target_array);

let heap_array = self.codegen_brillig_array_to_heap_array(target_array);
let pointer = self.codegen_make_array_items_pointer(target_array);
let num_limbs = self.make_usize_constant_instruction(target_array.size.into());

// Perform big-endian ToRadix
self.black_box_op_instruction(BlackBoxOp::ToRadix {
input: source_field.address,
radix: radix.address,
output: heap_array,
output_bits,
output_pointer: pointer,
num_limbs: num_limbs.address,
output_bits: bits_register.address,
});

if little_endian {
let items_len = self.make_usize_constant_instruction(target_array.size.into());
self.codegen_array_reverse(heap_array.pointer, items_len.address);
self.codegen_array_reverse(pointer, items_len.address);
self.deallocate_single_addr(items_len);
}
self.deallocate_register(heap_array.pointer);
self.deallocate_register(pointer);
self.deallocate_single_addr(bits_register);
self.deallocate_single_addr(num_limbs);
}
}
7 changes: 4 additions & 3 deletions compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
result_pointer: MemoryAddress,
constant: F,
) {
debug_println!(self.enable_debug_trace, " ICONST {} = {}", result_pointer, constant);

Check warning on line 167 in compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (ICONST)
}

/// Processes a not instruction. Append with "_" as this is a high-level instruction.
Expand Down Expand Up @@ -397,13 +397,14 @@
output
);
}
BlackBoxOp::ToRadix { input, radix, output, output_bits: _ } => {
BlackBoxOp::ToRadix { input, radix, output_pointer, num_limbs, output_bits: _ } => {
debug_println!(
self.enable_debug_trace,
" TO_RADIX {} {} -> {}",
" TO_RADIX {} {} {} -> {}",
input,
radix,
output
num_limbs,
output_pointer
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ impl DependencyContext {
Value::Function(callee) => match all_functions[callee].runtime() {
RuntimeType::Brillig(_) => {
// Record arguments/results for each Brillig call for the check

self.tainted.insert(
*instruction,
BrilligTaintedIds::new(&arguments, &results),
Expand Down
1 change: 1 addition & 0 deletions compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ impl<'f> Context<'f> {
let argument_type = self.inserter.function.dfg.type_of_value(field);

let cast = Instruction::Cast(condition, argument_type.unwrap_numeric());

let casted_condition = self.insert_instruction(cast, call_stack);
let field = self.insert_instruction(
Instruction::binary(BinaryOp::Mul, field, casted_condition),
Expand Down
2 changes: 1 addition & 1 deletion scripts/install_bb.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

VERSION="0.66.0"
VERSION="0.67.1"

BBUP_PATH=~/.bb/bbup

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This circuit aggregates two Honk proof from `assert_statement`.
global SIZE_OF_PROOF_IF_LOGN_IS_28: u32 = 463;
global SIZE_OF_PROOF_IF_LOGN_IS_28: u32 = 459;
global HONK_IDENTIFIER: u32 = 1;
fn main(
verification_key: [Field; 128],
Expand Down
4 changes: 2 additions & 2 deletions test_programs/execution_success/verify_honk_proof/Prover.toml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This circuit aggregates a single Honk proof from `assert_statement`.
global SIZE_OF_PROOF_IF_LOGN_IS_28: u32 = 463;
global SIZE_OF_PROOF_IF_LOGN_IS_28: u32 = 459;
global HONK_IDENTIFIER: u32 = 1;
fn main(
verification_key: [Field; 128],
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ __metadata:
languageName: node
linkType: hard

"@aztec/bb.js@npm:0.66.0":
version: 0.66.0
resolution: "@aztec/bb.js@npm:0.66.0"
"@aztec/bb.js@npm:0.67.1":
version: 0.67.1
resolution: "@aztec/bb.js@npm:0.67.1"
dependencies:
comlink: ^4.4.1
commander: ^10.0.1
Expand All @@ -233,7 +233,7 @@ __metadata:
tslib: ^2.4.0
bin:
bb.js: dest/node/main.js
checksum: 7295bf6543afe1c2db795a95c7ed40806de63c77e44bb4dacb2ec6a9171d1d34749150844ab47bc2499d06676e623acb408857b6aa9da702d3c576efadb8c906
checksum: 1df1968fa83a867d920c70e8b5aceaa371e68c71651f05f543b7231cb1be1f2be449adc6cdb6b52ff0ed0f972d74289bcb3ff129334a4d0e8f853cd267625634
languageName: node
linkType: hard

Expand Down Expand Up @@ -14124,7 +14124,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "integration-tests@workspace:compiler/integration-tests"
dependencies:
"@aztec/bb.js": 0.66.0
"@aztec/bb.js": 0.67.1
"@noir-lang/noir_js": "workspace:*"
"@noir-lang/noir_wasm": "workspace:*"
"@nomicfoundation/hardhat-chai-matchers": ^2.0.0
Expand Down
Loading