From 51f52e0464636141134d942e5a6eabd7064db2b4 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Fri, 29 Nov 2024 16:08:31 +0800 Subject: [PATCH] crypto: use golangci-lint (#20295) --- crypto/bn256/bn256_fast.go | 11 ++++++----- crypto/ecies/ecies_test.go | 17 ----------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/crypto/bn256/bn256_fast.go b/crypto/bn256/bn256_fast.go index be0264a730db9..ef452857db275 100644 --- a/crypto/bn256/bn256_fast.go +++ b/crypto/bn256/bn256_fast.go @@ -19,17 +19,18 @@ // Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve. package bn256 -import "github.com/XinFinOrg/XDPoSChain/crypto/bn256/cloudflare" - +import ( + bn256cf "github.com/XinFinOrg/XDPoSChain/crypto/bn256/cloudflare" +) // G1 is an abstract cyclic group. The zero value is suitable for use as the // output of an operation, but cannot be used as an input. -type G1 = bn256.G1 +type G1 = bn256cf.G1 // G2 is an abstract cyclic group. The zero value is suitable for use as the // output of an operation, but cannot be used as an input. -type G2 = bn256.G2 +type G2 = bn256cf.G2 // PairingCheck calculates the Optimal Ate pairing for a set of points. func PairingCheck(a []*G1, b []*G2) bool { - return bn256.PairingCheck(a, b) + return bn256cf.PairingCheck(a, b) } diff --git a/crypto/ecies/ecies_test.go b/crypto/ecies/ecies_test.go index 5fc6bbe007a50..235c2b59a8873 100644 --- a/crypto/ecies/ecies_test.go +++ b/crypto/ecies/ecies_test.go @@ -36,7 +36,6 @@ import ( "crypto/sha256" "encoding/hex" "errors" - "fmt" "math/big" "testing" @@ -67,22 +66,6 @@ func cmpParams(p1, p2 *ECIESParams) bool { p1.BlockSize == p2.BlockSize } -// cmpPublic returns true if the two public keys represent the same pojnt. -func cmpPublic(pub1, pub2 PublicKey) bool { - if pub1.X == nil || pub1.Y == nil { - fmt.Println(ErrInvalidPublicKey.Error()) - return false - } - if pub2.X == nil || pub2.Y == nil { - fmt.Println(ErrInvalidPublicKey.Error()) - return false - } - pub1Out := elliptic.Marshal(pub1.Curve, pub1.X, pub1.Y) - pub2Out := elliptic.Marshal(pub2.Curve, pub2.X, pub2.Y) - - return bytes.Equal(pub1Out, pub2Out) -} - // Validate the ECDH component. func TestSharedKey(t *testing.T) { prv1, err := GenerateKey(rand.Reader, DefaultCurve, nil)