Make sure that public key always uses 64 bytes
This commit is contained in:
parent
bb1641e4ec
commit
842d52db7b
@ -89,11 +89,12 @@ func (tx *Transaction) Signature(key []byte) []byte {
|
||||
func (tx *Transaction) PublicKey() []byte {
|
||||
hash := tx.Hash()
|
||||
|
||||
// If we don't make a copy we will overwrite the existing underlying array
|
||||
dst := make([]byte, len(tx.r))
|
||||
copy(dst, tx.r)
|
||||
r := make([]byte, 32-len(tx.r))
|
||||
s := make([]byte, 32-len(tx.s))
|
||||
r = append(r, ethutil.CopyBytes(tx.r)...)
|
||||
s = append(s, ethutil.CopyBytes(tx.s)...)
|
||||
|
||||
sig := append(dst, tx.s...)
|
||||
sig := append(r, s...)
|
||||
sig = append(sig, tx.v-27)
|
||||
|
||||
pubkey, _ := secp256k1.RecoverPubkey(hash, sig)
|
||||
@ -127,6 +128,8 @@ func (tx *Transaction) Sign(privk []byte) error {
|
||||
func (tx *Transaction) RlpData() interface{} {
|
||||
data := []interface{}{tx.Nonce, tx.GasPrice, tx.Gas, tx.Recipient, tx.Value, tx.Data}
|
||||
|
||||
// TODO Remove prefixing zero's
|
||||
|
||||
return append(data, tx.v, tx.r, tx.s)
|
||||
}
|
||||
|
||||
@ -151,10 +154,8 @@ func (tx *Transaction) RlpValueDecode(decoder *ethutil.Value) {
|
||||
tx.Data = decoder.Get(5).Bytes()
|
||||
tx.v = byte(decoder.Get(6).Uint())
|
||||
|
||||
r := make([]byte, 32-len(decoder.Get(7).Bytes()))
|
||||
s := make([]byte, 32-len(decoder.Get(8).Bytes()))
|
||||
tx.r = append(r, decoder.Get(7).Bytes()...)
|
||||
tx.s = append(s, decoder.Get(8).Bytes()...)
|
||||
tx.r = decoder.Get(7).Bytes()
|
||||
tx.s = decoder.Get(8).Bytes()
|
||||
|
||||
if IsContractAddr(tx.Recipient) {
|
||||
tx.contractCreation = true
|
||||
@ -178,8 +179,7 @@ func (tx *Transaction) String() string {
|
||||
`,
|
||||
tx.Hash(),
|
||||
len(tx.Recipient) == 0,
|
||||
//tx.Sender(),
|
||||
nil,
|
||||
tx.Sender(),
|
||||
tx.Recipient,
|
||||
tx.Nonce,
|
||||
tx.GasPrice,
|
||||
|
Loading…
Reference in New Issue
Block a user