kyber_py.modules package
Submodules
kyber_py.modules.modules module
- class kyber_py.modules.modules.Matrix(parent, matrix_data, transpose=False)
Bases:
GenericMatrix- property T
Return a matrix with the rows and columns of swapped
- compress(d)
Compress every element of the matrix to have at most
dbits
- decompress(d)
Perform (lossy) decompression of the polynomial assuming it has been compressed to have at most
dbits.
- dim()
Return the dimensions of the matrix with m rows and n columns
- dot(other)
Compute the inner product of two vectors
- encode(d)
Encode every element of a matrix into bytes and concatenate
- from_ntt()
Convert every element of the matrix from NTT form
- reduce_coefficients()
Reduce every element in the polynomial using the modulus of the PolynomialRing
- to_ntt()
Convert every element of the matrix into NTT form
- transpose()
Return a matrix with the rows and columns of swapped
- transpose_self()
Swap the rows and columns of the matrix in place
- class kyber_py.modules.modules.Module
Bases:
GenericModule- decode_vector(input_bytes, k, d, is_ntt=False)
Decode bytes into a a vector of polynomial elements.
Each element is assumed to be encoded as a polynomial with
d-bit coefficients (hence a polynomial is encoded into256 * dbits).A vector of length
kthen has256 * d * kbits.
- class kyber_py.modules.modules.Vector(parent, vector_elements)
Bases:
Matrix- property T
Return a matrix with the rows and columns of swapped
- compress(d)
Compress every element of the matrix to have at most
dbits
- decompress(d)
Perform (lossy) decompression of the polynomial assuming it has been compressed to have at most
dbits.
- dim()
Return the dimensions of the matrix with m rows and n columns
- dot(other)
Compute the inner product of two vectors
- encode(d)
Encode every element of a matrix into bytes and concatenate
- from_ntt()
Convert every element of the matrix from NTT form
- reduce_coefficients()
Reduce every element in the polynomial using the modulus of the PolynomialRing
- to_ntt()
Convert every element of the matrix into NTT form
- transpose()
Return a matrix with the rows and columns of swapped
- transpose_self()
Swap the rows and columns of the matrix in place
kyber_py.modules.modules_generic module
- class kyber_py.modules.modules_generic.GenericMatrix(parent, matrix_data, transpose=False)
Bases:
object- property T
Return a matrix with the rows and columns of swapped
- dim()
Return the dimensions of the matrix with m rows and n columns
- dot(other)
Compute the inner product of two vectors
- reduce_coefficients()
Reduce every element in the polynomial using the modulus of the PolynomialRing
- transpose()
Return a matrix with the rows and columns of swapped
- transpose_self()
Swap the rows and columns of the matrix in place
- class kyber_py.modules.modules_generic.GenericModule(ring)
Bases:
object- random_element(m, n)
Generate a random element of the module of dimension m x n
- Parameters:
m (int) – the number of rows in the matrix
m – the number of columns in tge matrix
- Returns:
an element of the module with dimension m times n
- vector(elements)
Construct a vector given a list of elements of the module’s ring
- Parameters:
list – a list of elements of the ring
- Returns:
a vector of the module