Browse Source

variable rename: `priv2pub` -> `pubkey_gen`

The MMGen Project 11 months ago
parent
commit
4de9924f93
3 changed files with 15 additions and 10 deletions
  1. 7 2
      extmod/secp256k1mod.c
  2. 6 6
      mmgen/proto/secp256k1/keygen.py
  3. 2 2
      test/unit_tests_d/ut_dep.py

+ 7 - 2
extmod/secp256k1mod.c

@@ -20,7 +20,7 @@
 #include <Python.h>
 #include <Python.h>
 #include <secp256k1.h>
 #include <secp256k1.h>
 
 
-static PyObject * priv2pub(PyObject *self, PyObject *args) {
+static PyObject * pubkey_gen(PyObject *self, PyObject *args) {
 	const unsigned char * privkey;
 	const unsigned char * privkey;
 	const int klen;
 	const int klen;
 	const int compressed;
 	const int compressed;
@@ -65,7 +65,12 @@ struct module_state {
 #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
 #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
 
 
 static PyMethodDef secp256k1_methods[] = {
 static PyMethodDef secp256k1_methods[] = {
-	{"priv2pub", priv2pub, METH_VARARGS, "Generate pubkey from privkey using libsecp256k1"},
+	{
+		"pubkey_gen",
+		pubkey_gen,
+		METH_VARARGS,
+		"Generate a serialized pubkey from privkey bytes"
+	},
     {NULL, NULL}
     {NULL, NULL}
 };
 };
 
 

+ 6 - 6
mmgen/proto/secp256k1/keygen.py

@@ -25,25 +25,25 @@ class backend:
 			super().__init__(cfg)
 			super().__init__(cfg)
 			# catch ImportError to satisfy pylint when testing repo with unbuilt secp256k1 extension mod:
 			# catch ImportError to satisfy pylint when testing repo with unbuilt secp256k1 extension mod:
 			try:
 			try:
-				from .secp256k1 import priv2pub
-				self.priv2pub = priv2pub
+				from .secp256k1 import pubkey_gen
+				self.pubkey_gen = pubkey_gen
 			except ImportError:
 			except ImportError:
 				from ...util import die
 				from ...util import die
 				die(3,'libsecp256k1.keygen.backend: you shouldn’t be seeing this')
 				die(3,'libsecp256k1.keygen.backend: you shouldn’t be seeing this')
 
 
 		def to_pubkey(self,privkey):
 		def to_pubkey(self,privkey):
 			return PubKey(
 			return PubKey(
-				s = self.priv2pub( privkey, int(privkey.compressed) ),
+				s = self.pubkey_gen( privkey, int(privkey.compressed) ),
 				compressed = privkey.compressed )
 				compressed = privkey.compressed )
 
 
 		@classmethod
 		@classmethod
 		def get_clsname(cls,cfg,silent=False):
 		def get_clsname(cls,cfg,silent=False):
 			try:
 			try:
-				from .secp256k1 import priv2pub
-				if not priv2pub(bytes.fromhex('deadbeef'*8),1):
+				from .secp256k1 import pubkey_gen
+				if not pubkey_gen(bytes.fromhex('deadbeef'*8),1):
 					from ...util import die
 					from ...util import die
 					die( 'ExtensionModuleError',
 					die( 'ExtensionModuleError',
-						'Unable to execute priv2pub() from secp256k1 extension module' )
+						'Unable to execute pubkey_gen() from secp256k1 extension module' )
 				return cls.__name__
 				return cls.__name__
 			except ImportError as e:
 			except ImportError as e:
 				if not silent:
 				if not silent:

+ 2 - 2
test/unit_tests_d/ut_dep.py

@@ -60,8 +60,8 @@ class unit_tests:
 		return False
 		return False
 
 
 	def secp256k1(self,name,ut):
 	def secp256k1(self,name,ut):
-		from mmgen.proto.secp256k1.secp256k1 import priv2pub
-		priv2pub(bytes.fromhex('deadbeef'*8),1)
+		from mmgen.proto.secp256k1.secp256k1 import pubkey_gen
+		pubkey_gen(bytes.fromhex('deadbeef'*8),1)
 		return True
 		return True
 
 
 	def cryptography(self,name,ut):
 	def cryptography(self,name,ut):