Skip to content

Commit

Permalink
Minor optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Oct 11, 2020
1 parent 8260fc8 commit 283f52a
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,14 @@ func (p *JSONEnvelope) process(miner *Miner, bodyContents []byte) error {
}

// Verify using DER format
if p.Validated, err = validateSignature(p.Signature, p.PublicKey, p.Payload); err != nil {
return err
}

return nil
p.Validated, err = validateSignature(p.Signature, p.PublicKey, p.Payload)
return err
}

// validateSignature will check the data against the pubkey + signature
func validateSignature(signature, pubKey, data string) (bool, error) {
// Only if we have a signature and pubkey
if len(signature) > 0 && len(pubKey) > 0 {
// Verify using DER format
return bitcoin.VerifyMessageDER(sha256.Sum256([]byte(data)), pubKey, signature)
}
return false, nil
Expand Down

0 comments on commit 283f52a

Please sign in to comment.