pub trait LinearCode {
type P: PackedField;
type EncodeError: Error + Send + Sync + 'static;
// Required methods
fn dim_bits(&self) -> usize;
fn min_dist(&self) -> usize;
fn inv_rate(&self) -> usize;
fn encode_batch_inplace(
&self,
code: &mut [Self::P],
log_batch_size: usize,
) -> Result<(), Self::EncodeError>;
// Provided methods
fn len(&self) -> usize { ... }
fn dim(&self) -> usize { ... }
fn encode_inplace(
&self,
code: &mut [Self::P],
) -> Result<(), Self::EncodeError> { ... }
fn encode(
&self,
msg: Vec<Self::P>,
) -> Result<Vec<Self::P>, Self::EncodeError> { ... }
fn encode_ext_batch_inplace<PE>(
&self,
code: &mut [PE],
log_batch_size: usize,
) -> Result<(), Self::EncodeError>
where PE: RepackedExtension<Self::P>,
PE::Scalar: ExtensionField<<Self::P as PackedField>::Scalar> { ... }
fn encode_ext_inplace<PE>(
&self,
code: &mut [PE],
) -> Result<(), Self::EncodeError>
where PE: RepackedExtension<Self::P>,
PE::Scalar: ExtensionField<<Self::P as PackedField>::Scalar> { ... }
fn encode_extension<PE>(
&self,
msg: Vec<PE>,
) -> Result<Vec<PE>, Self::EncodeError>
where PE: RepackedExtension<Self::P>,
PE::Scalar: ExtensionField<<Self::P as PackedField>::Scalar> { ... }
}
Expand description
An encodable linear error-correcting code intended for use in a Brakedown-style polynomial commitment scheme.
This trait represents linear codes with a dimension that is a power of 2, as that property is required for the Brakedown polynomial commitment scheme.
Requirements:
len()
is a multiple ofdim()
dim()
is a power of 2dim()
is a multiple ofP::WIDTH
Required Associated Types§
type P: PackedField
type EncodeError: Error + Send + Sync + 'static
Required Methods§
sourcefn encode_batch_inplace(
&self,
code: &mut [Self::P],
log_batch_size: usize,
) -> Result<(), Self::EncodeError>
fn encode_batch_inplace( &self, code: &mut [Self::P], log_batch_size: usize, ) -> Result<(), Self::EncodeError>
Encode a batch of interleaved messages in-place in a provided buffer.
The message symbols are interleaved in the buffer, which improves the cache-efficiency of the encoding procedure. The interleaved codeword is stored in the buffer when the method completes.
§Throws
- If the
code
buffer does not have capacity forlen() << log_batch_size
field elements.
Provided Methods§
sourcefn encode_inplace(&self, code: &mut [Self::P]) -> Result<(), Self::EncodeError>
fn encode_inplace(&self, code: &mut [Self::P]) -> Result<(), Self::EncodeError>
Encode a message in-place in a provided buffer.
§Throws
- If the
code
buffer does not have capacity forlen()
field elements.
sourcefn encode(&self, msg: Vec<Self::P>) -> Result<Vec<Self::P>, Self::EncodeError>
fn encode(&self, msg: Vec<Self::P>) -> Result<Vec<Self::P>, Self::EncodeError>
Encode a message provided as a vector of packed field elements.
sourcefn encode_ext_batch_inplace<PE>(
&self,
code: &mut [PE],
log_batch_size: usize,
) -> Result<(), Self::EncodeError>
fn encode_ext_batch_inplace<PE>( &self, code: &mut [PE], log_batch_size: usize, ) -> Result<(), Self::EncodeError>
Encode a batch of interleaved messages of extension field elements in-place in a provided buffer.
A linear code can be naturally extended to a code over extension fields by encoding each dimension of the extension as a vector-space separately.
§Preconditions
PE::Scalar::DEGREE
must be a power of two.
§Throws
- If the
code
buffer does not have capacity forlen() << log_batch_size
field elements.
sourcefn encode_ext_inplace<PE>(
&self,
code: &mut [PE],
) -> Result<(), Self::EncodeError>
fn encode_ext_inplace<PE>( &self, code: &mut [PE], ) -> Result<(), Self::EncodeError>
Encode a message of extension field elements in-place in a provided buffer.
See Self::encode_ext_batch_inplace
for more details.
§Throws
- If the
code
buffer does not have capacity forlen()
field elements.
sourcefn encode_extension<PE>(
&self,
msg: Vec<PE>,
) -> Result<Vec<PE>, Self::EncodeError>
fn encode_extension<PE>( &self, msg: Vec<PE>, ) -> Result<Vec<PE>, Self::EncodeError>
Encode a message of extension field elements provided as a vector of packed field elements.
See [Self::encode_extension_inplace
] for more details.