aboutsummaryrefslogtreecommitdiff
path: root/nizk/stage2_test.go
diff options
context:
space:
mode:
authorÖzgür Kesim <oec@codeblau.de>2024-11-12 22:36:12 +0100
committerÖzgür Kesim <oec@codeblau.de>2024-11-12 22:36:12 +0100
commitf5516b13fa50db2fc510584337d0641af8d21b23 (patch)
tree1eb52b7362dec64eb81768b1695c3ad76e798e2c /nizk/stage2_test.go
parente9e0b4f5551c8bcdfc83e7fb617e8919b3696c82 (diff)
BROKEN refactor: rewrote stage2; notice bug in definition and handling of Y
Diffstat (limited to 'nizk/stage2_test.go')
-rw-r--r--nizk/stage2_test.go48
1 files changed, 11 insertions, 37 deletions
diff --git a/nizk/stage2_test.go b/nizk/stage2_test.go
index 9d3ebec..7edcf80 100644
--- a/nizk/stage2_test.go
+++ b/nizk/stage2_test.go
@@ -6,46 +6,20 @@ import (
. "kesim.org/seal/common"
)
-func TestVerification(t *testing.T) {
- var st [3]*Stage2
- for i, typ := range []Type{None, Unset, Set} {
- st[i] = NewStage2(typ)
- c, p := st[i].Commit()
- if !c.Verify(p) {
- t.Fatalf("Couldn't verify proof for %v, case %d\n", typ, i)
- }
+func TestStage2Simple(t *testing.T) {
+ id := Curve.RandomScalar()
+ b1 := NewBit(id, false)
+ b2 := NewBit(id, false)
+ s1, c1, _ := b1.CommitStage1()
+ curr, _ := b2.Commit()
+
+ _, c2, p2 := b2.CommitStage2(true, s1)
+ if !curr.VerifyStage2(c1, c2, p2) {
+ t.Fatal("Could not verify stage2")
}
- for _, ind := range [][2]int{{0, 1}, {1, 2}, {2, 0}} {
- c1, p1 := st[ind[0]].Commit()
- c2, p2 := st[ind[1]].Commit()
- if c1.Verify(p2) || c2.Verify(p1) {
- t.Fatalf("Shouldn't be able to verify %d with proof %d", ind[0], ind[1])
- }
- }
}
-func TestVerificationFromScalar(t *testing.T) {
- var s [8]*Scalar
- var st [3]*Stage2
-
- for i := range s {
- s[i] = Curve.RandomScalar()
- }
-
- for i, typ := range []Type{None, Unset, Set} {
- st[i] = NewStage2FromScalars(typ, s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7])
- c, p := st[i].Commit()
- if !c.Verify(p) {
- t.Fatalf("Couldn't verify proof for %v, case %d\n", typ, i)
- }
- }
+func TestStage2FromScalar(t *testing.T) {
- for _, ind := range [][2]int{{0, 1}, {1, 2}, {2, 1}, {2, 0}} {
- c1, p1 := st[ind[0]].Commit()
- c2, p2 := st[ind[1]].Commit()
- if c1.Verify(p2) || c2.Verify(p1) {
- t.Fatalf("Shouldn't be able to verify %d with proof %d", ind[0], ind[1])
- }
- }
}