Created
March 21, 2018 21:13
-
-
Save JonCooperWorks/b7d9be4dc47133d6c878e872f1c7673d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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