Skip to content

Commit

Permalink
fix: Validate EthAddress size in aztec-nr (#5198)
Browse files Browse the repository at this point in the history
Ensure the field element backing an EthAddress in aztec-nr is no larger
than 20 bytes.
  • Loading branch information
spalladino authored Mar 13, 2024
1 parent 037a38f commit 201c5e1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ contract ContractInstanceDeployer {
universal_deploy: bool
) {
// TODO(@spalladino): assert nullifier_exists silo(contract_class_id, ContractClassRegisterer)
// TODO(@spalladino): assert is_valid_eth_address(portal_contract_address)

// TODO(#4434) Add deployer field to instance calculation
// let deployer = if universal_deploy { Field::zero() } else { context.msg_sender() };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ impl Serialize<ETH_ADDRESS_LENGTH> for EthAddress {

impl Deserialize<ETH_ADDRESS_LENGTH> for EthAddress {
fn deserialize(fields: [Field; ETH_ADDRESS_LENGTH]) -> Self {
Self {
inner: fields[0]
}
EthAddress::from_field(fields[0])
}
}

Expand All @@ -47,6 +45,7 @@ impl EthAddress {
}

pub fn from_field(field: Field) -> Self {
field.assert_max_bit_size(160);
Self { inner: field }
}

Expand Down

0 comments on commit 201c5e1

Please sign in to comment.