]> Cypherpunks.ru repositories - gogost.git/commitdiff
Shorter unified curve argument name
authorSergey Matveev <stargrave@stargrave.org>
Tue, 16 Nov 2021 15:33:55 +0000 (18:33 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 16 Nov 2021 15:33:55 +0000 (18:33 +0300)
gost3410/private.go
gost3410/public.go

index 237a906cfacfbe3127cd21c79d14f37d0284f6fe..ac08df5be11f1ed383020186d41b57a337170532 100644 (file)
@@ -28,8 +28,8 @@ type PrivateKey struct {
        Key *big.Int
 }
 
-func NewPrivateKey(curve *Curve, raw []byte) (*PrivateKey, error) {
-       pointSize := curve.PointSize()
+func NewPrivateKey(c *Curve, raw []byte) (*PrivateKey, error) {
+       pointSize := c.PointSize()
        if len(raw) != pointSize {
                return nil, fmt.Errorf("gogost/gost3410: len(key) != %d", pointSize)
        }
@@ -41,15 +41,15 @@ func NewPrivateKey(curve *Curve, raw []byte) (*PrivateKey, error) {
        if k.Cmp(zero) == 0 {
                return nil, errors.New("gogost/gost3410: zero private key")
        }
-       return &PrivateKey{curve, k.Mod(k, curve.Q)}, nil
+       return &PrivateKey{c, k.Mod(k, c.Q)}, nil
 }
 
-func GenPrivateKey(curve *Curve, rand io.Reader) (*PrivateKey, error) {
-       raw := make([]byte, curve.PointSize())
+func GenPrivateKey(c *Curve, rand io.Reader) (*PrivateKey, error) {
+       raw := make([]byte, c.PointSize())
        if _, err := io.ReadFull(rand, raw); err != nil {
                return nil, err
        }
-       return NewPrivateKey(curve, raw)
+       return NewPrivateKey(c, raw)
 }
 
 func (prv *PrivateKey) Raw() []byte {
index 3bef45f70ef798287edf4b23654e09d2103a730b..85d3557bfe03c7506e4417ed258c6e62665aa46f 100644 (file)
@@ -27,8 +27,8 @@ type PublicKey struct {
        Y *big.Int
 }
 
-func NewPublicKey(curve *Curve, raw []byte) (*PublicKey, error) {
-       pointSize := curve.PointSize()
+func NewPublicKey(c *Curve, raw []byte) (*PublicKey, error) {
+       pointSize := c.PointSize()
        key := make([]byte, 2*pointSize)
        if len(raw) != len(key) {
                return nil, fmt.Errorf("gogost/gost3410: len(key) != %d", len(key))
@@ -37,7 +37,7 @@ func NewPublicKey(curve *Curve, raw []byte) (*PublicKey, error) {
                key[i] = raw[len(raw)-i-1]
        }
        return &PublicKey{
-               curve,
+               c,
                bytes2big(key[pointSize : 2*pointSize]),
                bytes2big(key[:pointSize]),
        }, nil