This repository was archived by the owner on Oct 1, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,12 @@ export class AwsKmsSigner extends ethers.Signer {
2020 }
2121
2222 async getAddress ( ) : Promise < string > {
23+ console . log ( "getting Address" ) ;
2324 if ( this . ethereumAddress === undefined ) {
25+ console . log ( "ethAddress is undefined" ) ;
2426 const key = await getPublicKey ( this . kmsCredentials ) ;
25- this . ethereumAddress = getEthereumAddress ( key . PublicKey as Buffer ) ;
27+ console . log ( "received public key" ) ;
28+ this . ethereumAddress = getEthereumAddress ( Buffer . from ( key . PublicKey ) ) ;
2629 }
2730 return Promise . resolve ( this . ethereumAddress ) ;
2831 }
Original file line number Diff line number Diff line change @@ -49,14 +49,21 @@ export function getEthereumAddress(publicKey: Buffer): string {
4949 // I used https://lapo.it/asn1js to figure out how to parse this
5050 // and defined the schema in the EcdsaPubKey object
5151 const res = EcdsaPubKey . decode ( publicKey , "der" ) ;
52+
53+ console . log ( "decode success" ) ;
5254 let pubKeyBuffer : Buffer = res . pubKey . data ;
5355
5456 // The public key starts with a 0x04 prefix that needs to be removed
5557 // more info: https://www.oreilly.com/library/view/mastering-ethereum/9781491971932/ch04.html
5658 pubKeyBuffer = pubKeyBuffer . slice ( 1 , pubKeyBuffer . length ) ;
59+ console . log ( "buffer slice success" ) ;
5760
5861 const address = ethers . utils . keccak256 ( pubKeyBuffer ) ; // keccak256 hash of publicKey
62+ console . log ( "keccak success" ) ;
63+
5964 const EthAddr = `0x${ address . slice ( - 40 ) } ` ; // take last 20 bytes as ethereum adress
65+
66+ console . log ( "address slice success" ) ;
6067 return EthAddr ;
6168}
6269
You can’t perform that action at this time.
0 commit comments