pub trait Encoder<F: Field> {
// Required method
fn encode_batch(
&self,
message: RowMajorMatrix<F>,
log_inv_rate: usize,
) -> RowMajorMatrix<F>;
// Provided method
fn encode_batch_padded(
&self,
message: RowMajorMatrix<F>,
log_inv_rate: usize,
) -> RowMajorMatrix<F> { ... }
}Expand description
A linear code applied to every column of a matrix.
The blanket impl below covers every TwoAdicSubgroupDft, which restricts what an
implementor may write: impl<F: Field> Encoder<F> for MyEncoder overlaps it and is rejected
(E0119), since a downstream crate could implement TwoAdicSubgroupDft for MyEncoder. An
impl must therefore name the concrete field(s) it encodes over, as in
impl Encoder<MyField> for MyEncoder.
The randomized counterpart is p3_zk_codes::ZkEncoding, whose codewords additionally hide the
message from a bounded number of queries.
Required Methods§
Sourcefn encode_batch(
&self,
message: RowMajorMatrix<F>,
log_inv_rate: usize,
) -> RowMajorMatrix<F>
fn encode_batch( &self, message: RowMajorMatrix<F>, log_inv_rate: usize, ) -> RowMajorMatrix<F>
Encodes each column of message into a codeword.
message has height 2^k; the result has the same width and height
2^(k + log_inv_rate). Output row i is codeword symbol i.
§Panics
Panics if the height of message is not a power of two, or if the codeword height
2^(k + log_inv_rate) overflows usize.
Provided Methods§
Sourcefn encode_batch_padded(
&self,
message: RowMajorMatrix<F>,
log_inv_rate: usize,
) -> RowMajorMatrix<F>
fn encode_batch_padded( &self, message: RowMajorMatrix<F>, log_inv_rate: usize, ) -> RowMajorMatrix<F>
Encodes a coefficient matrix already padded to its final height.
The original message occupies the first height / 2^log_inv_rate rows; the
caller must set the remaining entries to zero. Implementations may ignore
that tail and use the rate to avoid work on zero coefficients.
The default preserves the ordinary transform of the full padded matrix.
§Panics
Panics if the height is not a power of two or the padding exceeds its height.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<F: TwoAdicField, D: TwoAdicSubgroupDft<F>> Encoder<F> for D
Reed-Solomon over the two-adic subgroup of order 2^(k + log_inv_rate): each column of
message is the low-degree coefficient vector of a polynomial, and the codeword is its
evaluation vector on that subgroup.