Skip to content

Commit

Permalink
🐛 Fix out of bound encode
Browse files Browse the repository at this point in the history
  • Loading branch information
cairoeth committed Jan 12, 2024
1 parent cecab44 commit cfd36de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/auth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#[allow(clippy::module_inception)]
pub mod auth;
pub mod owned;
pub mod owned;
4 changes: 2 additions & 2 deletions src/tokens/erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type Result<T, E = ERC20Error> = core::result::Result<T, E>;

impl<T: ERC20Params> ERC20<T> {
pub fn compute_domain_separator() -> Result<B256> {
let mut digest_input = [0u8; 32 + 32];
let mut digest_input = [0u8; 160];
digest_input[0..32].copy_from_slice(&crypto::keccak("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)".as_bytes())[..]);
digest_input[32..64].copy_from_slice(&crypto::keccak(T::NAME.as_bytes())[..]);
digest_input[64..96].copy_from_slice(&crypto::keccak("1".as_bytes())[..]);
Expand Down Expand Up @@ -228,7 +228,7 @@ impl<T: ERC20Params> ERC20<T> {
let nonce = nonce_setter.get();
nonce_setter.set(nonce + U256::from(1));

let mut struct_hash = [0u8; 32 + 32];
let mut struct_hash = [0u8; 192];
struct_hash[0..32].copy_from_slice(&crypto::keccak(b"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)")[..]);
struct_hash[32..64].copy_from_slice(&owner[..]);
struct_hash[64..96].copy_from_slice(&spender[..]);
Expand Down

0 comments on commit cfd36de

Please sign in to comment.