Last active
February 2, 2019 20:34
-
-
Save liamsi/44466eae97c74904324f702feefa5583 to your computer and use it in GitHub Desktop.
This file contains 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
package main | |
import ( | |
"fmt" | |
"crypto/sha256" | |
"github.com/btcsuite/btcd/btcec" | |
) | |
func main() { | |
msg := []byte("Then strong encryption became available to the masses, and trust was no longer required.") | |
priv, err := btcec.NewPrivateKey(btcec.S256()) | |
if err != nil { | |
panic("Duh!") | |
} | |
h := sha256.Sum256(msg) | |
sig, err := priv.Sign(h[:]) | |
if err != nil { | |
panic("Duh^2!") | |
} | |
fmt.Println("Signature is valid?", sig.Verify(h[:], priv.PubKey())) | |
// s = N - s | |
sig.S.Sub(btcec.S256().CurveParams.N, sig.S) | |
fmt.Println("'Malleated' Signature is still valid?", sig.Verify(h[:], priv.PubKey())) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment