Skip to content
Snippets Groups Projects
Unverified Commit b36fe868 authored by Holger Nahrstaedt's avatar Holger Nahrstaedt Committed by GitHub
Browse files

Merge pull request #60 from crokkon/conveyor

rework Conveyor signing, revert ecdsasig changes
parents 76a55f29 0d662068
No related branches found
No related tags found
No related merge requests found
...@@ -65,9 +65,10 @@ class Conveyor(object): ...@@ -65,9 +65,10 @@ class Conveyor(object):
self.K = hashlib.sha256(py23_bytes('steem_jsonrpc_auth', self.K = hashlib.sha256(py23_bytes('steem_jsonrpc_auth',
self.ENCODING)).digest() self.ENCODING)).digest()
def hash_message(self, timestamp, account, method, params, nonce): def prehash_message(self, timestamp, account, method, params, nonce):
""" Hash a Conveyor API request with SHA256 according to """ Prepare a hash for the Conveyor API request with SHA256 according
https://github.com/steemit/rpc-auth to https://github.com/steemit/rpc-auth
Hashing of `second` is then done inside `ecdsasig.sign_message()`.
:param str timestamp: valid iso8601 datetime ending in "Z" :param str timestamp: valid iso8601 datetime ending in "Z"
:param str account: valid steem blockchain account name :param str account: valid steem blockchain account name
...@@ -78,8 +79,7 @@ class Conveyor(object): ...@@ -78,8 +79,7 @@ class Conveyor(object):
""" """
first = hashlib.sha256(py23_bytes(timestamp + account + method + first = hashlib.sha256(py23_bytes(timestamp + account + method +
params, self.ENCODING)) params, self.ENCODING))
second = hashlib.sha256(self.K + first.digest() + nonce) return self.K + first.digest() + nonce
return second.digest()
def _request(self, account, method, params, key): def _request(self, account, method, params, key):
"""Assemble the request, hash it, sign it and send it to the Conveyor """Assemble the request, hash it, sign it and send it to the Conveyor
...@@ -98,9 +98,9 @@ class Conveyor(object): ...@@ -98,9 +98,9 @@ class Conveyor(object):
nonce_bytes = struct.pack('>Q', nonce_int) # 64bit ULL, big endian nonce_bytes = struct.pack('>Q', nonce_int) # 64bit ULL, big endian
nonce_str = "%016x" % (nonce_int) nonce_str = "%016x" % (nonce_int)
message = self.hash_message(timestamp, account, method, message = self.prehash_message(timestamp, account, method,
params_enc, nonce_bytes) params_enc, nonce_bytes)
signature = sign_message(message, key, hashfn=None) signature = sign_message(message, key)
signature_hex = hexlify(signature).decode(self.ENCODING) signature_hex = hexlify(signature).decode(self.ENCODING)
request = { request = {
......
...@@ -149,10 +149,7 @@ def sign_message(message, wif, hashfn=hashlib.sha256): ...@@ -149,10 +149,7 @@ def sign_message(message, wif, hashfn=hashlib.sha256):
if not isinstance(message, bytes_types): if not isinstance(message, bytes_types):
message = py23_bytes(message, "utf-8") message = py23_bytes(message, "utf-8")
if hashfn is not None: digest = hashfn(message).digest()
digest = hashfn(message).digest()
else:
digest = message
priv_key = PrivateKey(wif) priv_key = PrivateKey(wif)
if SECP256K1_MODULE == "secp256k1": if SECP256K1_MODULE == "secp256k1":
p = py23_bytes(priv_key) p = py23_bytes(priv_key)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment