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