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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
package nizk
import (
"testing"
. "kesim.org/seal/common"
)
func TestStage1(t *testing.T) {
st1 := NewStage1(true)
st2 := NewStage1(false)
c1, pr1 := st1.Commit()
c2, pr2 := st2.Commit()
if !c1.Verify(pr1) {
t.Fatal("Could not verify st1 with c1 and pr1, plus=true case")
}
if !c2.Verify(pr2) {
t.Fatal("Could not verify st2 with c2 and pr2, plus=false case")
}
// Wrong proof test
if c1.Verify(pr2) {
t.Fatal("Shouldn't be able to verify c1 with pr2")
}
}
func TestStage1FromScalars(t *testing.T) {
var x, y, r, α, β *Scalar
for _, s := range []**Scalar{&x, &y, &r, &α, &β} {
*s = Curve.RandomScalar()
}
st1 := NewStage1FromScalars(true, x, y, r, α, β)
st2 := NewStage1FromScalars(false, x, y, r, α, β)
c1, pr1 := st1.Commit()
c2, pr2 := st2.Commit()
if !c1.Verify(pr1) {
t.Fatal("Could not verify st1 with c1 and pr1, plus=true case")
}
if !c2.Verify(pr2) {
t.Fatal("Could not verify st2 with c2 and pr2, plus=false case")
}
// Wrong proof test
if c1.Verify(pr2) {
t.Fatal("Shouldn't be able to verify c1 with pr2")
}
}
|