mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-26 04:06:18 +08:00
sm2: naming convention
This commit is contained in:
parent
c6cc18ee9c
commit
c1f84cefed
12
sm2/sm2.go
12
sm2/sm2.go
@ -44,9 +44,9 @@ const (
|
|||||||
// It implemented both crypto.Decrypter and crypto.Signer interfaces.
|
// It implemented both crypto.Decrypter and crypto.Signer interfaces.
|
||||||
type PrivateKey struct {
|
type PrivateKey struct {
|
||||||
ecdsa.PrivateKey
|
ecdsa.PrivateKey
|
||||||
// inverseOfkeyPlus1 is set under inverseOfkeyPlus1Once
|
// inverseOfKeyPlus1 is set under inverseOfKeyPlus1Once
|
||||||
inverseOfkeyPlus1 *bigmod.Nat
|
inverseOfKeyPlus1 *bigmod.Nat
|
||||||
inverseOfkeyPlus1Once sync.Once
|
inverseOfKeyPlus1Once sync.Once
|
||||||
}
|
}
|
||||||
|
|
||||||
type pointMarshalMode byte
|
type pointMarshalMode byte
|
||||||
@ -598,7 +598,7 @@ func (priv *PrivateKey) inverseOfPrivateKeyPlus1(c *sm2Curve) (*bigmod.Nat, erro
|
|||||||
dp1Inv, oneNat *bigmod.Nat
|
dp1Inv, oneNat *bigmod.Nat
|
||||||
dp1Bytes []byte
|
dp1Bytes []byte
|
||||||
)
|
)
|
||||||
priv.inverseOfkeyPlus1Once.Do(func() {
|
priv.inverseOfKeyPlus1Once.Do(func() {
|
||||||
oneNat, _ = bigmod.NewNat().SetBytes(one.Bytes(), c.N)
|
oneNat, _ = bigmod.NewNat().SetBytes(one.Bytes(), c.N)
|
||||||
dp1Inv, err = bigmod.NewNat().SetBytes(priv.D.Bytes(), c.N)
|
dp1Inv, err = bigmod.NewNat().SetBytes(priv.D.Bytes(), c.N)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -608,7 +608,7 @@ func (priv *PrivateKey) inverseOfPrivateKeyPlus1(c *sm2Curve) (*bigmod.Nat, erro
|
|||||||
} else {
|
} else {
|
||||||
dp1Bytes, err = _sm2ec.P256OrdInverse(dp1Inv.Bytes(c.N))
|
dp1Bytes, err = _sm2ec.P256OrdInverse(dp1Inv.Bytes(c.N))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
priv.inverseOfkeyPlus1, err = bigmod.NewNat().SetBytes(dp1Bytes, c.N)
|
priv.inverseOfKeyPlus1, err = bigmod.NewNat().SetBytes(dp1Bytes, c.N)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -616,7 +616,7 @@ func (priv *PrivateKey) inverseOfPrivateKeyPlus1(c *sm2Curve) (*bigmod.Nat, erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errInvalidPrivateKey
|
return nil, errInvalidPrivateKey
|
||||||
}
|
}
|
||||||
return priv.inverseOfkeyPlus1, nil
|
return priv.inverseOfKeyPlus1, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func signSM2EC(c *sm2Curve, priv *PrivateKey, rand io.Reader, hash []byte) (sig []byte, err error) {
|
func signSM2EC(c *sm2Curve, priv *PrivateKey, rand io.Reader, hash []byte) (sig []byte, err error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user