Skip to content

Commit

Permalink
Performs extra check on isEIP55Address (spruceid#123)
Browse files Browse the repository at this point in the history
* Checks address length

* Update check
  • Loading branch information
w4ll3 authored Oct 10, 2022
1 parent 4b775d1 commit de72a5b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/siwe-parser/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { bytesToHex } from '@noble/hashes/utils';
* @returns Either the return is or not in the EIP-55 format.
*/
export const isEIP55Address = (address: string) => {
if(address.length != 42) {
return false;
}

const lowerAddress = `${address}`.toLowerCase().replace('0x', '');
var hash = bytesToHex(keccak_256(lowerAddress));
var ret = '0x';
Expand Down

0 comments on commit de72a5b

Please sign in to comment.