-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement error correction #205
Merged
apoelstra
merged 7 commits into
rust-bitcoin:master
from
apoelstra:2024-03--error-correction2
Oct 18, 2024
Merged
Implement error correction #205
apoelstra
merged 7 commits into
rust-bitcoin:master
from
apoelstra:2024-03--error-correction2
Oct 18, 2024
Commits on Sep 30, 2024
-
bech32: use correct generator exponents
There are two parameterizations of the bech32 checksum (see the "roots" unit test in src/primitives/polynomial.rs for what they are). In rust-bitcoin#203 we mixed them up, using the generator from one but the exponents from the other. We made the same mistake with codex32 apparently. When we implement error correction this will cause failures. Fix it.
Configuration menu - View commit details
-
Copy full SHA for 74ec75f - Browse repository at this point
Copy the full SHA 74ec75fView commit details -
field: add ability to multiply by integers
Adds a CHARACTERISTIC constant to the Field trait, so this is yet another breaking change (though in practice I don't think anybody is implementing Field on their own types).
Configuration menu - View commit details
-
Copy full SHA for 4dfe325 - Browse repository at this point
Copy the full SHA 4dfe325View commit details -
Configuration menu - View commit details
-
Copy full SHA for fc903d6 - Browse repository at this point
Copy the full SHA fc903d6View commit details -
primitives: introduce the Berlekamp-Massey algorithm for computing li…
…near shift registers This provides a general-purpose implementation of the Berlekamp-Massey algorithm for finding a linear shift register that generates a given sequence prefix. If compiled without an allocator, it will run less efficiently (and be limited to a maximum size) but it will work. Also introduces a fuzz test to check that it works properly and does not crash.
Configuration menu - View commit details
-
Copy full SHA for 6c24f98 - Browse repository at this point
Copy the full SHA 6c24f98View commit details -
This commit pulls everything together. The actual error correction code isn't too big: we interpret a residue as a polynomial, evaluate it at various powers of alpha to get a syndrome polynomial, call berlekeamp-massey on this to get a "connection polynomial", then use Forney's algorithm to get the actual error values. Each step in the above is encapsulated separately -- the "big" stuff, in particular Berlekamp-Massey and obtaining the relevant constants from the checksum definition, were in previous commits. This PR does need to add some more functionality to Polynomial. Specifically we need the ability to evaluate polynomials, take their formal derivatives, and multiply them modulo x^d for a given d. These are the bulk of this PR. The next commit will introduce a fuzztest which hammers on the correction logic to ensure that it's not crashing.
Configuration menu - View commit details
-
Copy full SHA for 2e1b7be - Browse repository at this point
Copy the full SHA 2e1b7beView commit details -
Configuration menu - View commit details
-
Copy full SHA for 383f788 - Browse repository at this point
Copy the full SHA 383f788View commit details -
fuzz: add fuzztests that try to correct bech32 and codex32 errors
The codex32 test will more thoroughly exercise the algebra, since there we can correct up to 4 errors. The bech32 test on the other hand should work without an allocator (though to exercise this you need to manually edit fuzz/Cargo.toml to disable the alloc feature -- this is rust-lang/cargo#2980 which has been open for 10 years and counting..)
Configuration menu - View commit details
-
Copy full SHA for 76d0dae - Browse repository at this point
Copy the full SHA 76d0daeView commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.