|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | + |
| 3 | +//! Error Correction |
| 4 | +//! |
| 5 | +//! Implements the Berlekamp-Massey algorithm to locate errors, with Forney's |
| 6 | +//! equation to identify the error values, in a BCH-encoded string. |
| 7 | +//! |
| 8 | +
|
| 9 | +/// **One more than** the maximum length (in characters) of a checksum which |
| 10 | +/// can be error-corrected without an allocator. |
| 11 | +/// |
| 12 | +/// When the **alloc** feature is enabled, this constant is practically irrelevant. |
| 13 | +/// When the feature is disabled, it represents a length beyond which this library |
| 14 | +/// does not support error correction. |
| 15 | +/// |
| 16 | +/// If you need this value to be increased, please file an issue describing your |
| 17 | +/// usecase. Bear in mind that an increased value will increase memory usage for |
| 18 | +/// all users, and the focus of this library is the Bitcoin ecosystem, so we may |
| 19 | +/// not be able to accept your request. |
| 20 | +// This constant is also used when comparing bech32 residues against the |
| 21 | +// bech32/bech32m targets, which should work with no-alloc. Therefore this |
| 22 | +// constant must be > 6 (the length of the bech32(m) checksum). |
| 23 | +// |
| 24 | +// Otherwise it basically represents a tradeoff between stack usage and the |
| 25 | +// size of error types, vs functionality in a no-alloc setting. The value |
| 26 | +// of 7 covers bech32 and bech32m. To get the descriptor checksum we need a |
| 27 | +// value and the descriptor checksum. To also get codex32 it should be >13, |
| 28 | +// and for "long codex32" >15 ... but consider that no-alloc contexts are |
| 29 | +// likely to be underpowered and will struggle to do correction on these |
| 30 | +// big codes anyway. |
| 31 | +// |
| 32 | +// Perhaps we will want to add a feature gate, off by default, that boosts |
| 33 | +// this to 16, or maybe even higher. But we will wait for implementors who |
| 34 | +// complain. |
| 35 | +pub const NO_ALLOC_MAX_LENGTH: usize = 7; |
0 commit comments