def verify_addr(cls,addr,hex_width,return_dict=False): def b58dec(addr_str): from mmgen.util import baseconv l = len(addr_str) a = ''.join([baseconv.tohex(addr_str[i*11:i*11+11],'b58',pad=16) for i in range(l//11)]) b = baseconv.tohex(addr_str[-(l%11):],'b58',pad=10) return a + b from mmgen.util import is_b58_str assert is_b58_str(addr),'Not valid base-58 string' assert len(addr) == cls.addr_width,'Incorrect width' ret = b58dec(addr) try: assert not g.use_internal_keccak_module from sha3 import keccak_256 except: from mmgen.keccak import keccak_256 chk = keccak_256(bytes.fromhex(ret)[:-4]).hexdigest()[:8] assert chk == ret[-8:],'{}: incorrect checksum. Correct value: {}'.format(ret[-8:],chk) return { 'hex': ret, 'format': 'monero' } if return_dict else True
def verify_addr(cls, addr, hex_width, return_dict=False): def b58dec(addr_str): from mmgen.util import baseconv l = len(addr_str) a = ''.join([ baseconv.tohex(addr_str[i * 11:i * 11 + 11], 'b58', pad=16) for i in range(l // 11) ]) b = baseconv.tohex(addr_str[-(l % 11):], 'b58', pad=10) return a + b from mmgen.util import is_b58_str assert is_b58_str(addr), 'Not valid base-58 string' assert len(addr) == cls.addr_width, 'Incorrect width' ret = b58dec(addr) try: assert not g.use_internal_keccak_module from sha3 import keccak_256 except: from mmgen.keccak import keccak_256 chk = keccak_256(bytes.fromhex(ret)[:-4]).hexdigest()[:8] assert chk == ret[ -8:], '{}: incorrect checksum. Correct value: {}'.format( ret[-8:], chk) return {'hex': ret, 'format': 'monero'} if return_dict else True
def verify_addr(cls, addr, hex_width, return_dict=False): def b58dec(addr_str): from mmgen.util import baseconv dec, l = baseconv.tohex, len(addr_str) a = ''.join([ dec(addr_str[i * 11:i * 11 + 11], 'b58', pad=16) for i in range(l / 11) ]) b = dec(addr_str[-(l % 11):], 'b58', pad=10) return a + b from mmgen.util import is_b58_str assert is_b58_str(addr), 'Not valid base-58 string' assert len(addr) == cls.addr_width, 'Incorrect width' ret = b58dec(addr) import sha3 chk = sha3.keccak_256(ret.decode('hex')[:-4]).hexdigest()[:8] assert chk == ret[-8:], 'Incorrect checksum' return { 'hex': ret, 'format': 'monero', 'width': cls.addr_width } if return_dict else True