Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
K1li4nL committed Jun 24, 2024
1 parent 872c62a commit 5a15399
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 25 deletions.
25 changes: 8 additions & 17 deletions pairing/bls12381/bls12381_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ func TestZKCryptoVectorsG2Compressed(t *testing.T) {
// Returns a log of the pseudorandom Points produced in the test,
// for comparison across alternative implementations
// that are supposed to be equivalent.
//
//nolint:gocyclo,cyclop // complete test
func testGroup(t *testing.T, g kyber.Group, rand cipher.Stream) []kyber.Point {
t.Logf("\nTesting group '%s': %d-byte Point, %d-byte Scalar\n",
g.String(), g.PointLen(), g.ScalarLen())
Expand Down Expand Up @@ -220,13 +222,7 @@ func testGroup(t *testing.T, g kyber.Group, rand cipher.Stream) []kyber.Point {

// Verify additive and multiplicative identities of the generator.
// TODO: Check GT exp
/*fmt.Println("Inverse of base")*/
//f := ptmp.Base().(*KyberGT).f
//newFp12(nil).inverse(f, f)
//fmt.Printf("\n-Inverse: %v\n", f)
//fmt.Println("Multiply by -1")
ptmp.Mul(stmp.SetInt64(-1), nil).Add(ptmp, gen)
/*fmt.Printf(" \n\nChecking equality additive identity\nptmp: %v \n\n zero %v\n", ptmp, pzero)*/
if !ptmp.Equal(pzero) {
t.Fatalf("generator additive identity doesn't work: (scalar -1 %v) %v (x) -1 (+) %v = %v != %v the group point identity",
stmp.SetInt64(-1), ptmp.Mul(stmp.SetInt64(-1), nil), gen, ptmp.Mul(stmp.SetInt64(-1), nil).Add(ptmp, gen), pzero)
Expand Down Expand Up @@ -256,7 +252,6 @@ func testGroup(t *testing.T, g kyber.Group, rand cipher.Stream) []kyber.Point {
t.Fatalf("Diffie-Hellman didn't work: %v == %v (x) %v != %v (x) %v == %v", dh1, s2, p1, s1, p2, dh2)
}
points = append(points, dh1)
//t.Logf("shared secret = %v", dh1)

// Test secret inverse to get from dh1 back to p1
if primeOrder {
Expand All @@ -267,7 +262,6 @@ func testGroup(t *testing.T, g kyber.Group, rand cipher.Stream) []kyber.Point {
}

// Zero and One identity secrets
//println("dh1^0 = ",ptmp.Mul(dh1, szero).String())
if !ptmp.Mul(szero, dh1).Equal(pzero) {
t.Fatalf("Encryption with secret=0 didn't work: %v (x) %v == %v != %v", szero, dh1, ptmp, pzero)
}
Expand Down Expand Up @@ -324,11 +318,7 @@ func testGroup(t *testing.T, g kyber.Group, rand cipher.Stream) []kyber.Point {

pick := func(rand cipher.Stream) (p kyber.Point) {
defer func() {
/*if err := recover(); err != nil {*/
//// TODO implement Pick for GT
//p = g.Point().Mul(g.Scalar().Pick(rand), nil)
//return
/*}*/
// TODO implement Pick for GT
}()
p = g.Point().Pick(rand)
return
Expand Down Expand Up @@ -455,7 +445,7 @@ func TestKyberPairingG2(t *testing.T) {
}
}

func TestRacePairings(t *testing.T) {
func TestRacePairings(_ *testing.T) {
suites := []pairing.Suite{
kilic.NewBLS12381Suite(),
circl.NewSuiteBLS12381(),
Expand Down Expand Up @@ -701,11 +691,12 @@ func BLSBenchmark(b *testing.B, curveOption string) {

randSource := random.New(rand.Reader)
var suite pairing.Suite
if curveOption == "kilic" {
switch curveOption {
case "kilic":
suite = kilic.NewBLS12381Suite()
} else if curveOption == "circl" {
case "circl":
suite = circl.NewSuiteBLS12381()
} else {
default:
panic(fmt.Errorf("invalid curve option: %s", curveOption))
}

Expand Down
2 changes: 1 addition & 1 deletion pairing/bls12381/kilic/g1.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (k *G1Elt) EmbedLen() int {
panic("bls12-381: unsupported operation")
}

func (k *G1Elt) Embed(data []byte, rand cipher.Stream) kyber.Point {
func (k *G1Elt) Embed(_ []byte, _ cipher.Stream) kyber.Point {
panic("bls12-381: unsupported operation")
}

Expand Down
2 changes: 1 addition & 1 deletion pairing/bls12381/kilic/g2.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (k *G2Elt) EmbedLen() int {
panic("bls12-381: unsupported operation")
}

func (k *G2Elt) Embed(data []byte, rand cipher.Stream) kyber.Point {
func (k *G2Elt) Embed(_ []byte, _ cipher.Stream) kyber.Point {
panic("bls12-381: unsupported operation")
}

Expand Down
4 changes: 2 additions & 2 deletions pairing/bls12381/kilic/gt.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (k *GTElt) Base() kyber.Point {
panic("bls12-381.GT.Base(): unsupported operation")
}

func (k *GTElt) Pick(rand cipher.Stream) kyber.Point {
func (k *GTElt) Pick(_ cipher.Stream) kyber.Point {
panic("bls12-381.GT.Pick(): unsupported operation")
}

Expand Down Expand Up @@ -123,7 +123,7 @@ func (k *GTElt) EmbedLen() int {
panic("bls12-381.GT.EmbedLen(): unsupported operation")
}

func (k *GTElt) Embed(data []byte, rand cipher.Stream) kyber.Point {
func (k *GTElt) Embed(_ []byte, _ cipher.Stream) kyber.Point {
panic("bls12-381.GT.Embed(): unsupported operation")
}

Expand Down
6 changes: 3 additions & 3 deletions pairing/bls12381/kilic/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ func (s *Suite) Pair(p1, p2 kyber.Point) kyber.Point {
}

// New implements the kyber.Encoding interface.
func (s *Suite) New(t reflect.Type) interface{} {
func (s *Suite) New(_ reflect.Type) interface{} {
panic("Suite.Encoding: deprecated in kyber")
}

// Read is the default implementation of kyber.Encoding interface Read.
func (s *Suite) Read(r io.Reader, objs ...interface{}) error {
func (s *Suite) Read(_ io.Reader, _ ...interface{}) error {
panic("Suite.Read(): deprecated in kyber")
}

// Write is the default implementation of kyber.Encoding interface Write.
func (s *Suite) Write(w io.Writer, objs ...interface{}) error {
func (s *Suite) Write(_ io.Writer, _ ...interface{}) error {
panic("Suite.Write(): deprecated in kyber")
}

Expand Down
2 changes: 1 addition & 1 deletion pairing/bls12381/kilic/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestVerifySigOnG2(t *testing.T) {
}
}

func TestImplementInterfaces(t *testing.T) {
func TestImplementInterfaces(_ *testing.T) {
var _ kyber.Point = &G1Elt{}
var _ kyber.Point = &G2Elt{}
var _ kyber.Point = &GTElt{}
Expand Down

0 comments on commit 5a15399

Please sign in to comment.