OSDN Git Service

fix bug
authorChengcheng Zhang <943420582@qq.com>
Fri, 21 Dec 2018 06:45:13 +0000 (14:45 +0800)
committerChengcheng Zhang <943420582@qq.com>
Fri, 21 Dec 2018 06:45:13 +0000 (14:45 +0800)
app/api/resources.py
app/model/key.py

index 6c65744..e35de87 100644 (file)
@@ -9,10 +9,10 @@ from app.model.key import mnemonic_to_seed
 from app.model.key import seed_to_root_xprv
 
 parser = reqparse.RequestParser()
-parser.add_argument('private_key', type=str)
-parser.add_argument('message', type=str)
-parser.add_argument('public_key', type=str)
-parser.add_argument('signature', type=str)
+parser.add_argument('private_key_str', type=str)
+parser.add_argument('message_str', type=str)
+parser.add_argument('public_key_str', type=str)
+parser.add_argument('signature_str', type=str)
 parser.add_argument('entropy_str', type=str)
 parser.add_argument('mnemonic_str', type=str)
 parser.add_argument('seed_str', type=str)
@@ -26,8 +26,8 @@ class Sign(Resource):
 
     def post(self):
         args = parser.parse_args()
-        private_key = args.get('private_key')
-        message = args.get('message')
+        private_key = args.get('private_key_str')
+        message = args.get('message_str')
         sig = sign(private_key, message)
         return sig
 
@@ -35,9 +35,9 @@ class Verify(Resource):
     
     def post(self):
         args = parser.parse_args()
-        public_key = args.get('public_key')
-        signature = args.get('signature')
-        message = args.get('message')
+        public_key = args.get('public_key_str')
+        signature = args.get('signature_str')
+        message = args.get('message_str')
         result = verify(public_key, signature, message)
         return result
 
index b17fa42..7fe1e23 100644 (file)
@@ -2,6 +2,7 @@ import random
 import hashlib
 import pbkdf2
 import hmac
+import ed25519
 
 # create_key create 128 bits entropy
 def create_entropy():
@@ -101,4 +102,11 @@ def seed_to_root_xprv(seed_str):
     new_hc_str = new_hc_str[:62] + hc_31_str + new_hc_str[64:]
     root_xprv_str = new_hc_str
 
-    return root_xprv_str
\ No newline at end of file
+    return root_xprv_str
+
+# def xprv_to_xpub(xprv_str):
+# private_key = ed25519.SigningKey(bytes.fromhex(xprv_str[:64]))
+# public_key = private_key.get_verifying_key().to_ascii(encoding='hex')
+# xpub_str = public_key.decode() + xprv_str[64:]
+#     return xpub_str
+