Skip to content

Commit

Permalink
Closes #105 for UTXQ/MTXQ
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankC01 committed Jul 26, 2018
1 parent 55179ed commit ee8eff4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/shared/exchange.py
Expand Up @@ -29,6 +29,7 @@
from modules.config import (
public_key, private_key,
keys_path,
HB_OPERATOR,
valid_partnership, partnership_secret)
from modules.decode import (
asset_addresser,
Expand Down Expand Up @@ -208,7 +209,7 @@ def __create_initiate_payload(ingest):
data.SerializeToString(),
private_key(request['plus']),
public_key(request['minus'])))
return (request['plus'], ExchangePayload(
return (HB_OPERATOR, ExchangePayload(
udata=encrypted,
ukey=utxq_addresser.utxq_unmatched(
Duality.breakqname(operation), str(uuid.uuid4())),
Expand All @@ -220,7 +221,6 @@ def __create_initiate_inputs_outputs(ingest):
signer, payload = ingest
inputs = []
outputs = [payload.ukey]
print("NEW INITIATE ADDRESS => {}".format(payload.ukey))
return (
signer,
utxq_addresser,
Expand Down Expand Up @@ -260,7 +260,7 @@ def __create_reciprocate_payload(ingest):
payload.SerializeToString(),
private_key(request['plus']),
public_key(request['minus'])))
return (request['plus'], ExchangePayload(
return (HB_OPERATOR, ExchangePayload(
type=ExchangePayload.MTXQ,
ukey=matched_uaddr,
mkey=mtxq_addresser.mtxq_address(
Expand Down
17 changes: 17 additions & 0 deletions modules/config.py
Expand Up @@ -29,6 +29,7 @@

REST_CONFIG = None
KEYS_PATH = None
HB_OPERATOR = '__ZZZ_fff_hashblock_OPERATOR'
ENVIRONMENT_KEYS_PATH = 'HASHBLOCK_KEYS'
ENVIRONMENT_CFGR_PATH = 'HASHBLOCK_CONFIG'
DUALITIES_SPECIFICATIONS = "dualities.yaml"
Expand Down Expand Up @@ -193,6 +194,16 @@ def __read_signer(signing_key):
return crypto_factory.new_signer(private_key)


def __fabricate_signer():
"""Fabricate private, public and signer keys"""
context = create_context('secp256k1')
private_key = context.new_random_private_key()
public_key = context.get_public_key(private_key)
crypto_factory = CryptoFactory(context)
signer_key = crypto_factory.new_signer(private_key)
return (public_key.as_hex(), private_key.as_hex(), signer_key)


def __load_cfg_and_keys(configfile):
"""Reads the configuration file and converts any priv keys to public"""
print("Reading {} from {}".format(configfile, DEFAULT_CFGR_PATH))
Expand All @@ -215,6 +226,12 @@ def __load_cfg_and_keys(configfile):
signer_keys[key] = public
submitter_keys[key] = __read_signer(private)

public, private, signer = __fabricate_signer()
public_keys[HB_OPERATOR] = public
private_keys[HB_OPERATOR] = private
signer_keys[HB_OPERATOR] = public
submitter_keys[HB_OPERATOR] = signer

doc['rest']['public_keys'] = public_keys
doc['rest']['private_keys'] = private_keys
doc['rest']['signer_keys'] = signer_keys
Expand Down

0 comments on commit ee8eff4

Please sign in to comment.