Add sign msg method
This commit is contained in:
parent
e4efc53b31
commit
793c1d9367
@ -1,3 +1,7 @@
|
||||
* 0.4.6
|
||||
- Add sign message
|
||||
* 0.4.5
|
||||
- Upgrade dependencies
|
||||
* 0.4.4
|
||||
- Upgrade dependencies
|
||||
* 0.4.3
|
||||
|
@ -38,3 +38,12 @@ class ReferenceSigner(Signer):
|
||||
tx.r = z[:32]
|
||||
tx.s = z[32:64]
|
||||
return z
|
||||
|
||||
|
||||
def signEthereumMessage(self, address, message, password=None):
|
||||
#msg = b'\x19Ethereum Signed Message:\n{}{}'.format(len(message), message)
|
||||
k = keys.PrivateKey(self.keyGetter.get(address, password))
|
||||
#z = keys.ecdsa_sign(message_hash=g, private_key=k)
|
||||
z = k.sign_msg(message.encode('utf-8'))
|
||||
return z
|
||||
|
||||
|
@ -50,6 +50,7 @@ class PlatformMiddleware:
|
||||
return params
|
||||
|
||||
|
||||
# TODO: DRY
|
||||
def __call__(self, method, suspect_params):
|
||||
|
||||
self.id_seq += 1
|
||||
@ -76,12 +77,11 @@ class PlatformMiddleware:
|
||||
#return str(json.dumps(jr))
|
||||
return jr
|
||||
|
||||
# TODO: DRY
|
||||
elif method == 'eth_signTransaction':
|
||||
params = PlatformMiddleware._translate_params(suspect_params)
|
||||
s = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_STREAM, proto=0)
|
||||
ipc_provider_workaround = s.connect(self.ipcaddr)
|
||||
logg.info('redirecting methodd {} params {} original params {}'.format(method, params, suspect_params))
|
||||
logg.info('redirecting method {} params {} original params {}'.format(method, params, suspect_params))
|
||||
o = jsonrpc_request(method, params[0])
|
||||
j = json.dumps(o)
|
||||
logg.debug('send {}'.format(j))
|
||||
@ -94,6 +94,23 @@ class PlatformMiddleware:
|
||||
#return str(json.dumps(jr))
|
||||
return jr
|
||||
|
||||
elif method == 'eth_sign':
|
||||
params = PlatformMiddleware._translate_params(suspect_params)
|
||||
s = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_STREAM, proto=0)
|
||||
ipc_provider_workaround = s.connect(self.ipcaddr)
|
||||
logg.info('redirecting method {} params {} original params {}'.format(method, params, suspect_params))
|
||||
o = jsonrpc_request(method, params[0])
|
||||
j = json.dumps(o)
|
||||
logg.debug('send {}'.format(j))
|
||||
s.send(j.encode('utf-8'))
|
||||
r = s.recv(4096)
|
||||
s.close()
|
||||
logg.debug('got recv {}'.format(str(r)))
|
||||
jr = json.loads(r)
|
||||
jr['id'] = self.id_seq
|
||||
return jr
|
||||
|
||||
|
||||
|
||||
r = self.make_request(method, suspect_params)
|
||||
return r
|
||||
|
@ -118,9 +118,15 @@ methods = {
|
||||
'personal_newAccount': personal_new_account,
|
||||
'personal_signTransaction': personal_sign_transaction,
|
||||
'eth_signTransaction': eth_signTransaction,
|
||||
'eth_sign': eth_sign,
|
||||
}
|
||||
|
||||
|
||||
def eth_sign(address, message):
|
||||
logg.debug('got message {} to sign'.format(p[0]))
|
||||
return signer.signEthereumMessage(address, message)
|
||||
|
||||
|
||||
def jsonrpc_error(rpc_id, err):
|
||||
return {
|
||||
'json-rpc': '2.0',
|
||||
|
@ -5,5 +5,5 @@ eth-keys==0.3.3
|
||||
pysha3==1.0.2
|
||||
rlp==2.0.0a1
|
||||
json-rpc==1.13.0
|
||||
confini==0.3.3
|
||||
confini==0.3.4
|
||||
sqlalchemy==1.3.20
|
||||
|
2
setup.py
2
setup.py
@ -24,7 +24,7 @@ f.close()
|
||||
|
||||
setup(
|
||||
name="crypto-dev-signer",
|
||||
version="0.4.4",
|
||||
version="0.4.6",
|
||||
description="A signer and keystore daemon and library for cryptocurrency software development",
|
||||
author="Louis Holbrook",
|
||||
author_email="dev@holbrook.no",
|
||||
|
@ -87,5 +87,10 @@ class TestSign(unittest.TestCase):
|
||||
z = s.signTransaction(t)
|
||||
|
||||
|
||||
def test_sign_message(self):
|
||||
s = ReferenceSigner(self.pk_getter)
|
||||
z = s.signEthereumMessage(tx_ints['from'], 'foo')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user