all: golint

This commit is contained in:
Sun Yimin 2025-06-20 10:24:08 +08:00 committed by GitHub
parent fca59d1a92
commit bb64af1a24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 11 additions and 12 deletions

View File

@ -46,8 +46,8 @@ const (
r = 4193792 // 2^32 mod q
)
// See FIPS 204, Algorithm 49, MontgomeryReduce()
func fieldReduce(a uint64) fieldElement {
// See FIPS 204, Algorithm 49, MontgomeryReduce()
t := uint32(a) * qNegInv
return fieldReduceOnce(uint32((a + uint64(t)*q) >> 32))
}
@ -243,4 +243,3 @@ func vectorCountOnes(a []ringElement) int {
}
return oneCount
}

View File

@ -845,7 +845,7 @@ var _p256 *sm2Curve
func p256() *sm2Curve {
p256Once.Do(func() {
_p256 = &sm2Curve{
newPoint: func() *_sm2ec.SM2P256Point { return _sm2ec.NewSM2P256Point() },
newPoint: _sm2ec.NewSM2P256Point,
}
precomputeParams(_p256, P256())
})

View File

@ -159,7 +159,7 @@ func buildTmpPublicKeyAttr(key crypto.Signer, rawAttributes []asn1.RawValue, tmp
}
publicKeyBytes = make([]byte, 136)
// Prefix{8} || X{32} || zero{32} || Y{32} || zero{32}
copy(publicKeyBytes[:], tmpPublicKeyPrefix)
copy(publicKeyBytes, tmpPublicKeyPrefix)
ecPub, _ := tmpPub.(*ecdsa.PublicKey)
ecPub.X.FillBytes(publicKeyBytes[8:40])
ecPub.Y.FillBytes(publicKeyBytes[72:104])
@ -175,7 +175,7 @@ func buildTmpPublicKeyAttr(key crypto.Signer, rawAttributes []asn1.RawValue, tmp
}
var tmpPublicKey = tmpPublicKeyInfo{
Version: 1,
PublicKey: publicKeyBytes[:],
PublicKey: publicKeyBytes,
}
b, err := asn1.Marshal(tmpPublicKey)
if err != nil {

View File

@ -393,11 +393,11 @@ func TestCheckSignatureWithDigest(t *testing.T) {
algo: SM2WithSM3,
digest: func() []byte {
hash, _ := sm2.CalculateSM2Hash(&sm2PrivateKey.PublicKey, rawMessage, nil)
return hash[:]
return hash
}(),
signature: func() []byte {
hash, _ := sm2.CalculateSM2Hash(&sm2PrivateKey.PublicKey, rawMessage, nil)
return mustSignSM2(t, sm2PrivateKey, hash[:])
return mustSignSM2(t, sm2PrivateKey, hash)
}(),
expectedError: nil,
},
@ -409,7 +409,7 @@ func TestCheckSignatureWithDigest(t *testing.T) {
algo: SM2WithSM3,
digest: func() []byte {
hash, _ := sm2.CalculateSM2Hash(&sm2PrivateKey.PublicKey, rawMessage, nil)
return hash[:]
return hash
}(),
signature: func() []byte {
hash, _ := sm2.CalculateSM2Hash(&sm2PrivateKey2.PublicKey, rawMessage, nil)