aboutsummaryrefslogtreecommitdiff
path: root/nizk/schnorr/schnorr_test.go
blob: 2adec8e967e2f01023ac107b1b15a47adc59a15f (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/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!")
	}
}