Skip to main content

Module codec

Module codec 

Source
Expand description

Encoding/decoding for Falcon keys and signatures. Ported from codec.c.

Statics§

MAX_FG_BITS
Maximum number of bits for f, g coefficients.
MAX_FG_BITS_UPPER
Maximum number of bits for F, G coefficients.
MAX_SIG_BITS
Maximum number of bits for signature coefficients (including sign bit).

Functions§

comp_decode
Decode compressed signature coefficients. Returns bytes consumed, or 0 on error.
comp_encode
Encode signature coefficients using compressed format. Values must be in -2047..+2047 range. Returns bytes written, or 0 on error. If out is None, computes and returns the required length.
modq_decode
Decode packed 14-bit mod-q values into a polynomial. Returns the number of bytes consumed, or 0 on error.
modq_encode
Encode a polynomial of mod-q values into packed 14-bit format. Returns the number of bytes written, or 0 on error. If out is None, returns the required output length.
trim_i8_decode
Decode variable-width signed 8-bit integers. Returns bytes consumed, or 0 on error.
trim_i8_encode
Encode signed 8-bit integers with a given bit width. Returns bytes written, or 0 on error. If out is None, returns the required output length.
trim_i16_decode
Decode variable-width signed 16-bit integers. Returns bytes consumed, or 0 on error.
trim_i16_encode
Encode signed 16-bit integers with a given bit width. Returns bytes written, or 0 on error. If out is None, returns the required output length.