Skip to content

Instantly share code, notes, and snippets.

Created March 21, 2018 21:13
What would you like to do?
// 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