Skip to content

Commit

Permalink
sm2: naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
emmansun committed Dec 18, 2023
1 parent c6cc18e commit c1f84ce
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sm2/sm2.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ const (
// It implemented both crypto.Decrypter and crypto.Signer interfaces.
type PrivateKey struct {
ecdsa.PrivateKey
// inverseOfkeyPlus1 is set under inverseOfkeyPlus1Once
inverseOfkeyPlus1 *bigmod.Nat
inverseOfkeyPlus1Once sync.Once
// inverseOfKeyPlus1 is set under inverseOfKeyPlus1Once
inverseOfKeyPlus1 *bigmod.Nat
inverseOfKeyPlus1Once sync.Once
}

type pointMarshalMode byte
Expand Down Expand Up @@ -598,7 +598,7 @@ func (priv *PrivateKey) inverseOfPrivateKeyPlus1(c *sm2Curve) (*bigmod.Nat, erro
dp1Inv, oneNat *bigmod.Nat
dp1Bytes []byte
)
priv.inverseOfkeyPlus1Once.Do(func() {
priv.inverseOfKeyPlus1Once.Do(func() {
oneNat, _ = bigmod.NewNat().SetBytes(one.Bytes(), c.N)
dp1Inv, err = bigmod.NewNat().SetBytes(priv.D.Bytes(), c.N)
if err == nil {
Expand All @@ -608,15 +608,15 @@ func (priv *PrivateKey) inverseOfPrivateKeyPlus1(c *sm2Curve) (*bigmod.Nat, erro
} else {
dp1Bytes, err = _sm2ec.P256OrdInverse(dp1Inv.Bytes(c.N))
if err == nil {
priv.inverseOfkeyPlus1, err = bigmod.NewNat().SetBytes(dp1Bytes, c.N)
priv.inverseOfKeyPlus1, err = bigmod.NewNat().SetBytes(dp1Bytes, c.N)
}
}
}
})
if err != nil {
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) {
Expand Down

0 comments on commit c1f84ce

Please sign in to comment.