Skip to content

Commit

Permalink
chore: modify code comments in VerifySignature (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 authored Aug 29, 2023
1 parent c17384e commit 24b6117
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions x/auth/signing/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
func VerifySignature(pubKey cryptotypes.PubKey, signerData SignerData, sigData signing.SignatureData, handler SignModeHandler, tx sdk.Tx, sigCache *lru.ARCCache, txBytes []byte) error {
switch data := sigData.(type) {
case *signing.SingleSignatureData:
// EIP712 signatures are verified in a different way
// In greenfield, we adapt another antehandler to reject non-EIP712 signatures
if data.SignMode == signing.SignMode_SIGN_MODE_EIP_712 {
// skip signature verification if we have a cache and the tx is already in it
if sigCache != nil && txBytes != nil {
Expand Down Expand Up @@ -69,16 +71,18 @@ func VerifySignature(pubKey cryptotypes.PubKey, signerData SignerData, sigData s
sigCache.Add(string(txBytes), tx)
}
return nil
} else {
// original cosmos-sdk signature verification
signBytes, err := handler.GetSignBytes(data.SignMode, signerData, tx)
if err != nil {
return err
}
if !pubKey.VerifySignature(signBytes, data.Signature) {
return fmt.Errorf("unable to verify single signer signature")
}
return nil
}
// This should never happen, but we add it just for test cases.
signBytes, err := handler.GetSignBytes(data.SignMode, signerData, tx)
if err != nil {
return err
}
if !pubKey.VerifySignature(signBytes, data.Signature) {
return fmt.Errorf("unable to verify single signer signature")
}
return nil

case *signing.MultiSignatureData:
return fmt.Errorf("multi signature is not allowed")
default:
Expand Down

0 comments on commit 24b6117

Please sign in to comment.