Verify a checksum. */
| 116 | |
| 117 | /** Verify a checksum. */ |
| 118 | bool VerifyChecksum(const std::string& hrp, const data& values) |
| 119 | { |
| 120 | // PolyMod computes what value to xor into the final values to make the checksum 0. However, |
| 121 | // if we required that the checksum was 0, it would be the case that appending a 0 to a valid |
| 122 | // list of values would result in a new valid list. For that reason, Bech32 requires the |
| 123 | // resulting checksum to be 1 instead. |
| 124 | return PolyMod(Cat(ExpandHRP(hrp), values)) == 1; |
| 125 | } |
| 126 | |
| 127 | /** Create a checksum. */ |
| 128 | data CreateChecksum(const std::string& hrp, const data& values) |