Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use EIP155 signer when needed #350

Merged
merged 1 commit into from
May 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions core/types/transaction_signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ type sigCache struct {

// MakeSigner returns a Signer based on the given chain config and block number.
func MakeSigner(config *params.ChainConfig, blockNumber *big.Int) Signer {
if config.IsQuorum {
return HomesteadSigner{}
}
var signer Signer
switch {
case config.IsEIP155(blockNumber):
Expand Down Expand Up @@ -128,6 +125,9 @@ func (s EIP155Signer) Equal(s2 Signer) bool {
var big8 = big.NewInt(8)

func (s EIP155Signer) Sender(tx *Transaction) (common.Address, error) {
if tx.IsPrivate() {
return HomesteadSigner{}.Sender(tx)
}
if !tx.Protected() {
return HomesteadSigner{}.Sender(tx)
}
Expand All @@ -136,12 +136,16 @@ func (s EIP155Signer) Sender(tx *Transaction) (common.Address, error) {
}
V := new(big.Int).Sub(tx.data.V, s.chainIdMul)
V.Sub(V, big8)
return recoverPlain(s.Hash(tx), tx.data.R, tx.data.S, V, true, false)
return recoverPlain(s.Hash(tx), tx.data.R, tx.data.S, V, true, tx.IsPrivate())
}

// WithSignature returns a new transaction with the given signature. This signature
// needs to be in the [R || S || V] format where V is 0 or 1.
func (s EIP155Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error) {
if tx.IsPrivate() {
return HomesteadSigner{}.SignatureValues(tx, sig)
}

R, S, V, err = HomesteadSigner{}.SignatureValues(tx, sig)
if err != nil {
return nil, nil, nil, err
Expand Down