Skip to content

Commit a09a28c

Browse files
committed
fixed
1 parent 76322c4 commit a09a28c

File tree

6 files changed

+14
-17
lines changed

6 files changed

+14
-17
lines changed

gm/sm2/sm2.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (pub *PublicKey) Verify(msg, sign []byte, opts crypto.SignerOpts) bool {
202202
return VerifyWithRS(pub, msg, r, s, opt)
203203
}
204204

205-
// 验证 asn.1 编码的数据 bytes(r + s)
205+
// 验证明文拼接的数据 bytes(r + s)
206206
// Verify Bytes marshal data bytes(r + s)
207207
func (pub *PublicKey) VerifyBytes(msg, sign []byte, opts crypto.SignerOpts) bool {
208208
r, s, err := UnmarshalSignatureBytes(pub.Curve, sign)
@@ -378,7 +378,7 @@ func (priv *PrivateKey) SignUsingK(k *big.Int, msg []byte, opts crypto.SignerOpt
378378
return nil, errors.New("go-cryptobin/sm2: Sign fail")
379379
}
380380

381-
// 签名返回 Bytes 编码数据 bytes(r + s)
381+
// 签名返回明文拼接数据 bytes(r + s)
382382
// sign data and return Bytes marshal data bytes(r + s)
383383
func (priv *PrivateKey) SignBytes(random io.Reader, msg []byte, opts crypto.SignerOpts) ([]byte, error) {
384384
r, s, err := SignToRS(random, priv, msg, opts)
@@ -389,7 +389,7 @@ func (priv *PrivateKey) SignBytes(random io.Reader, msg []byte, opts crypto.Sign
389389
return MarshalSignatureBytes(priv.Curve, r, s)
390390
}
391391

392-
// 签名返回 Bytes 编码数据 bytes(r + s)
392+
// 签名返回明文拼接数据 bytes(r + s)
393393
// sign data and return Bytes marshal data bytes(r + s)
394394
func (priv *PrivateKey) SignBytesUsingK(k *big.Int, msg []byte, opts crypto.SignerOpts) ([]byte, error) {
395395
r, s, err := SignUsingKToRS(k, priv, msg, opts)
@@ -731,7 +731,7 @@ func SignBytesUsingK(k *big.Int, priv *PrivateKey, msg []byte, opts crypto.Signe
731731
return priv.SignBytesUsingK(k, msg, opts)
732732
}
733733

734-
// 验证 asn.1 编码的数据 bytes(r + s)
734+
// 验证明文拼接的数据 bytes(r + s)
735735
// Verify Bytes marshal data
736736
func VerifyBytes(pub *PublicKey, msg, sign []byte, opts crypto.SignerOpts) bool {
737737
if pub == nil {

pubkey/ecdsa/decdsa.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
type Hasher = func() hash.Hash
1616

17-
type dSignature struct {
17+
type decdsaSignature struct {
1818
R, S *big.Int
1919
}
2020

@@ -24,7 +24,7 @@ func DSignASN1(priv *ecdsa.PrivateKey, csprng io.Reader, data []byte, hashFunc H
2424
return nil, err
2525
}
2626

27-
return asn1.Marshal(dSignature{r, s})
27+
return asn1.Marshal(decdsaSignature{r, s})
2828
}
2929

3030
func DSignBytes(priv *ecdsa.PrivateKey, csprng io.Reader, data []byte, hashFunc Hasher) ([]byte, error) {

pubkey/egdsa/egdsa.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func GenerateKey(random io.Reader, bitsize, probability int) (*PrivateKey, error
9595
}
9696

9797
// r and s data
98-
type elgamalSignature struct {
98+
type egdsaSignature struct {
9999
R, S *big.Int
100100
}
101101

@@ -109,7 +109,7 @@ func SignASN1(rand io.Reader, priv *PrivateKey, hash []byte) ([]byte, error) {
109109
return nil, err
110110
}
111111

112-
return asn1.Marshal(elgamalSignature{
112+
return asn1.Marshal(egdsaSignature{
113113
R: r,
114114
S: s,
115115
})
@@ -118,7 +118,7 @@ func SignASN1(rand io.Reader, priv *PrivateKey, hash []byte) ([]byte, error) {
118118
// VerifyASN1 verifies the ASN.1 encoded signature, sig, of hash using the
119119
// public key, pub. Its return value records whether the signature is valid.
120120
func VerifyASN1(pub *PublicKey, hash, sig []byte) (bool, error) {
121-
var sign elgamalSignature
121+
var sign egdsaSignature
122122
_, err := asn1.Unmarshal(sig, &sign)
123123
if err != nil {
124124
return false, err

pubkey/elgamal/elgamal.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ func VerifyASN1(pub *PublicKey, hash, sig []byte) (bool, error) {
457457
return Verify(pub, hash, sign.R, sign.S)
458458
}
459459

460-
// 签名返回 Bytes 编码数据
460+
// 签名返回明文拼接数据
461461
// sign data and return Bytes marshal data
462462
func SignBytes(rand io.Reader, priv *PrivateKey, hash []byte) ([]byte, error) {
463463
r, s, err := Sign(rand, priv, hash)
@@ -475,7 +475,7 @@ func SignBytes(rand io.Reader, priv *PrivateKey, hash []byte) ([]byte, error) {
475475
return buf, nil
476476
}
477477

478-
// 验证 asn.1 编码的数据 bytes(r + s)
478+
// 验证明文拼接的数据 bytes(r + s)
479479
// Verify Bytes marshal data
480480
func VerifyBytes(pub *PublicKey, hash, sign []byte) (bool, error) {
481481
byteLen := pub.P.BitLen()

pubkey/elgamalecc/elgamalecc.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,12 @@ func NewPrivateKey(curve elliptic.Curve, k []byte) (*PrivateKey, error) {
9191
return priv, nil
9292
}
9393

94-
// 输出私钥明文
9594
// output PrivateKey data
9695
func PrivateKeyTo(key *PrivateKey) []byte {
9796
privateKey := make([]byte, (key.Curve.Params().N.BitLen()+7)/8)
9897
return key.D.FillBytes(privateKey)
9998
}
10099

101-
// 根据公钥明文初始化公钥
102100
// New a PublicKey from publicKey data
103101
func NewPublicKey(curve elliptic.Curve, k []byte) (*PublicKey, error) {
104102
x, y := elliptic.Unmarshal(curve, k)
@@ -115,7 +113,6 @@ func NewPublicKey(curve elliptic.Curve, k []byte) (*PublicKey, error) {
115113
return pub, nil
116114
}
117115

118-
// 输出公钥明文
119116
// output PublicKey data
120117
func PublicKeyTo(key *PublicKey) []byte {
121118
return elliptic.Marshal(key.Curve, key.X, key.Y)

pubkey/sdsa/sdsa.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func GenerateKey(priv *PrivateKey, rand io.Reader) error {
243243
}
244244

245245
// r and s data
246-
type elgamalSignature struct {
246+
type sdsaSignature struct {
247247
R, S *big.Int
248248
}
249249

@@ -257,7 +257,7 @@ func SignASN1(rand io.Reader, priv *PrivateKey, hashFunc Hasher, data []byte) ([
257257
return nil, err
258258
}
259259

260-
return asn1.Marshal(elgamalSignature{
260+
return asn1.Marshal(sdsaSignature{
261261
R: r,
262262
S: s,
263263
})
@@ -266,7 +266,7 @@ func SignASN1(rand io.Reader, priv *PrivateKey, hashFunc Hasher, data []byte) ([
266266
// VerifyASN1 verifies the ASN.1 encoded signature, sig, of hash using the
267267
// public key, pub. Its return value records whether the signature is valid.
268268
func VerifyASN1(pub *PublicKey, hashFunc Hasher, data []byte, sig []byte) (bool, error) {
269-
var sign elgamalSignature
269+
var sign sdsaSignature
270270
_, err := asn1.Unmarshal(sig, &sign)
271271
if err != nil {
272272
return false, err

0 commit comments

Comments
 (0)