MCPcopy Create free account
hub / github.com/ElementsProject/elements / descsum_check

Function descsum_check

test/functional/test_framework/descriptors.py:48–57  ·  view source on GitHub ↗

Verify that the checksum is correct in a descriptor

(s, require=True)

Source from the content-addressed store, hash-verified

46 return s + '#' + ''.join(CHECKSUM_CHARSET[(checksum >> (5 * (7 - i))) & 31] for i in range(8))
47
48def descsum_check(s, require=True):
49 """Verify that the checksum is correct in a descriptor"""
50 if not '#' in s:
51 return not require
52 if s[-9] != '#':
53 return False
54 if not all(x in CHECKSUM_CHARSET for x in s[-8:]):
55 return False
56 symbols = descsum_expand(s[:-9]) + [CHECKSUM_CHARSET.find(x) for x in s[-8:]]
57 return descsum_polymod(symbols) == 1
58
59def drop_origins(s):
60 '''Drop the key origins from a descriptor'''

Callers 1

test_descMethod · 0.90

Calls 3

findMethod · 0.80
descsum_expandFunction · 0.70
descsum_polymodFunction · 0.70

Tested by 1

test_descMethod · 0.72