Function bitcoin_signingprovider::poly_mod
source · pub fn poly_mod(c: u64, val: i32) -> u64
Expand description
| Interprets c as 8 groups of 5 bits which
| are the coefficients of a degree 8 polynomial
| over
|
| GF(32), multiplies that polynomial
| by x, computes its remainder modulo
| a generator, and adds the constant term
| val.
|
| This generator is G(x) = x^8 + {30}x^7
| + {23}x^6 + {15}x^5 + {14}x^4 + {10}x^3
| + {6}x^2 + {12}x + {9}.
|
| It is chosen to define an cyclic error
| detecting code which is selected by:
|
| - Starting from all BCH codes over GF(32)
| of degree 8 and below, which by construction
| guarantee detecting 3 errors in windows
| up to 19000 symbols.
|
| - Taking all those generators, and for
| degree 7 ones, extend them to degree
| 8 by adding all degree-1 factors.
|
| - Selecting just the set of generators
| that guarantee detecting 4 errors in
| a window of length 512.
|
| - Selecting one of those with best worst-case
| behavior for 5 errors in windows of length
| up to 512.
|
| The generator and the constants to implement
| it can be verified using this Sage code:
|
| ———–
| @code
|
| B = GF(2) # Binary field
| BP. = B[] # Polynomials over the binary field
| F_mod = b5 + b3 + 1
| F.