Skip to content

Instantly share code, notes, and snippets.

@JonCooperWorks
Created March 21, 2018 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonCooperWorks/b7d9be4dc47133d6c878e872f1c7673d to your computer and use it in GitHub Desktop.
Save JonCooperWorks/b7d9be4dc47133d6c878e872f1c7673d to your computer and use it in GitHub Desktop.
// Verify verifies that a byte slice was signed by a given public key.
func Verify(publicKey *ecdsa.PublicKey, signature, data []byte) (bool, error) {
hasher := sha3.New256()
_, err := hasher.Write(data)
if err != nil {
return false, err
}
pluginHash := hasher.Sum(nil)
r := new(big.Int).SetBytes(signature[0:32])
s := new(big.Int).SetBytes(signature[32:64])
return ecdsa.Verify(publicKey, pluginHash, r, s), nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment