Skip to content

Commit

Permalink
api: personal_sign, eth_sign, kaia_sign are EIP-191 compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
blukat29 committed Jul 2, 2024
1 parent 487210c commit 8c5bfa3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/api_ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ func (api *EthereumAPI) SendRawTransaction(ctx context.Context, input hexutil.By
}

// Sign calculates an ECDSA signature for:
// keccack256("\x19Klaytn Signed Message:\n" + len(message) + message).
// keccack256("\x19Ethereum Signed Message:\n" + len(message) + message).
//
// Note, the produced signature conforms to the secp256k1 curve R, S and V values,
// where the V value will be 27 or 28 for legacy reasons.
Expand Down
4 changes: 2 additions & 2 deletions api/api_private_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ func (s *PrivateAccountAPI) signAsFeePayer(addr common.Address, passwd string, t
}

// Sign calculates a Kaia ECDSA signature for:
// keccack256("\x19Klaytn Signed Message:\n" + len(message) + message))
// keccack256("\x19Ethereum Signed Message:\n" + len(message) + message))
//
// Note, the produced signature conforms to the secp256k1 curve R, S and V values,
// where the V value will be 27 or 28 for legacy reasons.
Expand All @@ -469,7 +469,7 @@ func (s *PrivateAccountAPI) Sign(ctx context.Context, data hexutil.Bytes, addr c
return nil, err
}
// Assemble sign the data with the wallet
signature, err := wallet.SignHashWithPassphrase(account, passwd, signHash(data))
signature, err := wallet.SignHashWithPassphrase(account, passwd, ethSignHash(data))
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions api/api_public_transaction_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encod
}

// Sign calculates an ECDSA signature for:
// keccack256("\x19Klaytn Signed Message:\n" + len(message) + message).
// keccack256("\x19Ethereum Signed Message:\n" + len(message) + message).
//
// Note, the produced signature conforms to the secp256k1 curve R, S and V values,
// where the V value will be 27 or 28 for legacy reasons.
Expand All @@ -404,7 +404,7 @@ func (s *PublicTransactionPoolAPI) Sign(addr common.Address, data hexutil.Bytes)
return nil, err
}
// Sign the requested hash with the wallet
signature, err := wallet.SignHash(account, signHash(data))
signature, err := wallet.SignHash(account, ethSignHash(data))
if err == nil {
signature[crypto.RecoveryIDOffset] += 27 // Transform V from 0/1 to 27/28 according to the yellow paper
}
Expand Down

0 comments on commit 8c5bfa3

Please sign in to comment.