github.com/ronperry/cryptoedge@v0.0.0-20150815114006-cc363e290743/jcc/generic_test.go (about) 1 package jcc 2 3 import ( 4 "crypto/elliptic" 5 "crypto/rand" 6 "github.com/ronperry/cryptoedge/eccutil" 7 "testing" 8 ) 9 10 func TestGenericVerify(t *testing.T) { 11 msg := []byte("Random message without meaning, should be unique") 12 c := eccutil.SetCurve(elliptic.P256, rand.Reader, eccutil.Sha1Hash) 13 sigpriv, sigpub, err := c.GenerateKey() 14 if err != nil { 15 t.Errorf("Signer key gen failed: %s", err) 16 } 17 18 bc := NewGenericBlindingClient(c, sigpub) 19 cm := NewClearMessage(msg) 20 21 bfac, bmsg, err := bc.Blind(nil, cm) 22 if err != nil { 23 t.Errorf("Blinding failed: %s", err) 24 } 25 bs := NewGenericBlindingServer(sigpriv, sigpub, c, Fakeunique) 26 27 bsig, err := bs.Sign(nil, bmsg) 28 if err != nil { 29 t.Errorf("Signature failed") 30 } 31 32 st, mt, _ := bc.Unblind(bfac, cm, bsig) 33 34 ok, _ := bc.Verify(st, mt) 35 if !ok { 36 t.Errorf("Signature verification failed") 37 } 38 }