diff options
Diffstat (limited to 'schnorr/schnorr_test.go')
-rw-r--r-- | schnorr/schnorr_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/schnorr/schnorr_test.go b/schnorr/schnorr_test.go new file mode 100644 index 0000000..2adec8e --- /dev/null +++ b/schnorr/schnorr_test.go @@ -0,0 +1,34 @@ +package schnorr + +import ( + "testing" + + . "kesim.org/seal/common" +) + +func TestSchnorr(t *testing.T) { + a, e := Curve.ScalarFromReader(nil) + if e != nil { + t.Fatal(e) + } + A := G.Exp(a) + + id, e := Curve.ScalarFromReader(nil) + if e != nil { + t.Fatal(e) + } + ID := G.Exp(id) + + s := (*Statement)(a) + c := (*Commitment)(A) + + pr := s.Proof(ID) + + if !c.Verify(pr, ID) { + t.Fatalf("Verification failed!") + } + + if c.Verify(pr, ID.Exp(a)) { + t.Fatal("Verification didn't fail!") + } +} |