@@ -18,6 +18,7 @@ import (
18
18
"go.dedis.ch/kyber/v4/internal/test"
19
19
"go.dedis.ch/kyber/v4/pairing"
20
20
circl "go.dedis.ch/kyber/v4/pairing/bls12381/circl"
21
+ "go.dedis.ch/kyber/v4/pairing/bls12381/gnark"
21
22
kilic "go.dedis.ch/kyber/v4/pairing/bls12381/kilic"
22
23
"go.dedis.ch/kyber/v4/sign/bls"
23
24
"go.dedis.ch/kyber/v4/sign/tbls"
@@ -38,6 +39,7 @@ func TestScalarEndianess(t *testing.T) {
38
39
suites := []pairing.Suite {
39
40
kilic .NewBLS12381Suite (),
40
41
circl .NewSuiteBLS12381 (),
42
+ gnark .NewSuiteBLS12381 (),
41
43
}
42
44
43
45
seed := "TestScalarEndianess"
@@ -109,6 +111,16 @@ func TestZKCryptoVectorsG1Compressed(t *testing.T) {
109
111
if err != nil && testCaseValid {
110
112
panic ("Circl: err should be nil" )
111
113
}
114
+
115
+ // Test gnark
116
+ g3 := gnark.G1Elt {}
117
+ err = g3 .UnmarshalBinary (byts )
118
+ if err == nil && ! testCaseValid {
119
+ panic ("Gnark: err should not be nil" )
120
+ }
121
+ if err != nil && testCaseValid {
122
+ panic ("Gnark: err should be nil" )
123
+ }
112
124
})
113
125
}
114
126
}
@@ -156,6 +168,16 @@ func TestZKCryptoVectorsG2Compressed(t *testing.T) {
156
168
if err != nil && testCaseValid {
157
169
panic ("Circl: err should be nil" )
158
170
}
171
+
172
+ // Test gnark
173
+ g3 := gnark.G2Elt {}
174
+ err = g3 .UnmarshalBinary (byts )
175
+ if err == nil && ! testCaseValid {
176
+ panic ("Gnark: err should not be nil" )
177
+ }
178
+ if err != nil && testCaseValid {
179
+ panic ("Gnark: err should be nil" )
180
+ }
159
181
})
160
182
}
161
183
}
@@ -400,6 +422,7 @@ func TestKyberG1(t *testing.T) {
400
422
suites := []pairing.Suite {
401
423
kilic .NewBLS12381Suite (),
402
424
circl .NewSuiteBLS12381 (),
425
+ gnark .NewSuiteBLS12381 (),
403
426
}
404
427
405
428
for _ , suite := range suites {
@@ -411,6 +434,7 @@ func TestKyberG2(t *testing.T) {
411
434
suites := []pairing.Suite {
412
435
kilic .NewBLS12381Suite (),
413
436
circl .NewSuiteBLS12381 (),
437
+ gnark .NewSuiteBLS12381 (),
414
438
}
415
439
416
440
for _ , suite := range suites {
@@ -422,6 +446,7 @@ func TestKyberPairingG2(t *testing.T) {
422
446
suites := []pairing.Suite {
423
447
kilic .NewBLS12381Suite (),
424
448
circl .NewSuiteBLS12381 (),
449
+ gnark .NewSuiteBLS12381 (),
425
450
}
426
451
427
452
for _ , s := range suites {
@@ -449,6 +474,7 @@ func TestRacePairings(_ *testing.T) {
449
474
suites := []pairing.Suite {
450
475
kilic .NewBLS12381Suite (),
451
476
circl .NewSuiteBLS12381 (),
477
+ gnark .NewSuiteBLS12381 (),
452
478
}
453
479
454
480
for _ , s := range suites {
@@ -473,6 +499,7 @@ func TestKyberBLSG2(t *testing.T) {
473
499
suites := []pairing.Suite {
474
500
kilic .NewBLS12381Suite (),
475
501
circl .NewSuiteBLS12381 (),
502
+ gnark .NewSuiteBLS12381 (),
476
503
}
477
504
478
505
for _ , suite := range suites {
@@ -485,6 +512,7 @@ func TestKyberBLSG1(t *testing.T) {
485
512
suites := []pairing.Suite {
486
513
kilic .NewBLS12381Suite (),
487
514
circl .NewSuiteBLS12381 (),
515
+ gnark .NewSuiteBLS12381 (),
488
516
}
489
517
490
518
for _ , suite := range suites {
@@ -497,6 +525,7 @@ func TestKyberThresholdG2(t *testing.T) {
497
525
suites := []pairing.Suite {
498
526
kilic .NewBLS12381Suite (),
499
527
circl .NewSuiteBLS12381 (),
528
+ gnark .NewSuiteBLS12381 (),
500
529
}
501
530
502
531
for _ , suite := range suites {
@@ -509,6 +538,7 @@ func TestKyberThresholdG1(t *testing.T) {
509
538
suites := []pairing.Suite {
510
539
kilic .NewBLS12381Suite (),
511
540
circl .NewSuiteBLS12381 (),
541
+ gnark .NewSuiteBLS12381 (),
512
542
}
513
543
514
544
for _ , suite := range suites {
@@ -521,6 +551,7 @@ func TestIsValidGroup(t *testing.T) {
521
551
suites := []pairing.Suite {
522
552
kilic .NewBLS12381Suite (),
523
553
circl .NewSuiteBLS12381 (),
554
+ gnark .NewSuiteBLS12381 (),
524
555
}
525
556
526
557
for _ , suite := range suites {
@@ -549,6 +580,7 @@ func TestBasicPairing(t *testing.T) {
549
580
suites := []pairing.Suite {
550
581
kilic .NewBLS12381Suite (),
551
582
circl .NewSuiteBLS12381 (),
583
+ gnark .NewSuiteBLS12381 (),
552
584
}
553
585
554
586
for _ , suite := range suites {
@@ -601,6 +633,7 @@ func BenchmarkPairingSeparate(bb *testing.B) {
601
633
var suites = []pairing.Suite {
602
634
kilic .NewBLS12381Suite (),
603
635
circl .NewSuiteBLS12381 (),
636
+ gnark .NewSuiteBLS12381 (),
604
637
}
605
638
606
639
for _ , s := range suites {
@@ -630,6 +663,7 @@ func BenchmarkPairingInv(bb *testing.B) {
630
663
var suites = []pairing.Suite {
631
664
kilic .NewBLS12381Suite (),
632
665
circl .NewSuiteBLS12381 (),
666
+ gnark .NewSuiteBLS12381 (),
633
667
}
634
668
635
669
for _ , s := range suites {
@@ -657,7 +691,7 @@ func BenchmarkPairingInv(bb *testing.B) {
657
691
var (
658
692
dataSize = 32
659
693
numSigs = []int {1 , 10 , 100 , 1000 , 10000 }
660
- curveOptions = []string {"kilic" , "circl" }
694
+ curveOptions = []string {"kilic" , "circl" , "gnark" }
661
695
)
662
696
663
697
// Used to avoid compiler optimizations
@@ -671,6 +705,9 @@ func BenchmarkKilic(b *testing.B) {
671
705
func BenchmarkCircl (b * testing.B ) {
672
706
BLSBenchmark (b , "circl" )
673
707
}
708
+ func BenchmarkGnark (b * testing.B ) {
709
+ BLSBenchmark (b , "gnark" )
710
+ }
674
711
675
712
func BLSBenchmark (b * testing.B , curveOption string ) {
676
713
b .Logf ("----------------------" )
@@ -696,6 +733,8 @@ func BLSBenchmark(b *testing.B, curveOption string) {
696
733
suite = kilic .NewBLS12381Suite ()
697
734
case "circl" :
698
735
suite = circl .NewSuiteBLS12381 ()
736
+ case "gnark" :
737
+ suite = gnark .NewSuiteBLS12381 ()
699
738
default :
700
739
panic (fmt .Errorf ("invalid curve option: %s" , curveOption ))
701
740
}
@@ -752,7 +791,7 @@ func BLSBenchmark(b *testing.B, curveOption string) {
752
791
}
753
792
}
754
793
})
755
- b .Run (fmt .Sprintf ("AggregateSign-G1 on %d signs" , n ), func (bb * testing.B ) {
794
+ b .Run (fmt .Sprintf ("AggregateSign-G2 on %d signs" , n ), func (bb * testing.B ) {
756
795
for j := 0 ; j < bb .N ; j ++ {
757
796
result , err = schemeOnG2 .AggregateSignatures (sigsOnG2 [:n ]... )
758
797
if err != nil {
0 commit comments