Update to latest go-crypto, adjust code and tests
This commit is contained in:
@@ -10,8 +10,8 @@ import (
|
||||
// Creates a PrivAccount from secret.
|
||||
// The amount is not set.
|
||||
func PrivAccountFromSecret(secret string) PrivAccount {
|
||||
privKey := crypto.WrapPrivKey(
|
||||
crypto.GenPrivKeyEd25519FromSecret([]byte(secret)))
|
||||
privKey :=
|
||||
crypto.GenPrivKeyEd25519FromSecret([]byte(secret)).Wrap()
|
||||
privAccount := PrivAccount{
|
||||
PrivKey: privKey,
|
||||
Account: Account{
|
||||
@@ -31,7 +31,7 @@ func RandAccounts(num int, minAmount int64, maxAmount int64) []PrivAccount {
|
||||
balance += cmn.RandInt64() % (maxAmount - minAmount)
|
||||
}
|
||||
|
||||
privKey := crypto.WrapPrivKey(crypto.GenPrivKeyEd25519())
|
||||
privKey := crypto.GenPrivKeyEd25519().Wrap()
|
||||
pubKey := privKey.PubKey()
|
||||
privAccs[i] = PrivAccount{
|
||||
PrivKey: privKey,
|
||||
|
||||
+4
-4
@@ -104,7 +104,7 @@ func NewTxInput(pubKey crypto.PubKey, coins Coins, sequence int) TxInput {
|
||||
Sequence: sequence,
|
||||
}
|
||||
if sequence == 1 {
|
||||
input.PubKey = crypto.WrapPubKey(pubKey)
|
||||
input.PubKey = pubKey
|
||||
}
|
||||
return input
|
||||
}
|
||||
@@ -159,7 +159,7 @@ func (tx *SendTx) SignBytes(chainID string) []byte {
|
||||
func (tx *SendTx) SetSignature(addr []byte, sig crypto.Signature) bool {
|
||||
for i, input := range tx.Inputs {
|
||||
if bytes.Equal(input.Address, addr) {
|
||||
tx.Inputs[i].Signature = crypto.WrapSignature(sig)
|
||||
tx.Inputs[i].Signature = sig
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -183,14 +183,14 @@ type AppTx struct {
|
||||
func (tx *AppTx) SignBytes(chainID string) []byte {
|
||||
signBytes := wire.BinaryBytes(chainID)
|
||||
sig := tx.Input.Signature
|
||||
tx.Input.Signature = crypto.WrapSignature(nil)
|
||||
tx.Input.Signature = crypto.Signature{}
|
||||
signBytes = append(signBytes, wire.BinaryBytes(tx)...)
|
||||
tx.Input.Signature = sig
|
||||
return signBytes
|
||||
}
|
||||
|
||||
func (tx *AppTx) SetSignature(sig crypto.Signature) bool {
|
||||
tx.Input.Signature = crypto.WrapSignature(sig)
|
||||
tx.Input.Signature = sig
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
crypto "github.com/tendermint/go-crypto"
|
||||
cmn "github.com/tendermint/go-common"
|
||||
data "github.com/tendermint/go-data"
|
||||
)
|
||||
|
||||
@@ -109,7 +109,7 @@ func TestSendTxJSON(t *testing.T) {
|
||||
sig := test1PrivAcc.Sign(signBytes)
|
||||
// we handle both raw sig and wrapped sig the same
|
||||
tx.SetSignature(test1PrivAcc.PubKey.Address(), sig)
|
||||
tx2.SetSignature(test1PrivAcc.PubKey.Address(), crypto.WrapSignature(sig))
|
||||
tx2.SetSignature(test1PrivAcc.PubKey.Address(), sig)
|
||||
assert.Equal(tx, tx2)
|
||||
|
||||
// let's marshal / unmarshal this with signature
|
||||
|
||||
Reference in New Issue
Block a user