Verify that the checksum is correct in a descriptor
(s, require=True)
| 46 | return s + '#' + ''.join(CHECKSUM_CHARSET[(checksum >> (5 * (7 - i))) & 31] for i in range(8)) |
| 47 | |
| 48 | def 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 | |
| 59 | def drop_origins(s): |
| 60 | '''Drop the key origins from a descriptor''' |