Add ECDSA actions to CryptMessage (#1984)
* Add ecdsaSign and ecdsaVerify * Fix return * Fix unicode * Update CryptMessagePlugin.py
This commit is contained in:
parent
5ff2f792e6
commit
bdb0dc32a7
1 changed files with 14 additions and 1 deletions
|
@ -2,7 +2,7 @@ import base64
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from Plugin import PluginManager
|
from Plugin import PluginManager
|
||||||
from Crypt import CryptBitcoin
|
from Crypt import CryptBitcoin, CryptHash
|
||||||
import lib.pybitcointools as btctools
|
import lib.pybitcointools as btctools
|
||||||
|
|
||||||
from . import CryptMessage
|
from . import CryptMessage
|
||||||
|
@ -111,6 +111,19 @@ class UiWebsocketPlugin(object):
|
||||||
else:
|
else:
|
||||||
self.response(to, texts)
|
self.response(to, texts)
|
||||||
|
|
||||||
|
# Sign data using ECDSA
|
||||||
|
# Return: Signature
|
||||||
|
def actionEcdsaSign(self, to, data, privatekey=0):
|
||||||
|
if type(privatekey) is int: # Decrypt using user's privatekey
|
||||||
|
privatekey = self.user.getEncryptPrivatekey(self.site.address, privatekey)
|
||||||
|
|
||||||
|
self.response(to, CryptBitcoin.sign(data.encode("utf8"), privatekey))
|
||||||
|
|
||||||
|
# Verify data using ECDSA (address is either a address or array of addresses)
|
||||||
|
# Return: bool
|
||||||
|
def actionEcdsaVerify(self, to, data, address, signature):
|
||||||
|
self.response(to, CryptBitcoin.verify(data.encode("utf8"), address, signature))
|
||||||
|
|
||||||
|
|
||||||
@PluginManager.registerTo("User")
|
@PluginManager.registerTo("User")
|
||||||
class UserPlugin(object):
|
class UserPlugin(object):
|
||||||
|
|
Loading…
Reference in a new issue