def __init__(self, wallet): self.wallet = wallet self.account = self.wallet.accounts.default_account self.public_key = ECCipher.serialize_public_key(self.account.public_key) self.url = config.market.market_url_test self.token = '' self.nonce = ''
def setUp(self): private_key_file_path1 = join_with_root(private_key_file1) private_key_file_path2 = join_with_root(private_key_file2) password_path = join_with_root(private_key_password_file) with open(password_path) as f: password = f.read() self.pri_key, self.pub_key = ECCipher.load_key_pair(private_key_file_path1, password) self.pri_key_2, self.pub_key_2 = ECCipher.load_key_pair(private_key_file_path2, password) self.pub_key_string = ECCipher.serialize_public_key(self.pub_key) self.pub_key_string2 = ECCipher.serialize_public_key(self.pub_key_2) self.address = ECCipher.get_address_from_public_key(self.pub_key) self.address_2 = ECCipher.get_address_from_public_key(self.pub_key_2)
def mockup_product(self): private_key = ECCipher.create_private_key(self.account.privateKey) public_key = ECCipher.create_public_key_from_private_key(private_key) public_key = ECCipher.serialize_public_key(public_key) price = randint(1, 10000) * 0.01 return { 'description': 'stress testing description', 'signature': '304502201b31544ff65ebbfff3743a0b2536388e1f6cf2533de4bbf0ffab57d762f54d50022100a8101face8c6a6d2f0e01a9a01ea49d80598c880872db9e3c1e9eb27a23a2554', 'cover_image': 'upload_images/20181127072441_13.png', 'end_date': '2018-12-04T15:24:41.664517Z', 'msg_hash': 'dRFWYcWC9TKujDo7mLiUCq00MthHezzkyncAGIdaEos=', 'id': 53, 'start_date': '2018-11-27T15:24:41.664517Z', 'ptype': 'file', 'seq': 0, 'owner_address': public_key, 'tags': 'stress testing tags', 'price': price, 'title': 'stress testing product', 'category': 'stress testing category', 'status': 0, 'created': '2018-11-27T07:24:41.715315Z' }
def __init__(self, wallet, account=None): self.wallet = wallet self.account = account or self.wallet.accounts.default_account self.public_key = ECCipher.serialize_public_key( self.account.public_key) if self.account else None self.url = config.market.market_url + '/' self.token = '' self.nonce = ''
def exec_(): account = import_account(self.file.file, self.password.value) self.username.account = account def cb(status): self.imported.emit(status) public_key = ECCipher.serialize_public_key(account.public_key) wallet.market_client.isRegistered(public_key).addCallbacks(cb)
def __login(account=None): if account is None: wallet.accounts.set_default_account(1) account = wallet.accounts.default_account public_key = ECCipher.serialize_public_key(account.public_key) addr = utils.get_address_from_public_key_object(public_key) addr = web3.toChecksumAddress(addr) app.addr = addr if isinstance(account.key_passphrase, str): app.pwd = account.key_passphrase else: app.pwd = account.key_passphrase.decode() wallet.market_client.account = account wallet.market_client.public_key = ECCipher.serialize_public_key( wallet.market_client.account.public_key) wallet.market_client.login(app.username).addCallbacks( lambda _: event.emit(events.LOGIN_COMPLETED)) wallet.init() initialize_system() app.router.redirectTo('market_page')
def sign_proxy_data(data): public_key = _proxy_account.public_key private_key = _proxy_account.private_key signature = ECCipher.create_signature(private_key, data) msg = { 'data': data, 'public_key': ECCipher.serialize_public_key(public_key), 'signature': signature } return packb(msg, use_bin_type=True)
def login(): path = os.path.expanduser('~/.cpchain') if not os.path.exists(path): os.mkdir(path) with shelve.open(os.path.join(path, 'account')) as file: key_path = file.get('key_path') key_passphrase = file.get('key_passphrase') try: app.timing(logger, 'Data Init') if key_path and key_passphrase: if isinstance(key_passphrase, str): account = Account(key_path, key_passphrase.encode()) else: account = Account(key_path, key_passphrase) public_key = ECCipher.serialize_public_key(account.public_key) # Init market client account wallet.market_client.account = account wallet.market_client.public_key = public_key app.timing(logger, 'Account Prepare') addr = utils.get_address_from_public_key_object(public_key) addr = web3.toChecksumAddress(addr) logger.info(addr) app.addr = addr if isinstance(key_passphrase, str): app.pwd = key_passphrase else: app.pwd = key_passphrase.decode() wallet.market_client.query_username(app) __unlock() app.timing(logger, 'Unlock') enterPDash(account) return except Exception as e: logger.error(e) logger.debug('Init') wnd = LoginWindow(reactor) wnd.show() wallet.set_main_wnd(wnd)
"ciphertext": "b47aed1b93acaa270d14f3dce9084cb073e67dbe687340f75845817d4668e6fe", "cipher": "aes-128-ctr" } } keystore = '/tmp/keystore' with open(keystore, 'w') as f: f.write(json.dumps(encrypted_key)) buyer_account = Account(keystore, b'passwd') seller_account = Account(keystore, b'passwd') buyer_private_key = buyer_account.private_key #object type buyer_public_key = ECCipher.serialize_public_key( buyer_account.public_key) # string type buyer_addr = ECCipher.get_address_from_public_key( buyer_account.public_key) #string type seller_private_key = seller_account.private_key seller_public_key = ECCipher.serialize_public_key( seller_account.public_key) #string type seller_addr = ECCipher.get_address_from_public_key( seller_account.public_key) #string type order_id = 1 order_type = 'file' def fake_seller_message(): message = Message()
def __init__(self, eth_account): self.private_key = ECCipher.create_private_key(eth_account.privateKey) public_key = ECCipher.create_public_key_from_private_key(self.private_key) self.public_key = ECCipher.serialize_public_key(public_key) # self.address = eth_account.address self.address = ECCipher.get_address_from_public_key(public_key)