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

chore: modify code comments in VerifySignature #289

Merged
merged 1 commit into from
Aug 29, 2023
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
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