def auth_counterparty(self, nick, btc_sig, cj_pub): """Validate the counterpartys claim to own the btc address/pubkey that will be used for coinjoining with an ecdsa verification.""" # crypto_boxes[nick][0] = maker_pubkey if not btc.ecdsa_verify(self.crypto_boxes[nick][0], btc_sig, cj_pub): log.debug('signature didnt match pubkey and message') return False return True
def auth_counterparty(self, btc_sig, auth_pub, maker_pk): """Validate the counterpartys claim to own the btc address/pubkey that will be used for coinjoining with an ecdsa verification. """ try: if not btc.ecdsa_verify(maker_pk, btc_sig, auth_pub): jlog.debug('signature didnt match pubkey and message') return False except Exception as e: jlog.info("Failed ecdsa verify for maker pubkey: " + str(maker_pk)) jlog.info("Exception was: " + repr(e)) return False return True
def auth_counterparty(self, nick, i_utxo_pubkey, btc_sig): self.i_utxo_pubkey = i_utxo_pubkey if not btc.ecdsa_verify(self.taker_pk, btc_sig, self.i_utxo_pubkey): print('signature didnt match pubkey and message') return False # authorisation of taker passed # (but input utxo pubkey is checked in verify_unsigned_tx). # Send auth request to taker # TODO the next 2 lines are a little inefficient. btc_key = self.maker.wallet.get_key_from_addr(self.cj_addr) btc_pub = btc.privtopub(btc_key) btc_sig = btc.ecdsa_sign(self.kp.hex_pk(), btc_key) self.maker.msgchan.send_ioauth(nick, self.utxos.keys(), btc_pub, self.change_addr, btc_sig) return True
def on_JM_REQUEST_MSGSIG_VERIFY(self, msg, fullmsg, sig, pubkey, nick, hashlen, max_encoded, hostid): verif_result = True if not btc.ecdsa_verify(str(msg), sig, pubkey): jlog.debug("nick signature verification failed, ignoring.") verif_result = False #check that nick matches hash of pubkey nick_pkh_raw = hashlib.sha256(pubkey).digest()[:hashlen] nick_stripped = nick[2:2 + max_encoded] #strip right padding nick_unpadded = ''.join([x for x in nick_stripped if x != 'O']) if not nick_unpadded == btc.changebase(nick_pkh_raw, 256, 58): jlog.debug("Nick hash check failed, expected: " + str(nick_unpadded) + ", got: " + str(btc.changebase(nick_pkh_raw, 256, 58))) verif_result = False d = self.callRemote(commands.JMMsgSignatureVerify, verif_result=verif_result, nick=nick, fullmsg=fullmsg, hostid=hostid) self.defaultCallbacks(d) return {'accepted': True}