diff --git a/core/auth/v2/authenticator.go b/core/auth/v2/authenticator.go index ecd8b0ba7..4f507aec8 100644 --- a/core/auth/v2/authenticator.go +++ b/core/auth/v2/authenticator.go @@ -6,6 +6,7 @@ import ( "fmt" core "github.com/Layr-Labs/eigenda/core/v2" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" ) @@ -37,9 +38,10 @@ func (*authenticator) AuthenticateBlobRequest(header *core.BlobHeader) error { } accountId := header.PaymentMetadata.AccountID - pubKey := crypto.PubkeyToAddress(*sigPublicKeyECDSA).Hex() + accountAddr := common.HexToAddress(accountId) + pubKeyAddr := crypto.PubkeyToAddress(*sigPublicKeyECDSA) - if pubKey != accountId { + if accountAddr.Cmp(pubKeyAddr) != 0 { return errors.New("signature doesn't match with provided public key") } @@ -59,9 +61,10 @@ func (*authenticator) AuthenticatePaymentStateRequest(sig []byte, accountId stri return fmt.Errorf("failed to recover public key from signature: %v", err) } - pubKey := crypto.PubkeyToAddress(*sigPublicKeyECDSA).Hex() + accountAddr := common.HexToAddress(accountId) + pubKeyAddr := crypto.PubkeyToAddress(*sigPublicKeyECDSA) - if pubKey != accountId { + if accountAddr.Cmp(pubKeyAddr) != 0 { return errors.New("signature doesn't match with provided public key") } diff --git a/core/auth/v2/signer_test.go b/core/auth/v2/signer_test.go index f49b1cfb0..9c31d1a81 100644 --- a/core/auth/v2/signer_test.go +++ b/core/auth/v2/signer_test.go @@ -8,7 +8,6 @@ import ( func TestGetAccountID(t *testing.T) { // Test case with known private key and expected account ID - // privateKey := "73ae7e3a40b59caacb1cda8fa04f4e7fa5bb2b37101f9f3506290c201f57bf7b" privateKey := "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcded" expectedAccountID := "0x1aa8226f6d354380dDE75eE6B634875c4203e522"