Skip to content

Commit

Permalink
Allow signature to be colleted externally
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Broadhurst <[email protected]>
  • Loading branch information
peterbroadhurst committed Aug 5, 2024
1 parent 45ec58f commit e28890b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/ethsigner/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ func (t *Transaction) SignEIP1559(signer secp256k1.Signer, chainID int64) ([]byt
if err != nil {
return nil, err
}
return t.FinalizeEIP1559WithSignature(signaturePayload, sig)
}

func (t *Transaction) FinalizeEIP1559WithSignature(signaturePayload *TransactionSignaturePayload, sig *secp256k1.SignatureData) ([]byte, error) {
// Use the direct 0/1 Y-parity value
sig.UpdateEIP2930()

Expand Down
5 changes: 4 additions & 1 deletion pkg/secp256k1/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ func (s *SignatureData) UpdateEIP155(chainID int64) {

// EIP-2930 (/ EIP-1559) rules - 0 or 1 V value for raw Y-parity value (chainID goes into the payload)
func (s *SignatureData) UpdateEIP2930() {
s.V = s.V.Sub(s.V, big.NewInt(27))
vi64 := s.V.Int64()
if vi64 == 27 || vi64 == 28 {
s.V = s.V.Sub(s.V, big.NewInt(27))
}
}

// Recover obtains the original signer from the hash of the message
Expand Down

0 comments on commit e28890b

Please sign in to comment.