Browse Source

fix crash on bad podle revelation

master
undeath 7 years ago
parent
commit
286d306ba8
No known key found for this signature in database
GPG Key ID: F0DF5443BD2F3520
  1. 12
      jmclient/jmclient/maker.py

12
jmclient/jmclient/maker.py

@ -10,7 +10,7 @@ import btc
from jmclient.configure import jm_single from jmclient.configure import jm_single
from jmbase.support import get_log from jmbase.support import get_log
from jmclient.support import (calc_cj_fee) from jmclient.support import (calc_cj_fee)
from jmclient.podle import verify_podle, PoDLE from jmclient.podle import verify_podle, PoDLE, PoDLEError
from twisted.internet import task from twisted.internet import task
jlog = get_log() jlog = get_log()
@ -43,13 +43,19 @@ class Maker(object):
"""Receives data on proposed transaction offer from daemon, verifies """Receives data on proposed transaction offer from daemon, verifies
commitment, returns necessary data to send ioauth message (utxos etc) commitment, returns necessary data to send ioauth message (utxos etc)
""" """
#deserialize the commitment revelation
cr_dict = PoDLE.deserialize_revelation(cr)
#check the validity of the proof of discrete log equivalence #check the validity of the proof of discrete log equivalence
tries = jm_single().config.getint("POLICY", "taker_utxo_retries") tries = jm_single().config.getint("POLICY", "taker_utxo_retries")
def reject(msg): def reject(msg):
jlog.info("Counterparty commitment not accepted, reason: " + msg) jlog.info("Counterparty commitment not accepted, reason: " + msg)
return (False,) return (False,)
# deserialize the commitment revelation
try:
cr_dict = PoDLE.deserialize_revelation(cr)
except PoDLEError as e:
reason = repr(e)
return reject(reason)
if not verify_podle(str(cr_dict['P']), str(cr_dict['P2']), str(cr_dict['sig']), if not verify_podle(str(cr_dict['P']), str(cr_dict['P2']), str(cr_dict['sig']),
str(cr_dict['e']), str(commitment), str(cr_dict['e']), str(commitment),
index_range=range(tries)): index_range=range(tries)):

Loading…
Cancel
Save