]> Cypherpunks.ru repositories - pygost.git/blobdiff - pygost/gost3410.py
Less pylint-related comments
[pygost.git] / pygost / gost3410.py
index ed84f3efbd88d5895e10b6eb9c669b6cadf06449..50f3d00b0e05e02f25eabe9d6047cc5b1349a87c 100644 (file)
@@ -1,6 +1,6 @@
 # coding: utf-8
 # PyGOST -- Pure Python GOST cryptographic functions library
-# Copyright (C) 2015-2016 Sergey Matveev <stargrave@stargrave.org>
+# Copyright (C) 2015-2018 Sergey Matveev <stargrave@stargrave.org>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -162,9 +162,9 @@ class GOST3410Curve(object):
         y = y or self.y
         tx = x
         ty = y
-        degree -= 1
         if degree == 0:
             raise ValueError("Bad degree value")
+        degree -= 1
         while degree != 0:
             if degree & 1 == 1:
                 tx, ty = self._add(tx, ty, x, y)
@@ -173,25 +173,25 @@ class GOST3410Curve(object):
         return tx, ty
 
 
-def public_key(curve, private_key):
+def public_key(curve, prv):
     """ Generate public key from the private one
 
     :param GOST3410Curve curve: curve to use
-    :param long private_key: private key
-    :return: public key's parts, X and Y
+    :param long prv: private key
+    :returns: public key's parts, X and Y
     :rtype: (long, long)
     """
-    return curve.exp(private_key)
+    return curve.exp(prv)
 
 
-def sign(curve, private_key, digest, mode=2001):
+def sign(curve, prv, digest, mode=2001):
     """ Calculate signature for provided digest
 
     :param GOST3410Curve curve: curve to use
-    :param long private_key: private key
+    :param long prv: private key
     :param digest: digest for signing
     :type digest: bytes, 32 or 64 bytes
-    :return: signature
+    :returns: signature
     :rtype: bytes, 64 or 128 bytes
     """
     size = MODE2SIZE[mode]
@@ -207,7 +207,7 @@ def sign(curve, private_key, digest, mode=2001):
         r %= q
         if r == 0:
             continue
-        d = private_key * r
+        d = prv * r
         k *= e
         s = (d + k) % q
         if s == 0:
@@ -260,13 +260,13 @@ def verify(curve, pub, digest, signature, mode=2001):
     return lm == r
 
 
-def prv_unmarshal(private_key):
+def prv_unmarshal(prv):
     """Unmarshal private key
 
-    :param bytes private_key: serialized private key
+    :param bytes prv: serialized private key
     :rtype: long
     """
-    return bytes2long(private_key[::-1])
+    return bytes2long(prv[::-1])
 
 
 def pub_marshal(pub, mode=2001):