Template Class NativeVectorT
Defined in File mubintvecnat.h
Inheritance Relationships
Base Types
public lbcrypto::BigVectorInterface< NativeVectorT< IntegerType >, IntegerType >
(Template Class BigVectorInterface)public lbcrypto::Serializable
(Class Serializable)
Template Parameter Order
class IntegerType
Class Documentation
-
template<class IntegerType>
class intnat::NativeVectorT : public lbcrypto::BigVectorInterface<NativeVectorT<IntegerType>, IntegerType>, public lbcrypto::Serializable Inheritence diagram for intnat::NativeVectorT:
Collaboration diagram for intnat::NativeVectorT:
The class for representing vectors of native integers.
Public Types
-
using BasicInt = typename IntegerType::Integer
Public Functions
-
constexpr NativeVectorT() = default
-
inline explicit constexpr NativeVectorT(usint length) noexcept
Basic constructor for specifying the length of the vector.
- Parameters
length – is the length of the native vector, in terms of the number of entries.
-
inline constexpr NativeVectorT(usint length, const IntegerType &modulus) noexcept
Basic constructor for specifying the length of the vector and the modulus.
- Parameters
length – is the length of the native vector, in terms of the number of entries.
modulus – is the modulus of the ring.
-
inline constexpr NativeVectorT(usint length, const IntegerType &modulus, const IntegerType &val) noexcept
-
inline constexpr NativeVectorT(const NativeVectorT &v) noexcept
Basic constructor for copying a vector
- Parameters
bigVector – is the native vector to be copied.
-
inline constexpr NativeVectorT(NativeVectorT &&v) noexcept
Basic move constructor for moving a vector
- Parameters
&&bigVector – is the native vector to be moved.
-
NativeVectorT(usint length, const IntegerType &modulus, std::initializer_list<std::string> rhs) noexcept
Basic constructor for specifying the length of the vector the modulus and an initializer list.
- Parameters
length – is the length of the native vector, in terms of the number of entries.
modulus – is the modulus of the ring.
rhs – is an initializer list of strings
-
NativeVectorT(usint length, const IntegerType &modulus, std::initializer_list<uint64_t> rhs) noexcept
Basic constructor for specifying the length of the vector the modulus and an initializer list.
- Parameters
length – is the length of the native vector, in terms of the number of entries.
modulus – is the modulus of the ring.
rhs – is an initializer list of usint
-
inline NativeVectorT &operator=(const NativeVectorT &rhs) noexcept
Assignment operator to assign value from rhs
- Parameters
&rhs – is the native vector to be assigned from.
- Returns
Assigned NativeVectorT.
-
inline NativeVectorT &operator=(NativeVectorT &&rhs) noexcept
Move assignment operator
- Parameters
&&rhs – is the native vector to be moved.
- Returns
moved NativeVectorT object
-
NativeVectorT &operator=(std::initializer_list<std::string> rhs) noexcept
Initializer list for NativeVectorT.
- Parameters
&&rhs – is the list of strings containing integers to be assigned to the BBV.
- Returns
NativeVectorT object
-
NativeVectorT &operator=(std::initializer_list<uint64_t> rhs) noexcept
Initializer list for NativeVectorT.
- Parameters
&&rhs – is the list of integers to be assigned to the BBV.
- Returns
NativeVectorT object
-
inline constexpr NativeVectorT &operator=(uint64_t val)
Assignment operator to assign value val to first entry, 0 for the rest of entries.
- Parameters
val – is the value to be assigned at the first entry.
- Returns
Assigned NativeVectorT.
-
inline IntegerType &at(size_t i)
Sets/gets a value at an index. This method is slower than operator[] as it checks if index out of range
- Parameters
index – is the index to set a value at.
-
inline const IntegerType &at(size_t i) const
-
inline IntegerType &operator[](size_t idx)
operators to get a value at an index.
- Parameters
idx – is the index to get a value at.
- Returns
is the value at the index. return nullptr if invalid index.
-
inline const IntegerType &operator[](size_t idx) const
-
inline void SetModulus(const IntegerType &value)
Sets the vector modulus.
- Parameters
value – is the value to set.
value – is the modulus value to set.
-
void SwitchModulus(const IntegerType &value)
Sets the vector modulus and changes the values to match the new modulus.
Switches the integers in the vector to values corresponding to the new modulus. Algorithm: Integer i, Old Modulus om, New Modulus nm, delta = abs(om-nm): Case 1: om < nm if i > om/2 i’ = i + delta Case 2: om > nm i > om/2 i’ = i-delta
- Parameters
value – is the value to set.
-
inline const IntegerType &GetModulus() const
Gets the vector modulus.
- Returns
the vector modulus.
-
inline size_t GetLength() const
Gets the vector length.
- Returns
vector length.
-
NativeVectorT Mod(const IntegerType &modulus) const
Vector Modulus operator.
- Parameters
modulus – is the modulus to perform on the current vector entries.
- Returns
is the result after the modulus operation on current vector.
-
NativeVectorT &ModEq(const IntegerType &modulus)
Vector Modulus operator. In-place variant.
- Parameters
modulus – is the modulus to perform on the current vector entries.
- Returns
is the result after the modulus operation on current vector.
-
NativeVectorT ModAdd(const IntegerType &b) const
Scalar modulus addition.
After addition modulus operation is performed with the current vector modulus.
- Returns
is the result of the modulus addition operation.
-
NativeVectorT &ModAddEq(const IntegerType &b)
Scalar modulus addition. In-place variant.
After addition modulus operation is performed with the current vector modulus.
- Returns
is the result of the modulus addition operation.
-
NativeVectorT ModAddAtIndex(size_t i, const IntegerType &b) const
Scalar modulus addition at a particular index.
- Parameters
i – is the index of the entry to add.
&b – is the scalar to add.
- Returns
is the result of the modulus addition operation.
-
NativeVectorT &ModAddAtIndexEq(size_t i, const IntegerType &b)
Scalar modulus addition at a particular index. In-place variant.
- Parameters
i – is the index of the entry to add.
&b – is the scalar to add.
- Returns
is the result of the modulus addition operation.
-
NativeVectorT ModAdd(const NativeVectorT &b) const
vector modulus addition.
- Parameters
&b – is the vector to add at all locations.
- Returns
is the result of the modulus addition operation.
-
NativeVectorT &ModAddEq(const NativeVectorT &b)
vector modulus addition. In-place variant.
- Parameters
&b – is the vector to add at all locations.
- Returns
is the result of the modulus addition operation.
-
inline NativeVectorT &ModAddNoCheckEq(const NativeVectorT &b)
-
NativeVectorT ModSub(const IntegerType &b) const
Scalar modulus subtraction. After substraction modulus operation is performed with the current vector modulus.
- Parameters
&b – is the scalar to subtract from all locations.
- Returns
is the result of the modulus substraction operation.
-
NativeVectorT &ModSubEq(const IntegerType &b)
Scalar modulus subtraction. In-place variant. After substraction modulus operation is performed with the current vector modulus.
- Parameters
&b – is the scalar to subtract from all locations.
- Returns
is the result of the modulus substraction operation.
-
NativeVectorT ModSub(const NativeVectorT &b) const
Vector Modulus subtraction.
- Parameters
&b – is the vector to subtract.
- Returns
is the result of the modulus subtraction operation.
-
NativeVectorT &ModSubEq(const NativeVectorT &b)
Vector Modulus subtraction. In-place variant.
- Parameters
&b – is the vector to subtract.
- Returns
is the result of the modulus subtraction operation.
-
NativeVectorT ModMul(const IntegerType &b) const
Scalar modular multiplication. See the comments in the cpp files for details of the implementation.
- Parameters
&b – is the scalar to multiply at all locations.
- Returns
is the result of the modulus multiplication operation.
-
NativeVectorT &ModMulEq(const IntegerType &b)
Scalar modular multiplication. In-place variant. See the comments in the cpp files for details of the implementation.
- Parameters
&b – is the scalar to multiply at all locations.
- Returns
is the result of the modulus multiplication operation.
-
NativeVectorT ModMul(const NativeVectorT &b) const
Vector modulus multiplication.
- Parameters
&b – is the vector to multiply.
- Returns
is the result of the modulus multiplication operation.
-
NativeVectorT &ModMulEq(const NativeVectorT &b)
Vector modulus multiplication. In-place variant.
- Parameters
&b – is the vector to multiply.
- Returns
is the result of the modulus multiplication operation.
-
inline NativeVectorT &ModMulNoCheckEq(const NativeVectorT &b)
-
NativeVectorT MultWithOutMod(const NativeVectorT &b) const
Vector multiplication without applying the modulus operation.
- Parameters
&b – is the vector to multiply.
- Returns
is the result of the multiplication operation.
-
NativeVectorT ModExp(const IntegerType &b) const
Scalar modulus exponentiation.
- Parameters
&b – is the scalar to exponentiate at all locations.
- Returns
a new vector which is the result of the modulus exponentiation operation.
-
NativeVectorT &ModExpEq(const IntegerType &b)
Scalar modulus exponentiation. In-place variant.
- Parameters
&b – is the scalar to exponentiate at all locations.
- Returns
a new vector which is the result of the modulus exponentiation operation.
-
inline NativeVectorT ModInverse() const
Modulus inverse.
- Returns
a new vector which is the result of the modulus inverse operation.
-
inline NativeVectorT &ModInverseEq()
Modulus inverse. In-place variant.
- Returns
a new vector which is the result of the modulus inverse operation.
-
NativeVectorT ModByTwo() const
Perform a modulus by 2 operation. Returns the least significant bit.
- Returns
a new vector which is the return value of the modulus by 2, also the least significant bit.
-
NativeVectorT &ModByTwoEq()
Perform a modulus by 2 operation. Returns the least significant bit. In-place variant.
- Returns
a new vector which is the return value of the modulus by 2, also the least significant bit.
-
NativeVectorT MultiplyAndRound(const IntegerType &p, const IntegerType &q) const
Multiply and Rounding operation on a BigInteger x. Returns [x*p/q] where [] is the rounding operation.
- Parameters
p – is the numerator to be multiplied.
q – is the denominator to be divided.
- Returns
the result of multiply and round.
-
NativeVectorT &MultiplyAndRoundEq(const IntegerType &p, const IntegerType &q)
Multiply and Rounding operation on a BigInteger x. Returns [x*p/q] where [] is the rounding operation. In-place variant.
- Parameters
p – is the numerator to be multiplied.
q – is the denominator to be divided.
- Returns
the result of multiply and round.
-
NativeVectorT DivideAndRound(const IntegerType &q) const
Divide and Rounding operation on a BigInteger x. Returns [x/q] where [] is the rounding operation.
- Parameters
q – is the denominator to be divided.
- Returns
the result of divide and round.
-
NativeVectorT &DivideAndRoundEq(const IntegerType &q)
Divide and Rounding operation on a BigInteger x. Returns [x/q] where [] is the rounding operation. In-place variant.
- Parameters
q – is the denominator to be divided.
- Returns
the result of divide and round.
-
NativeVectorT GetDigitAtIndexForBase(usint index, usint base) const
Digit vector at a specific index for all entries for a given number base. Warning: only power-of-2 bases are currently supported. Example: for vector (83, 1, 45), index 2 and base 4 we have:
|83| |3,0,1,1| |1| |1 | —base 4 decomposition–> |1,0,0,0| —at index 2–> |0| |45| |1,3,2,0| |2|index:0,1,2,3
The return vector is (1,0,2)
- Parameters
index – is the index to return the digit from in all entries.
base – is the base to use for the operation.
- Returns
is the digit at a specific index for all entries for a given number base
-
template<class Archive>
inline std::enable_if<!cereal::traits::is_text_archive<Archive>::value, void>::type save(Archive &ar, std::uint32_t const version) const
-
template<class Archive>
inline std::enable_if<cereal::traits::is_text_archive<Archive>::value, void>::type save(Archive &ar, std::uint32_t const version) const
-
template<class Archive>
inline std::enable_if<!cereal::traits::is_text_archive<Archive>::value, void>::type load(Archive &ar, std::uint32_t const version)
-
template<class Archive>
inline std::enable_if<cereal::traits::is_text_archive<Archive>::value, void>::type load(Archive &ar, std::uint32_t const version)
-
inline virtual std::string SerializedObjectName() const override
Public Static Functions
-
static inline constexpr NativeVectorT Single(const IntegerType &val, const IntegerType &modulus) noexcept
-
static inline uint32_t SerializedVersion()
Friends
-
template<class IntegerType_c>
inline friend std::ostream &operator<<(std::ostream &os, const NativeVectorT<IntegerType_c> &ptr_obj) ostream operator to output vector values to console
- Parameters
os – is the std ostream object.
&ptr_obj – is the NativeVectorT object to be printed.
- Returns
std ostream object which captures the vector values.
-
using BasicInt = typename IntegerType::Integer