Skip to main content

LinearCode

Trait LinearCode 

Source
pub trait LinearCode<Zt: ZipTypes>:
    Debug
    + Clone
    + Eq
    + Sync
    + Send {
    const REPETITION_FACTOR: usize;

    // Required methods
    fn row_len(&self) -> usize;
    fn codeword_len(&self) -> usize;
    fn params_string(&self) -> String;
    fn encode(&self, row: &[Zt::Eval]) -> Vec<Zt::Cw>;
    fn encode_wide(&self, row: &[Zt::CombR]) -> Vec<Zt::CombR>;
    fn encode_f<F>(&self, row: &[F]) -> Vec<F>
       where F: FromPrimitiveWithConfig + FromRef<F>;
}

Required Associated Constants§

Source

const REPETITION_FACTOR: usize

Repetition factor, a.k.a. inverse rate, the ratio of codeword length to input row length. Has to be at a power of 2.

Note: Ideally, this should be a generic constant, but due to the fact that generic parameters may not be used in const operations, this makes using it too much of a hassle.

Required Methods§

Source

fn row_len(&self) -> usize

Length of each input row before encoding

Source

fn codeword_len(&self) -> usize

Length of each encoded codeword (output length after encoding)

Source

fn params_string(&self) -> String

String representation of the parameters of this linear code, used for benchmarks. Should start with “row_len=X”.

Source

fn encode(&self, row: &[Zt::Eval]) -> Vec<Zt::Cw>

Encodes a row of cryptographic integers using this linear encoding scheme.

This function is optimized for the prover’s context where we work with cryptographic integers. It’s more efficient than encode_f as it avoids field conversions.

§Parameters
  • row: Slice of cryptographic integers to encode
§Returns

A vector of cryptographic integers representing the encoded row

Source

fn encode_wide(&self, row: &[Zt::CombR]) -> Vec<Zt::CombR>

Encodes a row of cryptographic integers using this linear encoding scheme.

This function is optimized for the prover’s context where we work with cryptographic integers. It’s more efficient than encode_f as it avoids field conversions.

§Parameters
  • row: Slice of cryptographic integers to encode
§Returns

A vector of cryptographic integers representing the encoded row

Source

fn encode_f<F>(&self, row: &[F]) -> Vec<F>
where F: FromPrimitiveWithConfig + FromRef<F>,

Encodes a row of field elements using this linear encoding scheme.

This function is used when working with field elements directly and performs the encoding by first converting the sparse matrices to field elements.

§Parameters
  • row: Slice of field elements to encode
  • field: Field configuration for the conversion
§Returns

A vector of field elements representing the encoded row

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Zt, Config, const REP: usize, const CHECK: bool> LinearCode<Zt> for IprsCode<Zt, Config, REP, CHECK>
where Zt: ZipTypes, Config: PnttConfig, Zt::Eval: for<'a> MulByScalar<&'a PnttInt, Zt::Cw>, Zt::CombR: for<'a> MulByScalar<&'a PnttInt>, Zt::Cw: CheckedAdd + for<'a> MulByScalar<&'a PnttInt>,

Source§

impl<Zt: ZipTypes, Config: RaaConfig, const REP: usize> LinearCode<Zt> for RaaCode<Zt, Config, REP>

Source§

impl<Zt: ZipTypes, Config: RaaConfig, const REP: usize> LinearCode<Zt> for RaaSignFlippingCode<Zt, Config, REP>
where Zt::Cw: Ring,