Class Field2n
Defined in File field2n.h
Page Contents
Inheritance Relationships
Base Types
public std::vector< std::complex< double > >public lbcrypto::Serializable(Class Serializable)
Class Documentation
-
class lbcrypto::Field2n : public std::vector<std::complex<double>>, public lbcrypto::Serializable
Inheritence diagram for lbcrypto::Field2n:
![digraph {
graph [bgcolor="#00000000"]
node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
edge [color="#1414CE"]
"2" [label="std::vector< std::complex< double > >" tooltip="std::vector< std::complex< double > >"]
"3" [label="lbcrypto::Serializable" tooltip="lbcrypto::Serializable"]
"1" [label="lbcrypto::Field2n" tooltip="lbcrypto::Field2n" fillcolor="#BFBFBF"]
"1" -> "2" [dir=forward tooltip="public-inheritance"]
"1" -> "3" [dir=forward tooltip="public-inheritance"]
}](../_images/graphviz-17a5dd4aefc783a7c3a22fa606abcebab3811cba.png)
Collaboration diagram for lbcrypto::Field2n:
![digraph {
graph [bgcolor="#00000000"]
node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
edge [color="#1414CE"]
"2" [label="std::vector< std::complex< double > >" tooltip="std::vector< std::complex< double > >"]
"3" [label="lbcrypto::Serializable" tooltip="lbcrypto::Serializable"]
"1" [label="lbcrypto::Field2n" tooltip="lbcrypto::Field2n" fillcolor="#BFBFBF"]
"1" -> "2" [dir=forward tooltip="public-inheritance"]
"1" -> "3" [dir=forward tooltip="public-inheritance"]
}](../_images/graphviz-17a5dd4aefc783a7c3a22fa606abcebab3811cba.png)
A class to represent field elements with power-of-2 dimension.
Public Functions
-
Field2n() noexcept = default
Default Constructor.
-
inline Field2n(usint size, Format f = Format::EVALUATION, bool initializeElementToZero = false)
Constructor for field element.
- Parameters
size – element size
f – format/representation of the element. Initially set to Format::EVALUATION representation.
initializeElementToZero – flag for initializing values to zero. It is set to false by default.
-
explicit Field2n(const Poly &element)
Constructor from ring element.
- Parameters
& – element ring element
-
explicit Field2n(const NativePoly &element)
Constructor from ring element.
- Parameters
& – element ring element
-
explicit Field2n(const DCRTPoly &element)
Constructor from DCRTPoly ring element.
- Parameters
& – element ring element
-
explicit Field2n(const Matrix<int64_t> &element)
Constructor from a ring element matrix.
- Parameters
&element – ring element matrix
-
inline Format GetFormat() const
Method for getting the format/representation of the element.
- Returns
format/representation of the field element
-
Field2n Inverse() const
Inverse operation for the field elements.
- Returns
the inverse field element
-
Field2n Plus(const Field2n &rhs) const
Addition operation for field elements.
- Parameters
&rhs – right hand side element for operation
- Returns
result of the operation
-
Field2n Plus(double rhs) const
Scalar addition operation for field elements.
- Parameters
&rhs – right hand side element for operation
- Returns
result of the operation
-
Field2n Minus(const Field2n &rhs) const
Substraction operation for field elements.
- Parameters
&rhs – right hand side element for operation
- Returns
result of the operation
-
Field2n Times(const Field2n &rhs) const
Multiplication operation for field elements.
- Parameters
&rhs – right hand side element for operation
- Returns
result of the operation
-
Field2n ShiftRight()
Right shift operation for the field element.
- Returns
the shifted field element
-
Field2n AutomorphismTransform(size_t i) const
Performs an automorphism transform operation and returns the result.
- Parameters
&i – is the element to perform the automorphism transform with.
- Returns
is the result of the automorphism transform.
-
Field2n Transpose() const
Transpose operation defined in section VI.B4 of https://eprint.iacr.org/2017/844.pdf.
- Returns
the transpose of the element
-
Field2n ExtractOdd() const
Function for extracting odd factors of the field element.
- Returns
the field element with odd parts of the initial element
-
Field2n ExtractEven() const
Function for extracting even factors of the field element.
- Returns
the field element with even parts of the initial element
-
Field2n Permute() const
Permutation operation defined in Algorithm 4 of https://eprint.iacr.org/2017/844.pdf.
- Returns
permuted new field element
-
Field2n InversePermute() const
Inverse operation for permutation operation defined in Algorithm 4 of https://eprint.iacr.org/2017/844.pdf.
- Returns
non permuted version of the element
-
Field2n ScalarMult(double d)
Operation for scalar multiplication.
- Parameters
d – scalar for multiplication
- Returns
the field element with the scalar multiplication
-
void SwitchFormat()
Method for switching format of the field elements.
-
inline void SetFormat(Format f)
Sets the evaluation or coefficient representation of the field elements.
- Parameters
&format – the enum value corresponding to coefficient or evaluation representation
-
inline size_t Size() const
Method for getting the size of the element.
- Returns
the size of the element
-
inline std::complex<double> &operator[](size_t idx)
Indexing operator for field elements.
- Parameters
idx – index of the element
- Returns
element at the index
-
inline const std::complex<double> &operator[](size_t idx) const
Indexing operator for field elements.
- Parameters
idx – index of the element
- Returns
element at the index
-
inline Field2n &operator+=(const Field2n &element)
In-place addition operation for field elements.
- Parameters
&element – right hand side element for operation
- Returns
result of the operation
-
inline Field2n &operator-=(const Field2n &element)
In-place subtraction operation for field elements.
- Parameters
&element – right hand side element for operation
- Returns
result of the operation
-
inline Field2n operator-() const
Unary minus on a field element.
- Returns
negation of the field element.
-
inline virtual std::string SerializedObjectName() const override
Public Static Functions
-
static inline uint32_t SerializedVersion()
Friends
-
inline friend Field2n operator-(const Field2n &a, const Field2n &b)
Substraction operator for field elements.
- Parameters
&a – left hand side field element
&b – right hand side field element
- Returns
result of the substraction operation
-
inline friend Field2n operator+(const Field2n &a, const Field2n &b)
Addition operator for field elements.
- Parameters
&a – left hand side field element
&b – right hand side field element
- Returns
result of the addition operation
-
Field2n() noexcept = default