aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-23 17:23:51 +0800
committerobscuren <geffobscura@gmail.com>2014-06-23 17:23:51 +0800
commit842d52db7b98fb309ed99ccc4b65ca3973fb81ec (patch)
treec913044ccc33526ec46ba16fdc44ca8cdf3e43a2 /ethchain
parentbb1641e4ecd92884f219d77acd5348ceb0782490 (diff)
downloadgo-tangerine-842d52db7b98fb309ed99ccc4b65ca3973fb81ec.tar
go-tangerine-842d52db7b98fb309ed99ccc4b65ca3973fb81ec.tar.gz
go-tangerine-842d52db7b98fb309ed99ccc4b65ca3973fb81ec.tar.bz2
go-tangerine-842d52db7b98fb309ed99ccc4b65ca3973fb81ec.tar.lz
go-tangerine-842d52db7b98fb309ed99ccc4b65ca3973fb81ec.tar.xz
go-tangerine-842d52db7b98fb309ed99ccc4b65ca3973fb81ec.tar.zst
go-tangerine-842d52db7b98fb309ed99ccc4b65ca3973fb81ec.zip
Make sure that public key always uses 64 bytes
Diffstat (limited to 'ethchain')
-rw-r--r--ethchain/transaction.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/ethchain/transaction.go b/ethchain/transaction.go
index 29b167355..2ab681030 100644
--- a/ethchain/transaction.go
+++ b/ethchain/transaction.go
@@ -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,