github.com/ronperry/cryptoedge@v0.0.0-20150815114006-cc363e290743/jcc/server_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 TestNewSigner(t *testing.T) { 11 c := eccutil.SetCurve(elliptic.P256, rand.Reader, eccutil.Sha1Hash) 12 sigpriv, sigpub, _ := c.GenerateKey() 13 signer := NewBlindingServer(sigpriv, sigpub, c, Fakeunique) 14 _ = signer 15 } 16 17 func TestSigner_Sign(t *testing.T) { 18 msg := []byte("Random message without meaning, should be unique") 19 c := eccutil.SetCurve(elliptic.P256, rand.Reader, eccutil.Sha1Hash) 20 sigpriv, sigpub, _ := c.GenerateKey() 21 signer := NewBlindingServer(sigpriv, sigpub, c, Fakeunique) 22 bc := NewBlindingClient(c, sigpub) 23 24 bmsg, bfac, err := bc.Blind(msg) 25 if err != nil { 26 t.Errorf("Blinding failed: %s", err) 27 } 28 29 r, s, err := signer.Sign(bmsg) 30 if err != nil { 31 t.Errorf("Signature failed") 32 } 33 _, _, _ = r, s, bfac 34 }