diff --git a/plugins/CryptMessage/CryptMessagePlugin.py b/plugins/CryptMessage/CryptMessagePlugin.py index fb895975..f1fdc4d4 100644 --- a/plugins/CryptMessage/CryptMessagePlugin.py +++ b/plugins/CryptMessage/CryptMessagePlugin.py @@ -2,7 +2,7 @@ import base64 import os from Plugin import PluginManager -from Crypt import CryptBitcoin +from Crypt import CryptBitcoin, CryptHash import lib.pybitcointools as btctools from . import CryptMessage @@ -111,6 +111,19 @@ class UiWebsocketPlugin(object): else: 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") class UserPlugin(object):