extend bitcoin: URI with signature data, instead of serialized format
This commit is contained in:
@@ -318,7 +318,6 @@ def sign_request_with_alias(pr, alias, alias_privkey):
|
||||
address = bitcoin.address_from_private_key(alias_privkey)
|
||||
compressed = bitcoin.is_compressed(alias_privkey)
|
||||
pr.signature = ec_key.sign_message(message, compressed, address)
|
||||
return pr
|
||||
|
||||
|
||||
def sign_request_with_x509(pr, key_path, cert_path):
|
||||
@@ -336,14 +335,13 @@ def sign_request_with_x509(pr, key_path, cert_path):
|
||||
hashBytes = bytearray(hashlib.sha256(msgBytes).digest())
|
||||
sig = rsakey.sign(x509.PREFIX_RSA_SHA256 + hashBytes)
|
||||
pr.signature = bytes(sig)
|
||||
return pr
|
||||
|
||||
|
||||
def serialize_request(req):
|
||||
pr = make_unsigned_request(req)
|
||||
signature = req.get('signature')
|
||||
if signature:
|
||||
requestor = req.get('requestor')
|
||||
signature = req.get('sig')
|
||||
requestor = req.get('id')
|
||||
if requestor and signature:
|
||||
pr.signature = signature.decode('hex')
|
||||
pr.pki_type = 'dnssec+btc'
|
||||
pr.pki_data = str(requestor)
|
||||
|
||||
11
lib/util.py
11
lib/util.py
@@ -261,7 +261,7 @@ def parse_URI(uri):
|
||||
for k, v in pq.items():
|
||||
if len(v)!=1:
|
||||
raise Exception('Duplicate Key', k)
|
||||
if k not in ['amount', 'label', 'message', 'r', 's']:
|
||||
if k not in ['amount', 'label', 'message', 'r', 'id', 'sig', 'timestamp', 'expiration']:
|
||||
raise BaseException('Unknown key', k)
|
||||
|
||||
out = {k: v[0] for k, v in pq.items()}
|
||||
@@ -276,9 +276,16 @@ def parse_URI(uri):
|
||||
amount = Decimal(m.group(1)) * pow( Decimal(10) , k)
|
||||
else:
|
||||
amount = Decimal(am) * COIN
|
||||
out['amount'] = amount
|
||||
out['amount'] = int(amount)
|
||||
if 'message' in out:
|
||||
out['message'] = out['message'].decode('utf8')
|
||||
out['memo'] = out['message']
|
||||
if 'timestamp' in out:
|
||||
out['timestamp'] = int(out['timestamp'])
|
||||
out['expiration'] = int(out['expiration'])
|
||||
if 'sig' in out:
|
||||
out['sig'] = bitcoin.base_decode(out['sig'], None, base=58).encode('hex')
|
||||
|
||||
return out
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user