Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl LogEncryption for AES128 {
let ciphertext_without_eph_pk_x = bytes_from_fields(ciphertext_without_eph_pk_x_fields);

// First byte of the ciphertext represents the ephemeral public key sign
let eph_pk_sign_bool = ciphertext_without_eph_pk_x.get(0) as bool;
let eph_pk_sign_bool = ciphertext_without_eph_pk_x.get(0) != 0;
// With the sign and the x-coordinate of the ephemeral public key, we can reconstruct the point
let eph_pk = point_from_x_coord_and_sign(eph_pk_x, eph_pk_sign_bool);

Expand Down
2 changes: 1 addition & 1 deletion noir-projects/aztec-nr/aztec/src/note/retrieved_note.nr
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ where
{
let contract_address = AztecAddress::from_field(packed_retrieved_note[0]);
let nonce = packed_retrieved_note[1];
let nonzero_note_hash_counter = packed_retrieved_note[2] as bool;
let nonzero_note_hash_counter = (packed_retrieved_note[2] as u1) != 0;

let packed_note = subarray(packed_retrieved_note, RETRIEVED_NOTE_OVERHEAD);
let note = NOTE::unpack(packed_note);
Expand Down
14 changes: 4 additions & 10 deletions noir-projects/aztec-nr/aztec/src/oracle/keys.nr
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,10 @@ pub unconstrained fn get_public_keys_and_partial_address(
let result = get_public_keys_and_partial_address_oracle(address);

let keys = PublicKeys {
npk_m: NpkM { inner: Point { x: result[0], y: result[1], is_infinite: result[2] as bool } },
ivpk_m: IvpkM {
inner: Point { x: result[3], y: result[4], is_infinite: result[5] as bool },
},
ovpk_m: OvpkM {
inner: Point { x: result[6], y: result[7], is_infinite: result[8] as bool },
},
tpk_m: TpkM {
inner: Point { x: result[9], y: result[10], is_infinite: result[11] as bool },
},
npk_m: NpkM { inner: Point { x: result[0], y: result[1], is_infinite: result[2] != 0 } },
ivpk_m: IvpkM { inner: Point { x: result[3], y: result[4], is_infinite: result[5] != 0 } },
ovpk_m: OvpkM { inner: Point { x: result[6], y: result[7], is_infinite: result[8] != 0 } },
tpk_m: TpkM { inner: Point { x: result[9], y: result[10], is_infinite: result[11] != 0 } },
};

let partial_address = PartialAddress::from_field(result[12]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ impl Serialize<3> for UserFlags {
// after having received the serialized value as a return-value
impl Deserialize<3> for UserFlags {
fn deserialize(fields: [Field; 3]) -> Self {
Self {
is_admin: fields[0] as bool,
is_minter: fields[1] as bool,
is_blacklisted: fields[2] as bool,
}
Self { is_admin: fields[0] != 0, is_minter: fields[1] != 0, is_blacklisted: fields[2] != 0 }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl Deserialize<AVM_CIRCUIT_PUBLIC_INPUTS_LENGTH> for AvmCircuitPublicInputs {
),
accumulated_data: reader.read_struct(AvmAccumulatedData::deserialize),
transaction_fee: reader.read(),
reverted: reader.read() as bool,
reverted: reader.read_bool(),
};
reader.finish();
item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Deserialize<CALL_CONTEXT_LENGTH> for CallContext {
msg_sender: AztecAddress::from_field(reader.read()),
contract_address: AztecAddress::from_field(reader.read()),
function_selector: FunctionSelector::from_field(reader.read()),
is_static_call: reader.read() as bool,
is_static_call: reader.read_bool(),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Deserialize<FUNCTION_DATA_LENGTH> for FunctionData {
fn deserialize(serialized: [Field; FUNCTION_DATA_LENGTH]) -> Self {
Self {
selector: FunctionSelector::from_field(serialized[0]),
is_private: serialized[1] as bool,
is_private: serialized[1] != 0,
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Serialize<MAX_BLOCK_NUMBER_LENGTH> for MaxBlockNumber {
impl Deserialize<MAX_BLOCK_NUMBER_LENGTH> for MaxBlockNumber {
fn deserialize(serialized: [Field; MAX_BLOCK_NUMBER_LENGTH]) -> MaxBlockNumber {
MaxBlockNumber {
_opt: if serialized[0] as bool {
_opt: if serialized[0] != 0 {
Option::some(serialized[1] as u32)
} else {
Option::none()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Deserialize<PUBLIC_CALL_REQUEST_LENGTH> for PublicCallRequest {
let request = PublicCallRequest {
msg_sender: AztecAddress::from_field(reader.read()),
contract_address: AztecAddress::from_field(reader.read()),
is_static_call: reader.read() as bool,
is_static_call: reader.read_bool(),
calldata_hash: reader.read(),
};
reader.finish();
Expand Down Expand Up @@ -119,7 +119,7 @@ impl Deserialize<NUM_PUBLIC_CALL_REQUEST_ARRAYS> for PublicCallRequestArrayLengt
let item = PublicCallRequestArrayLengths {
setup_calls: reader.read_u32(),
app_logic_calls: reader.read_u32(),
teardown_call: reader.read() as bool,
teardown_call: reader.read_bool(),
};

reader.finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl Deserialize<SPONGE_BLOB_LENGTH> for SpongeBlob {
cache: [fields[0], fields[1], fields[2]],
state: [fields[3], fields[4], fields[5], fields[6]],
cache_size: fields[7] as u32,
squeeze_mode: fields[8] as bool,
squeeze_mode: fields[8] != 0,
},
fields: fields[9] as u32,
expected_fields: fields[10] as u32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl Serialize<KEY_VALIDATION_REQUEST_LENGTH> for KeyValidationRequest {
impl Deserialize<KEY_VALIDATION_REQUEST_LENGTH> for KeyValidationRequest {
fn deserialize(fields: [Field; KEY_VALIDATION_REQUEST_LENGTH]) -> Self {
Self {
pk_m: Point { x: fields[0], y: fields[1], is_infinite: fields[2] as bool },
pk_m: Point { x: fields[0], y: fields[1], is_infinite: fields[2] != 0 },
sk_app: fields[3],
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ pub comptime fn generate_deserialize_from_fields(
result = quote { $unpack_method([ $packed_fields ]) };

consumed_counter = packed_len;
} else if typ.is_field() | typ.as_integer().is_some() | typ.is_bool() {
} else if typ.is_bool() {
// The field is a primitive so we just reference it in the field array
result = quote { $field_array_name[$num_already_consumed] != 0 };
consumed_counter = 1;
} else if typ.is_field() | typ.as_integer().is_some() {
// The field is a primitive so we just reference it in the field array
result = quote { $field_array_name[$num_already_consumed] as $typ };
consumed_counter = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Empty for Point {

impl Deserialize<POINT_LENGTH> for Point {
fn deserialize(serialized: [Field; POINT_LENGTH]) -> Point {
Point { x: serialized[0], y: serialized[1], is_infinite: serialized[2] as bool }
Point { x: serialized[0], y: serialized[1], is_infinite: serialized[2] != 0 }
}
}
// TODO(#11356): use compact representation here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,28 +165,28 @@ impl Deserialize<PUBLIC_KEYS_LENGTH> for PublicKeys {
inner: Point {
x: serialized[0],
y: serialized[1],
is_infinite: serialized[2] as bool,
is_infinite: serialized[2] != 0,
},
},
ivpk_m: IvpkM {
inner: Point {
x: serialized[3],
y: serialized[4],
is_infinite: serialized[5] as bool,
is_infinite: serialized[5] != 0,
},
},
ovpk_m: OvpkM {
inner: Point {
x: serialized[6],
y: serialized[7],
is_infinite: serialized[8] as bool,
is_infinite: serialized[8] != 0,
},
},
tpk_m: TpkM {
inner: Point {
x: serialized[9],
y: serialized[10],
is_infinite: serialized[11] as bool,
is_infinite: serialized[11] != 0,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ pub fn unpack_delay_change<let INITIAL_DELAY: u32>(
let sdc_block_of_change = tmp as u32;

tmp = (tmp - sdc_block_of_change as Field) / TWO_POW_32;
let sdc_post_is_some = tmp as bool;
let sdc_post_is_some = (tmp as u1) != 0;

tmp = (tmp - sdc_post_is_some as Field) / TWO_POW_8;
let sdc_post_inner = tmp as u32;

tmp = (tmp - sdc_post_inner as Field) / TWO_POW_32;
let sdc_pre_is_some = tmp as bool;
let sdc_pre_is_some = (tmp as u1) != 0;

tmp = (tmp - sdc_pre_is_some as Field) / TWO_POW_8;
let sdc_pre_inner = tmp as u32;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl FromField for Field {
impl FromField for bool {
#[inline_always]
fn from_field(value: Field) -> Self {
value as bool
value != 0
}
}
impl FromField for u1 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl Packable<BOOL_PACKED_LEN> for bool {
}

fn unpack(fields: [Field; BOOL_PACKED_LEN]) -> bool {
fields[0] as bool
(fields[0] as u1) != 0
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Serialize<BOOL_SERIALIZED_LEN> for bool {

impl Deserialize<BOOL_SERIALIZED_LEN> for bool {
fn deserialize(fields: [Field; BOOL_SERIALIZED_LEN]) -> bool {
fields[0] as bool
fields[0] != 0
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl<let N: u32> Reader<N> {
}

pub fn read_bool(&mut self) -> bool {
self.read() as bool
self.read() != 0
}

pub fn read_array<let K: u32>(&mut self) -> [Field; K] {
Expand Down