diff options
author | Özgür Kesim <oec@codeblau.de> | 2024-11-14 20:42:45 +0100 |
---|---|---|
committer | Özgür Kesim <oec@codeblau.de> | 2024-11-14 20:42:45 +0100 |
commit | 38ab8f84c71ef2448fbbd10652fd4068cfbc3a31 (patch) | |
tree | fb3c939fe380f6352a41388fe755f7ebe49e7ec5 | |
parent | 0e0e75d03695e343a315ff5f7b655ed2313d9493 (diff) |
more granular stage2 test
-rw-r--r-- | nizk/stage2_test.go | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/nizk/stage2_test.go b/nizk/stage2_test.go index 446f20d..cfd6e13 100644 --- a/nizk/stage2_test.go +++ b/nizk/stage2_test.go @@ -1,6 +1,7 @@ package nizk import ( + "fmt" "testing" . "kesim.org/seal/common" @@ -9,31 +10,35 @@ import ( func TestStage2Simple(t *testing.T) { id := Curve.RandomScalar() b1, _, _ := NewBit(id, false) // This is also the junction - r1, _ := b1.RevealStage1() c1 := b1.StageCommit() + r1, _ := b1.RevealStage1() + // Because the first index is a junction, any subsequent + // combination of Bits must verify with 'lost' set to true + // in the RevealStage2 calls. for _, s := range [][2]bool{ {false, false}, {true, false}, - {true, true}, {false, true}, + {true, true}, } { b2, bc2, _ := NewBit(id, s[0]) b3, bc3, _ := NewBit(id, s[1]) c2 := b2.StageCommit() c3 := b3.StageCommit() - - r2, p2 := b2.RevealStage2(true, b1) - if !bc2.VerifyStage2(c1, c2, r1, r2, p2) { - t.Fatalf("failed to verify!\nbc2: %#v\nc1: %#v\nc2: %#v\nr1: %#v\nr2: %#v\np2: %#v\n", - bc2, c1, c2, r1, r2, p2) - } - - r3, p3 := b3.RevealStage2(true, b1) - if !bc3.VerifyStage2(c1, c3, r1, r3, p3) { - t.Fatalf("faild to verify bc3") - } + t.Run(fmt.Sprintf("variant %t %t b2.b1", s[0], s[1]), func(t *testing.T) { + r2, p2 := b2.RevealStage2(true, b1) // We had lost previously + if !bc2.VerifyStage2(c1, c2, r1, r2, p2) { + t.Fatalf("failed to verify bc2") + } + }) + t.Run(fmt.Sprintf("variant %t %t, b3.b1", s[0], s[1]), func(t *testing.T) { + r3, p3 := b3.RevealStage2(true, b1) // We had lost previously + if !bc3.VerifyStage2(c1, c3, r1, r3, p3) { + t.Fatalf("failed to verify bc3") + } + }) } } |