package nizk import ( "testing" . "kesim.org/seal/common" ) func TestStatement(t *testing.T) { id := Curve.RandomScalar() Id := G.Exp(id) st1, st2 := NewBid(true), NewBid(false) c1, p1 := st1.Commit(Id) c2, p2 := st2.Commit(Id) if !c1.Verify(p1) { t.Fatal("Could not verify st1 with c1, plus=true case") } if !c2.Verify(p2) { t.Fatal("Could not verify st2 with c2, plus=false case") } // Use the wrong proof if c2.Verify(p1) { t.Fatal("Verify with wrong proof should have failed!") } } func TestStatementFromScalar(t *testing.T) { var α, β, id = Curve.RandomScalar(), Curve.RandomScalar(), Curve.RandomScalar() Id := G.Exp(id) st1, st2 := NewBidFromScalars(true, α, β), NewBidFromScalars(false, α, β) c1, p1 := st1.Commit(Id) c2, p2 := st2.Commit(Id) if !c1.Verify(p1) { t.Fatal("Could not verify st1 with c1, plus=true case") } if !c2.Verify(p2) { t.Fatal("Could not verify st2 with c2, plus=false case") } // Use the wrong proof if c2.Verify(p1) { t.Fatal("Verify with wrong proof should have failed!") } }