diff options
Diffstat (limited to 'core/types/transaction_signing.go')
-rw-r--r-- | core/types/transaction_signing.go | 40 |
1 files changed, 4 insertions, 36 deletions
diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index 8952bd574..4ebc789a5 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -50,8 +50,8 @@ func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer { return signer } -// SignECDSA signs the transaction using the given signer and private key -func SignECDSA(s Signer, tx *Transaction, prv *ecdsa.PrivateKey) (*Transaction, error) { +// SignTx signs the transaction using the given signer and private key +func SignTx(tx *Transaction, s Signer, prv *ecdsa.PrivateKey) (*Transaction, error) { h := s.Hash(tx) sig, err := crypto.Sign(h[:], prv) if err != nil { @@ -96,9 +96,8 @@ type Signer interface { Hash(tx *Transaction) common.Hash // PubilcKey returns the public key derived from the signature PublicKey(tx *Transaction) ([]byte, error) - // SignECDSA signs the transaction with the given and returns a copy of the tx - SignECDSA(tx *Transaction, prv *ecdsa.PrivateKey) (*Transaction, error) - // WithSignature returns a copy of the transaction with the given signature + // WithSignature returns a copy of the transaction with the given signature. + // The signature must be encoded in [R || S || V] format where V is 0 or 1. WithSignature(tx *Transaction, sig []byte) (*Transaction, error) // Checks for equality on the signers Equal(Signer) bool @@ -124,10 +123,6 @@ func (s EIP155Signer) Equal(s2 Signer) bool { return ok && eip155.chainId.Cmp(s.chainId) == 0 } -func (s EIP155Signer) SignECDSA(tx *Transaction, prv *ecdsa.PrivateKey) (*Transaction, error) { - return SignECDSA(s, tx, prv) -} - func (s EIP155Signer) PublicKey(tx *Transaction) ([]byte, error) { // if the transaction is not protected fall back to homestead signer if !tx.Protected() { @@ -193,15 +188,6 @@ func (s EIP155Signer) Hash(tx *Transaction) common.Hash { }) } -func (s EIP155Signer) SigECDSA(tx *Transaction, prv *ecdsa.PrivateKey) (*Transaction, error) { - h := s.Hash(tx) - sig, err := crypto.Sign(h[:], prv) - if err != nil { - return nil, err - } - return s.WithSignature(tx, sig) -} - // HomesteadTransaction implements TransactionInterface using the // homestead rules. type HomesteadSigner struct{ FrontierSigner } @@ -224,15 +210,6 @@ func (hs HomesteadSigner) WithSignature(tx *Transaction, sig []byte) (*Transacti return cpy, nil } -func (hs HomesteadSigner) SignECDSA(tx *Transaction, prv *ecdsa.PrivateKey) (*Transaction, error) { - h := hs.Hash(tx) - sig, err := crypto.Sign(h[:], prv) - if err != nil { - return nil, err - } - return hs.WithSignature(tx, sig) -} - func (hs HomesteadSigner) PublicKey(tx *Transaction) ([]byte, error) { if tx.data.V.BitLen() > 8 { return nil, ErrInvalidSig @@ -280,15 +257,6 @@ func (fs FrontierSigner) WithSignature(tx *Transaction, sig []byte) (*Transactio return cpy, nil } -func (fs FrontierSigner) SignECDSA(tx *Transaction, prv *ecdsa.PrivateKey) (*Transaction, error) { - h := fs.Hash(tx) - sig, err := crypto.Sign(h[:], prv) - if err != nil { - return nil, err - } - return fs.WithSignature(tx, sig) -} - // Hash returns the hash to be sned by the sender. // It does not uniquely identify the transaction. func (fs FrontierSigner) Hash(tx *Transaction) common.Hash { |