Skip to content

Commit 446a8a5

Browse files
committed
Merge branch 'master' into tf/generic-to-radix
* master: feat: Sync from aztec-packages (#5790) feat: add `Expr::resolve` and `TypedExpr::as_function_definition` (#5859) feat: LSP signature help for assert and assert_eq (#5862) fix(sha256): Add extra checks against message size when constructing msg blocks (#5861) feat: show backtrace on comptime assertion failures (#5842) feat: add `Expr::as_assert` (#5857) chore: underconstrained check in parallel (#5848)
2 parents 19aeae7 + 5c4f19f commit 446a8a5

File tree

93 files changed

+2195
-877
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+2195
-877
lines changed

.aztec-sync-commit

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
91042c7bcebfebeb4e629162f44988e2cda1ed41
1+
57f3c9bdc99103862a165bc235efdc8ef01b4e92

Cargo.lock

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ color-eyre = "0.6.2"
154154
rand = "0.8.5"
155155
proptest = "1.2.0"
156156
proptest-derive = "0.4.0"
157+
rayon = "1.8.0"
157158

158159
im = { version = "15.1", features = ["serde"] }
159160
tracing = "0.1.40"

acvm-repo/acir/codegen/acir.cpp

+63-1
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ namespace Program {
464464
Program::MemoryAddress input;
465465
uint32_t radix;
466466
Program::HeapArray output;
467+
bool output_bits;
467468

468469
friend bool operator==(const ToRadix&, const ToRadix&);
469470
std::vector<uint8_t> bincodeSerialize() const;
@@ -635,6 +636,16 @@ namespace Program {
635636
static Const bincodeDeserialize(std::vector<uint8_t>);
636637
};
637638

639+
struct IndirectConst {
640+
Program::MemoryAddress destination_pointer;
641+
Program::BitSize bit_size;
642+
std::string value;
643+
644+
friend bool operator==(const IndirectConst&, const IndirectConst&);
645+
std::vector<uint8_t> bincodeSerialize() const;
646+
static IndirectConst bincodeDeserialize(std::vector<uint8_t>);
647+
};
648+
638649
struct Return {
639650
friend bool operator==(const Return&, const Return&);
640651
std::vector<uint8_t> bincodeSerialize() const;
@@ -716,7 +727,7 @@ namespace Program {
716727
static Stop bincodeDeserialize(std::vector<uint8_t>);
717728
};
718729

719-
std::variant<BinaryFieldOp, BinaryIntOp, Cast, JumpIfNot, JumpIf, Jump, CalldataCopy, Call, Const, Return, ForeignCall, Mov, ConditionalMov, Load, Store, BlackBox, Trap, Stop> value;
730+
std::variant<BinaryFieldOp, BinaryIntOp, Cast, JumpIfNot, JumpIf, Jump, CalldataCopy, Call, Const, IndirectConst, Return, ForeignCall, Mov, ConditionalMov, Load, Store, BlackBox, Trap, Stop> value;
720731

721732
friend bool operator==(const BrilligOpcode&, const BrilligOpcode&);
722733
std::vector<uint8_t> bincodeSerialize() const;
@@ -933,6 +944,7 @@ namespace Program {
933944
std::vector<Program::FunctionInput> proof;
934945
std::vector<Program::FunctionInput> public_inputs;
935946
Program::FunctionInput key_hash;
947+
uint32_t proof_type;
936948

937949
friend bool operator==(const RecursiveAggregation&, const RecursiveAggregation&);
938950
std::vector<uint8_t> bincodeSerialize() const;
@@ -3149,6 +3161,7 @@ namespace Program {
31493161
if (!(lhs.proof == rhs.proof)) { return false; }
31503162
if (!(lhs.public_inputs == rhs.public_inputs)) { return false; }
31513163
if (!(lhs.key_hash == rhs.key_hash)) { return false; }
3164+
if (!(lhs.proof_type == rhs.proof_type)) { return false; }
31523165
return true;
31533166
}
31543167

@@ -3176,6 +3189,7 @@ void serde::Serializable<Program::BlackBoxFuncCall::RecursiveAggregation>::seria
31763189
serde::Serializable<decltype(obj.proof)>::serialize(obj.proof, serializer);
31773190
serde::Serializable<decltype(obj.public_inputs)>::serialize(obj.public_inputs, serializer);
31783191
serde::Serializable<decltype(obj.key_hash)>::serialize(obj.key_hash, serializer);
3192+
serde::Serializable<decltype(obj.proof_type)>::serialize(obj.proof_type, serializer);
31793193
}
31803194

31813195
template <>
@@ -3186,6 +3200,7 @@ Program::BlackBoxFuncCall::RecursiveAggregation serde::Deserializable<Program::B
31863200
obj.proof = serde::Deserializable<decltype(obj.proof)>::deserialize(deserializer);
31873201
obj.public_inputs = serde::Deserializable<decltype(obj.public_inputs)>::deserialize(deserializer);
31883202
obj.key_hash = serde::Deserializable<decltype(obj.key_hash)>::deserialize(deserializer);
3203+
obj.proof_type = serde::Deserializable<decltype(obj.proof_type)>::deserialize(deserializer);
31893204
return obj;
31903205
}
31913206

@@ -4525,6 +4540,7 @@ namespace Program {
45254540
if (!(lhs.input == rhs.input)) { return false; }
45264541
if (!(lhs.radix == rhs.radix)) { return false; }
45274542
if (!(lhs.output == rhs.output)) { return false; }
4543+
if (!(lhs.output_bits == rhs.output_bits)) { return false; }
45284544
return true;
45294545
}
45304546

@@ -4551,6 +4567,7 @@ void serde::Serializable<Program::BlackBoxOp::ToRadix>::serialize(const Program:
45514567
serde::Serializable<decltype(obj.input)>::serialize(obj.input, serializer);
45524568
serde::Serializable<decltype(obj.radix)>::serialize(obj.radix, serializer);
45534569
serde::Serializable<decltype(obj.output)>::serialize(obj.output, serializer);
4570+
serde::Serializable<decltype(obj.output_bits)>::serialize(obj.output_bits, serializer);
45544571
}
45554572

45564573
template <>
@@ -4560,6 +4577,7 @@ Program::BlackBoxOp::ToRadix serde::Deserializable<Program::BlackBoxOp::ToRadix>
45604577
obj.input = serde::Deserializable<decltype(obj.input)>::deserialize(deserializer);
45614578
obj.radix = serde::Deserializable<decltype(obj.radix)>::deserialize(deserializer);
45624579
obj.output = serde::Deserializable<decltype(obj.output)>::deserialize(deserializer);
4580+
obj.output_bits = serde::Deserializable<decltype(obj.output_bits)>::deserialize(deserializer);
45634581
return obj;
45644582
}
45654583

@@ -5382,6 +5400,50 @@ Program::BrilligOpcode::Const serde::Deserializable<Program::BrilligOpcode::Cons
53825400
return obj;
53835401
}
53845402

5403+
namespace Program {
5404+
5405+
inline bool operator==(const BrilligOpcode::IndirectConst &lhs, const BrilligOpcode::IndirectConst &rhs) {
5406+
if (!(lhs.destination_pointer == rhs.destination_pointer)) { return false; }
5407+
if (!(lhs.bit_size == rhs.bit_size)) { return false; }
5408+
if (!(lhs.value == rhs.value)) { return false; }
5409+
return true;
5410+
}
5411+
5412+
inline std::vector<uint8_t> BrilligOpcode::IndirectConst::bincodeSerialize() const {
5413+
auto serializer = serde::BincodeSerializer();
5414+
serde::Serializable<BrilligOpcode::IndirectConst>::serialize(*this, serializer);
5415+
return std::move(serializer).bytes();
5416+
}
5417+
5418+
inline BrilligOpcode::IndirectConst BrilligOpcode::IndirectConst::bincodeDeserialize(std::vector<uint8_t> input) {
5419+
auto deserializer = serde::BincodeDeserializer(input);
5420+
auto value = serde::Deserializable<BrilligOpcode::IndirectConst>::deserialize(deserializer);
5421+
if (deserializer.get_buffer_offset() < input.size()) {
5422+
throw serde::deserialization_error("Some input bytes were not read");
5423+
}
5424+
return value;
5425+
}
5426+
5427+
} // end of namespace Program
5428+
5429+
template <>
5430+
template <typename Serializer>
5431+
void serde::Serializable<Program::BrilligOpcode::IndirectConst>::serialize(const Program::BrilligOpcode::IndirectConst &obj, Serializer &serializer) {
5432+
serde::Serializable<decltype(obj.destination_pointer)>::serialize(obj.destination_pointer, serializer);
5433+
serde::Serializable<decltype(obj.bit_size)>::serialize(obj.bit_size, serializer);
5434+
serde::Serializable<decltype(obj.value)>::serialize(obj.value, serializer);
5435+
}
5436+
5437+
template <>
5438+
template <typename Deserializer>
5439+
Program::BrilligOpcode::IndirectConst serde::Deserializable<Program::BrilligOpcode::IndirectConst>::deserialize(Deserializer &deserializer) {
5440+
Program::BrilligOpcode::IndirectConst obj;
5441+
obj.destination_pointer = serde::Deserializable<decltype(obj.destination_pointer)>::deserialize(deserializer);
5442+
obj.bit_size = serde::Deserializable<decltype(obj.bit_size)>::deserialize(deserializer);
5443+
obj.value = serde::Deserializable<decltype(obj.value)>::deserialize(deserializer);
5444+
return obj;
5445+
}
5446+
53855447
namespace Program {
53865448

53875449
inline bool operator==(const BrilligOpcode::Return &lhs, const BrilligOpcode::Return &rhs) {

acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs

+2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ pub enum BlackBoxFuncCall<F> {
159159
/// The circuit implementing this opcode can use this hash to ensure that the
160160
/// key provided to the circuit matches the key produced by the circuit creator
161161
key_hash: FunctionInput<F>,
162+
proof_type: u32,
162163
},
163164
BigIntAdd {
164165
lhs: u32,
@@ -350,6 +351,7 @@ impl<F: Copy> BlackBoxFuncCall<F> {
350351
proof,
351352
public_inputs,
352353
key_hash,
354+
proof_type: _,
353355
} => {
354356
let mut inputs = Vec::new();
355357
inputs.extend(key.iter().copied());

acvm-repo/acir/tests/test_program_serialization.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ fn simple_brillig_foreign_call() {
204204
let bytes = Program::serialize_program(&program);
205205

206206
let expected_serialization: Vec<u8> = vec![
207-
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 173, 80, 49, 10, 192, 32, 12, 52, 45, 45, 165, 155, 63,
208-
209, 31, 248, 25, 7, 23, 7, 17, 223, 175, 96, 2, 65, 162, 139, 30, 132, 203, 221, 65, 72,
209-
2, 170, 227, 107, 5, 216, 63, 200, 164, 57, 200, 115, 200, 102, 15, 22, 206, 205, 50, 124,
210-
223, 107, 108, 128, 155, 106, 113, 217, 141, 252, 10, 25, 225, 103, 121, 136, 197, 167,
211-
188, 250, 213, 76, 75, 158, 22, 178, 10, 176, 188, 242, 119, 164, 1, 0, 0,
207+
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 173, 80, 49, 10, 192, 32, 12, 52, 45, 45, 133, 110, 190,
208+
68, 127, 224, 103, 28, 92, 28, 68, 124, 191, 130, 9, 4, 137, 46, 122, 16, 46, 119, 7, 33,
209+
9, 168, 142, 175, 21, 96, 255, 32, 147, 230, 32, 207, 33, 155, 61, 88, 56, 55, 203, 240,
210+
125, 175, 177, 1, 110, 170, 197, 101, 55, 242, 43, 100, 132, 159, 229, 33, 22, 159, 242,
211+
234, 87, 51, 45, 121, 90, 200, 42, 48, 209, 35, 111, 164, 1, 0, 0,
212212
];
213213

214214
assert_eq!(bytes, expected_serialization)
@@ -307,15 +307,15 @@ fn complex_brillig_foreign_call() {
307307

308308
let bytes = Program::serialize_program(&program);
309309
let expected_serialization: Vec<u8> = vec![
310-
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 213, 84, 75, 10, 132, 48, 12, 77, 90, 199, 145, 217,
311-
205, 13, 6, 102, 14, 208, 241, 4, 222, 69, 220, 41, 186, 244, 248, 90, 140, 24, 159, 5, 23,
312-
86, 208, 7, 37, 253, 228, 243, 146, 144, 50, 77, 200, 198, 197, 178, 127, 136, 52, 34, 253,
313-
189, 165, 53, 102, 221, 66, 164, 59, 134, 63, 199, 243, 229, 206, 226, 104, 110, 192, 209,
314-
158, 192, 145, 84, 255, 47, 216, 239, 152, 125, 137, 90, 63, 27, 152, 159, 132, 166, 249,
315-
74, 229, 252, 20, 153, 97, 161, 189, 145, 161, 237, 224, 173, 128, 19, 235, 189, 126, 192,
316-
17, 97, 4, 177, 75, 162, 101, 154, 187, 84, 113, 97, 136, 255, 82, 89, 150, 109, 211, 213,
317-
85, 111, 65, 21, 233, 126, 213, 254, 7, 239, 12, 118, 104, 171, 161, 63, 176, 144, 46, 7,
318-
244, 246, 124, 191, 105, 41, 241, 92, 246, 1, 235, 222, 207, 212, 69, 5, 0, 0,
310+
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 213, 84, 75, 10, 132, 48, 12, 77, 90, 199, 17, 102, 55,
311+
39, 24, 152, 57, 64, 199, 19, 120, 23, 113, 167, 232, 210, 227, 107, 49, 98, 124, 22, 92,
312+
88, 65, 31, 148, 244, 147, 207, 75, 66, 202, 52, 33, 27, 23, 203, 254, 33, 210, 136, 244,
313+
247, 150, 214, 152, 117, 11, 145, 238, 24, 254, 28, 207, 151, 59, 139, 163, 185, 1, 71,
314+
123, 2, 71, 82, 253, 191, 96, 191, 99, 246, 37, 106, 253, 108, 96, 126, 18, 154, 230, 43,
315+
149, 243, 83, 100, 134, 133, 246, 70, 134, 182, 131, 183, 2, 78, 172, 247, 250, 1, 71, 132,
316+
17, 196, 46, 137, 150, 105, 238, 82, 197, 133, 33, 254, 75, 101, 89, 182, 77, 87, 87, 189,
317+
5, 85, 164, 251, 85, 251, 31, 188, 51, 216, 161, 173, 134, 254, 192, 66, 186, 28, 208, 219,
318+
243, 253, 166, 165, 196, 115, 217, 7, 253, 216, 100, 109, 69, 5, 0, 0,
319319
];
320320

321321
assert_eq!(bytes, expected_serialization)

acvm-repo/acvm_js/test/shared/complex_foreign_call.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { WitnessMap } from '@noir-lang/acvm_js';
22

33
// See `complex_brillig_foreign_call` integration test in `acir/tests/test_program_serialization.rs`.
44
export const bytecode = Uint8Array.from([
5-
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 213, 84, 75, 10, 132, 48, 12, 77, 90, 199, 145, 217, 205, 13, 6, 102, 14, 208, 241,
6-
4, 222, 69, 220, 41, 186, 244, 248, 90, 140, 24, 159, 5, 23, 86, 208, 7, 37, 253, 228, 243, 146, 144, 50, 77, 200,
7-
198, 197, 178, 127, 136, 52, 34, 253, 189, 165, 53, 102, 221, 66, 164, 59, 134, 63, 199, 243, 229, 206, 226, 104, 110,
8-
192, 209, 158, 192, 145, 84, 255, 47, 216, 239, 152, 125, 137, 90, 63, 27, 152, 159, 132, 166, 249, 74, 229, 252, 20,
9-
153, 97, 161, 189, 145, 161, 237, 224, 173, 128, 19, 235, 189, 126, 192, 17, 97, 4, 177, 75, 162, 101, 154, 187, 84,
10-
113, 97, 136, 255, 82, 89, 150, 109, 211, 213, 85, 111, 65, 21, 233, 126, 213, 254, 7, 239, 12, 118, 104, 171, 161,
11-
63, 176, 144, 46, 7, 244, 246, 124, 191, 105, 41, 241, 92, 246, 1, 235, 222, 207, 212, 69, 5, 0, 0,
5+
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 213, 84, 75, 10, 132, 48, 12, 77, 90, 199, 17, 102, 55, 39, 24, 152, 57, 64, 199,
6+
19, 120, 23, 113, 167, 232, 210, 227, 107, 49, 98, 124, 22, 92, 88, 65, 31, 148, 244, 147, 207, 75, 66, 202, 52, 33,
7+
27, 23, 203, 254, 33, 210, 136, 244, 247, 150, 214, 152, 117, 11, 145, 238, 24, 254, 28, 207, 151, 59, 139, 163, 185,
8+
1, 71, 123, 2, 71, 82, 253, 191, 96, 191, 99, 246, 37, 106, 253, 108, 96, 126, 18, 154, 230, 43, 149, 243, 83, 100,
9+
134, 133, 246, 70, 134, 182, 131, 183, 2, 78, 172, 247, 250, 1, 71, 132, 17, 196, 46, 137, 150, 105, 238, 82, 197,
10+
133, 33, 254, 75, 101, 89, 182, 77, 87, 87, 189, 5, 85, 164, 251, 85, 251, 31, 188, 51, 216, 161, 173, 134, 254, 192,
11+
66, 186, 28, 208, 219, 243, 253, 166, 165, 196, 115, 217, 7, 253, 216, 100, 109, 69, 5, 0, 0,
1212
]);
1313
export const initialWitnessMap: WitnessMap = new Map([
1414
[1, '0x0000000000000000000000000000000000000000000000000000000000000001'],

acvm-repo/acvm_js/test/shared/foreign_call.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { WitnessMap } from '@noir-lang/acvm_js';
22

33
// See `simple_brillig_foreign_call` integration test in `acir/tests/test_program_serialization.rs`.
44
export const bytecode = Uint8Array.from([
5-
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 173, 80, 49, 10, 192, 32, 12, 52, 45, 45, 165, 155, 63, 209, 31, 248, 25, 7, 23, 7,
6-
17, 223, 175, 96, 2, 65, 162, 139, 30, 132, 203, 221, 65, 72, 2, 170, 227, 107, 5, 216, 63, 200, 164, 57, 200, 115,
7-
200, 102, 15, 22, 206, 205, 50, 124, 223, 107, 108, 128, 155, 106, 113, 217, 141, 252, 10, 25, 225, 103, 121, 136,
8-
197, 167, 188, 250, 213, 76, 75, 158, 22, 178, 10, 176, 188, 242, 119, 164, 1, 0, 0,
5+
31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 173, 80, 49, 10, 192, 32, 12, 52, 45, 45, 133, 110, 190, 68, 127, 224, 103, 28, 92,
6+
28, 68, 124, 191, 130, 9, 4, 137, 46, 122, 16, 46, 119, 7, 33, 9, 168, 142, 175, 21, 96, 255, 32, 147, 230, 32, 207,
7+
33, 155, 61, 88, 56, 55, 203, 240, 125, 175, 177, 1, 110, 170, 197, 101, 55, 242, 43, 100, 132, 159, 229, 33, 22, 159,
8+
242, 234, 87, 51, 45, 121, 90, 200, 42, 48, 209, 35, 111, 164, 1, 0, 0,
99
]);
1010
export const initialWitnessMap: WitnessMap = new Map([
1111
[1, '0x0000000000000000000000000000000000000000000000000000000000000005'],

acvm-repo/brillig/src/black_box.rs

+1
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@ pub enum BlackBoxOp {
132132
input: MemoryAddress,
133133
radix: u32,
134134
output: HeapArray,
135+
output_bits: bool,
135136
},
136137
}

acvm-repo/brillig/src/opcodes.rs

+5
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ pub enum BrilligOpcode<F> {
223223
bit_size: BitSize,
224224
value: F,
225225
},
226+
IndirectConst {
227+
destination_pointer: MemoryAddress,
228+
bit_size: BitSize,
229+
value: F,
230+
},
226231
Return,
227232
/// Used to get data from an outside source.
228233
/// Also referred to as an Oracle. However, we don't use that name as

acvm-repo/brillig_vm/src/black_box.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
use acir::brillig::{BlackBoxOp, HeapArray, HeapVector};
1+
use acir::brillig::{BlackBoxOp, HeapArray, HeapVector, IntegerBitSize};
22
use acir::{AcirField, BlackBoxFunc};
33
use acvm_blackbox_solver::BigIntSolver;
44
use acvm_blackbox_solver::{
55
aes128_encrypt, blake2s, blake3, ecdsa_secp256k1_verify, ecdsa_secp256r1_verify, keccak256,
66
keccakf1600, sha256, sha256compression, BlackBoxFunctionSolver, BlackBoxResolutionError,
77
};
88
use num_bigint::BigUint;
9+
use num_traits::Zero;
910

1011
use crate::memory::MemoryValue;
1112
use crate::Memory;
@@ -366,7 +367,7 @@ pub(crate) fn evaluate_black_box<F: AcirField, Solver: BlackBoxFunctionSolver<F>
366367
memory.write_slice(memory.read_ref(output.pointer), &state);
367368
Ok(())
368369
}
369-
BlackBoxOp::ToRadix { input, radix, output } => {
370+
BlackBoxOp::ToRadix { input, radix, output, output_bits } => {
370371
let input: F = *memory.read(*input).extract_field().expect("ToRadix input not a field");
371372

372373
let mut input = BigUint::from_bytes_be(&input.to_be_bytes());
@@ -376,7 +377,15 @@ pub(crate) fn evaluate_black_box<F: AcirField, Solver: BlackBoxFunctionSolver<F>
376377

377378
for _ in 0..output.size {
378379
let limb = &input % &radix;
379-
limbs.push(MemoryValue::new_field(F::from_be_bytes_reduce(&limb.to_bytes_be())));
380+
if *output_bits {
381+
limbs.push(MemoryValue::new_integer(
382+
if limb.is_zero() { 0 } else { 1 },
383+
IntegerBitSize::U1,
384+
));
385+
} else {
386+
let limb: u8 = limb.try_into().unwrap();
387+
limbs.push(MemoryValue::new_integer(limb as u128, IntegerBitSize::U8));
388+
};
380389
input /= &radix;
381390
}
382391

acvm-repo/brillig_vm/src/lib.rs

+35
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,13 @@ impl<'a, F: AcirField, B: BlackBoxFunctionSolver<F>> VM<'a, F, B> {
339339
self.memory.write(*destination, MemoryValue::new_from_field(*value, *bit_size));
340340
self.increment_program_counter()
341341
}
342+
Opcode::IndirectConst { destination_pointer, bit_size, value } => {
343+
// Convert our destination_pointer to an address
344+
let destination = self.memory.read_ref(*destination_pointer);
345+
// Use our usize destination index to set the value in memory
346+
self.memory.write(destination, MemoryValue::new_from_field(*value, *bit_size));
347+
self.increment_program_counter()
348+
}
342349
Opcode::BlackBox(black_box_op) => {
343350
match evaluate_black_box(
344351
black_box_op,
@@ -1189,6 +1196,34 @@ mod tests {
11891196
assert_eq!(memory, expected);
11901197
}
11911198

1199+
#[test]
1200+
fn iconst_opcode() {
1201+
let opcodes = &[
1202+
Opcode::Const {
1203+
destination: MemoryAddress(0),
1204+
bit_size: BitSize::Integer(MEMORY_ADDRESSING_BIT_SIZE),
1205+
value: FieldElement::from(8_usize),
1206+
},
1207+
Opcode::IndirectConst {
1208+
destination_pointer: MemoryAddress(0),
1209+
bit_size: BitSize::Integer(MEMORY_ADDRESSING_BIT_SIZE),
1210+
value: FieldElement::from(27_usize),
1211+
},
1212+
];
1213+
let mut vm = VM::new(vec![], opcodes, vec![], &StubbedBlackBoxSolver);
1214+
1215+
let status = vm.process_opcode();
1216+
assert_eq!(status, VMStatus::InProgress);
1217+
1218+
let status = vm.process_opcode();
1219+
assert_eq!(status, VMStatus::Finished { return_data_offset: 0, return_data_size: 0 });
1220+
1221+
let VM { memory, .. } = vm;
1222+
1223+
let destination_value = memory.read(MemoryAddress::from(8));
1224+
assert_eq!(destination_value.to_field(), (27_usize).into());
1225+
}
1226+
11921227
#[test]
11931228
fn load_opcode() {
11941229
/// Brillig code for the following:

aztec_macros/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ noirc_frontend.workspace = true
1818
noirc_errors.workspace = true
1919
iter-extended.workspace = true
2020
convert_case = "0.6.0"
21+
im.workspace = true
2122
regex = "1.10"
2223
tiny-keccak = { version = "2.0.0", features = ["keccak"] }

0 commit comments

Comments
 (0)