forked from cerc-io/plugeth
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 {
|
func (tx *Transaction) PublicKey() []byte {
|
||||||
hash := tx.Hash()
|
hash := tx.Hash()
|
||||||
|
|
||||||
// If we don't make a copy we will overwrite the existing underlying array
|
r := make([]byte, 32-len(tx.r))
|
||||||
dst := make([]byte, len(tx.r))
|
s := make([]byte, 32-len(tx.s))
|
||||||
copy(dst, tx.r)
|
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)
|
sig = append(sig, tx.v-27)
|
||||||
|
|
||||||
pubkey, _ := secp256k1.RecoverPubkey(hash, sig)
|
pubkey, _ := secp256k1.RecoverPubkey(hash, sig)
|
||||||
@ -127,6 +128,8 @@ func (tx *Transaction) Sign(privk []byte) error {
|
|||||||
func (tx *Transaction) RlpData() interface{} {
|
func (tx *Transaction) RlpData() interface{} {
|
||||||
data := []interface{}{tx.Nonce, tx.GasPrice, tx.Gas, tx.Recipient, tx.Value, tx.Data}
|
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)
|
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.Data = decoder.Get(5).Bytes()
|
||||||
tx.v = byte(decoder.Get(6).Uint())
|
tx.v = byte(decoder.Get(6).Uint())
|
||||||
|
|
||||||
r := make([]byte, 32-len(decoder.Get(7).Bytes()))
|
tx.r = decoder.Get(7).Bytes()
|
||||||
s := make([]byte, 32-len(decoder.Get(8).Bytes()))
|
tx.s = decoder.Get(8).Bytes()
|
||||||
tx.r = append(r, decoder.Get(7).Bytes()...)
|
|
||||||
tx.s = append(s, decoder.Get(8).Bytes()...)
|
|
||||||
|
|
||||||
if IsContractAddr(tx.Recipient) {
|
if IsContractAddr(tx.Recipient) {
|
||||||
tx.contractCreation = true
|
tx.contractCreation = true
|
||||||
@ -178,8 +179,7 @@ func (tx *Transaction) String() string {
|
|||||||
`,
|
`,
|
||||||
tx.Hash(),
|
tx.Hash(),
|
||||||
len(tx.Recipient) == 0,
|
len(tx.Recipient) == 0,
|
||||||
//tx.Sender(),
|
tx.Sender(),
|
||||||
nil,
|
|
||||||
tx.Recipient,
|
tx.Recipient,
|
||||||
tx.Nonce,
|
tx.Nonce,
|
||||||
tx.GasPrice,
|
tx.GasPrice,
|
||||||
|
Loading…
Reference in New Issue
Block a user