binius_core::linear_code

Trait LinearCode

source
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 of dim()
  • dim() is a power of 2
  • dim() is a multiple of P::WIDTH

Required Associated Types§

Required Methods§

source

fn dim_bits(&self) -> usize

The base-2 log of the dimension.

source

fn min_dist(&self) -> usize

The minimum distance between codewords.

source

fn inv_rate(&self) -> usize

The reciprocal of the rate, ie. self.len() / self.dim().

source

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 for len() << log_batch_size field elements.

Provided Methods§

source

fn len(&self) -> usize

The block length.

source

fn dim(&self) -> usize

The dimension.

source

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 for len() field elements.
source

fn encode(&self, msg: Vec<Self::P>) -> Result<Vec<Self::P>, Self::EncodeError>

Encode a message provided as a vector of packed field elements.

source

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>,

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 for len() << log_batch_size field elements.
source

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>,

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 for len() field elements.
source

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>,

Encode a message of extension field elements provided as a vector of packed field elements.

See [Self::encode_extension_inplace] for more details.

Object Safety§

This trait is not object safe.

Implementors§