github.com/ronperry/cryptoedge@v0.0.0-20150815114006-cc363e290743/singhdas/generic_test.go (about) 1 package singhdas 2 3 import ( 4 "crypto/elliptic" 5 "crypto/rand" 6 "github.com/ronperry/cryptoedge/eccutil" 7 "testing" 8 ) 9 10 func Test_GenericRequest(t *testing.T) { 11 c := eccutil.SetCurve(elliptic.P256, rand.Reader, eccutil.Sha1Hash) 12 privkey, pubkey, err := c.GenerateKey() 13 if err != nil { 14 t.Fatalf("Error creating keys: %s", err) 15 } 16 signer := NewGenericBlindingServer(privkey, pubkey, c) 17 clientParams, serverParams, err := signer.GetParams() 18 if err != nil { 19 t.Errorf("Error occured throughout parameter creation: %s", err) 20 } 21 _, _ = clientParams, serverParams 22 } 23 24 func Test_GenericBlind(t *testing.T) { 25 msg := []byte("Message to be blinded") 26 c := eccutil.SetCurve(elliptic.P256, rand.Reader, eccutil.Sha1Hash) 27 privkey, pubkey, err := c.GenerateKey() 28 if err != nil { 29 t.Fatalf("Error creating keys: %s", err) 30 } 31 signer := NewGenericBlindingServer(privkey, pubkey, c) 32 client := NewGenericBlindingClient(pubkey, c) 33 34 clientParams, serverParams, err := signer.GetParams() 35 if err != nil { 36 t.Errorf("Error occured throughout parameter creation: %s", err) 37 } 38 cm := NewClearMessage(msg) 39 clientFactors, blindMessage, err := client.Blind(clientParams, cm) 40 if err != nil { 41 t.Errorf("Error occured throughout blinding: %s", err) 42 } 43 _, _, _, _, _ = clientParams, serverParams, client, clientFactors, blindMessage 44 _, _, _, _, _, _, _ = msg, client, clientParams, serverParams, cm, clientFactors, blindMessage 45 } 46 47 // func Test_GenericSign(t *testing.T) { 48 // msg := []byte("Message to be blinded") 49 // c := eccutil.SetCurve(elliptic.P256, rand.Reader, eccutil.Sha1Hash) 50 // privkey, pubkey, err := c.GenerateKey() 51 // if err != nil { 52 // t.Fatalf("Error creating keys: %s", err) 53 // } 54 // signer := NewGenericBlindingServer(privkey, pubkey, c) 55 // client := NewGenericBlindingClient(pubkey, c) 56 57 // clientParams, serverParams, err := signer.GetParams() 58 // if err != nil { 59 // t.Errorf("Error occured throughout parameter creation: %s", err) 60 // } 61 // cm := NewClearMessage(msg) 62 // clientFactors, blindMessage, err := client.Blind(clientParams, cm) 63 // if err != nil { 64 // t.Errorf("Error occured throughout blinding: %s", err) 65 // } 66 // blindsignature, err := signer.Sign(serverParams, blindMessage) 67 // if err != nil { 68 // t.Errorf("Error occured throughout signing: %s", err) 69 // } 70 // _, _, _, _, _ = clientParams, blindsignature, client, clientFactors, blindMessage 71 // } 72 73 // func Test_GenericUnBlind(t *testing.T) { 74 // msg := []byte("Message to be blinded") 75 // c := eccutil.SetCurve(elliptic.P256, rand.Reader, eccutil.Sha1Hash) 76 // privkey, pubkey, err := c.GenerateKey() 77 // if err != nil { 78 // t.Fatalf("Error creating keys: %s", err) 79 // } 80 // signer := NewGenericBlindingServer(privkey, pubkey, c) 81 // client := NewGenericBlindingClient(pubkey, c) 82 83 // clientParams, serverParams, err := signer.GetParams() 84 // if err != nil { 85 // t.Errorf("Error occured throughout parameter creation: %s", err) 86 // } 87 // cm := NewClearMessage(msg) 88 // clientFactors, blindMessage, err := client.Blind(clientParams, cm) 89 // if err != nil { 90 // t.Errorf("Error occured throughout blinding: %s", err) 91 // } 92 // blindsignature, err := signer.Sign(serverParams, blindMessage) 93 // if err != nil { 94 // t.Errorf("Error occured throughout signing: %s", err) 95 // } 96 // clearsig, clearmsg, err := client.Unblind(clientFactors, cm, blindsignature) 97 // if err != nil { 98 // t.Errorf("Error occured throughout unblinding: %s", err) 99 // } 100 // _, _, _, _, _ = clearsig, clearmsg, client, clientFactors, blindMessage 101 // } 102 103 // func Test_GenericVerify(t *testing.T) { 104 // msg := []byte("Message to be blinded") 105 // c := eccutil.SetCurve(elliptic.P256, rand.Reader, eccutil.Sha1Hash) 106 // privkey, pubkey, err := c.GenerateKey() 107 // if err != nil { 108 // t.Fatalf("Error creating keys: %s", err) 109 // } 110 // signer := NewGenericBlindingServer(privkey, pubkey, c) 111 // client := NewGenericBlindingClient(pubkey, c) 112 113 // clientParams, serverParams, err := signer.GetParams() 114 // if err != nil { 115 // t.Errorf("Error occured throughout parameter creation: %s", err) 116 // } 117 // cm := NewClearMessage(msg) 118 // clientFactors, blindMessage, err := client.Blind(clientParams, cm) 119 // if err != nil { 120 // t.Errorf("Error occured throughout blinding: %s", err) 121 // } 122 // blindsignature, err := signer.Sign(serverParams, blindMessage) 123 // if err != nil { 124 // t.Errorf("Error occured throughout signing: %s", err) 125 // } 126 // clearsig, clearmsg, err := client.Unblind(clientFactors, cm, blindsignature) 127 // if err != nil { 128 // t.Errorf("Error occured throughout unblinding: %s", err) 129 // } 130 // ok, err := client.Verify(clearsig, clearmsg) 131 // if err != nil { 132 // t.Errorf("Error occured throughout verify: %s", err) 133 // } 134 // if !ok { 135 // t.Error("Message does not verify") 136 // } 137 // _, _, _, _, _ = clearsig, clearmsg, client, clientFactors, blindMessage 138 // }