aboutsummaryrefslogtreecommitdiff
path: root/nizk/schnorr/schnorr_test.go
blob: ca541de1481a4216751f54709bf1dbbe0d9168f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package schnorr

import (
	"testing"

	. "kesim.org/seal/nizk"
)

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!")
	}
}