PyPoly¶
- class Pyfhel.PyPoly(PyPoly other=None, PyCtxt ref=None, PyPtxt ptxt=None, size_t index=0)¶
Bases:
objectPolynomial class of Pyfhel with the underlying data of a PyCtxt/PyPtxt.
- __init__()¶
Initializes a PyPoly polynomial.
- To fill the polynomial during initialization you can either:
Provide a PyPoly to deep copy.
- Provide a reference PyCtxt and (optionally) an index for the i-th
polynomial in the cipertext or (optionally) a source PyPtxt.
Methods
__add__(self, PyPoly other)Sums this pollynomial with another polynomial.
__sub__(self, other)Subtracts other polynomial from this polynomial.
__mul__(self, other)Multiplies this polynomial with another polynomial.
__invert__(self)Inverts this polynomial.
__repr__()Return repr(self).
__init__Initializes a PyPoly polynomial.
check_afpoly(self)Checks if afpoly was initialized or not
from_bytes(self, bytes content, encoding)from_bytes(bytes content)
from_coeff_list(self, ...)Sets all the coefficients at once.
get_coeff(self, size_t i)Gets the chosen coefficient in position i.
load(self, str fileName, encoding)load(self, str fileName, encoding)
save(self, str fileName)save(str fileName)
set_coeff(self, cy_complex coeff, size_t i)Sets the given complex value as coefficient in position i.
to_bytes(self)to_bytes()
to_coeff_list(self)List of complex coefficients of the polynomial
Attributes
coeff_countcoeff_modulus_countAPI description
- __add__(self, PyPoly other)¶
Sums this pollynomial with another polynomial.
Sums with a PyPoly, storing the result in a new PyPoly.
- Parameters:
other (PyPoly) – Second summand.
- Returns:
Polynomial resulting of addition.
- Return type:
See also
- __invert__(self)¶
Inverts this polynomial.
See also
- __mul__(self, other)¶
Multiplies this polynomial with another polynomial.
Multiplies with a PyPoly, storing the result in a new PyPoly.
- Parameters:
other (PyPoly) – multiplier polynomial.
- Returns:
Polynomial resulting of multiplication.
- Return type:
See also
- __repr__()¶
Return repr(self).
- __sub__(self, other)¶
Subtracts other polynomial from this polynomial.
Subtracts with a PyPoly, storing the result in this PyPoly.
- Parameters:
other (PyPoly) – Substrahend, to be subtracted from this polynomial.
- Returns:
Polynomial resulting of subtraction.
- Return type:
See also
- check_afpoly(self) void¶
Checks if afpoly was initialized or not
- from_bytes(self, bytes content, encoding) void¶
from_bytes(bytes content)
Recover the serialized polynomial from a binary/bytes string.
- Parameters:
content – (
bytes) Python bytes object containing the PyPoly.encoding – (:obj: str) String or type describing the encoding: * (‘int’, ‘integer’, int, 1, scheme_t.INTEGER) -> integer encoding. * (‘float’, ‘double’, float, 2, scheme_t.FRACTIONAL) -> fractional encoding. * (‘array’, ‘batch’, ‘matrix’, list, 3, scheme_t.BATCH) -> batch encoding.
- from_coeff_list(self, vector[cy_complex] coeff_list, PyCtxt ref) void¶
Sets all the coefficients at once.
- Parameters:
coeff_list (List(complex)) – list of coefficients
- Returns:
value decrypted.
- Return type:
See also
- get_coeff(self, size_t i) cy_complex¶
Gets the chosen coefficient in position i.
- load(self, str fileName, encoding) void¶
load(self, str fileName, encoding)
Load the polynomial from a file.
- Parameters:
fileName – (str) Valid file where the polynomial is retrieved from.
encoding – (str, type, int, scheme_t) One of the following: * (‘int’, ‘integer’, int, 1, scheme_t.INTEGER) -> integer encoding. * (‘float’, ‘double’, float, 2, scheme_t.FRACTIONAL) -> fractional encoding.
- Returns:
None
See also
to_scheme_t()
- save(self, str fileName) void¶
save(str fileName)
Save the polynomial into a file. The file can new one or exist already, in which case it will be overwriten.
- Parameters:
fileName – (str) File where the polynomial will be stored.
- Returns:
None
- set_coeff(self, cy_complex coeff, size_t i) void¶
Sets the given complex value as coefficient in position i.
- Parameters:
coeff (complex) – new coefficient value
- Returns:
None
- to_bytes(self) bytes¶
to_bytes()
Serialize the polynomial into a binary/bytes string.
- Returns:
serialized polynomial
- Return type:
- to_coeff_list(self) vector[cy_complex]¶
List of complex coefficients of the polynomial
- _pyfhel¶
A pyfhel instance, used for operations
- _scheme¶
returns the scheme type.
Can be set to: 0-None, 1-BFV, 2-CKKS, 3-BGV.
See also
to_scheme_t()- Type:
_scheme