PALISADE Lattice Crypto Library  1.11.9
A lattice crypto library for software engineers by software engineers.
ubintntl.h
1 // @file ubintntl.h This file contains the C++ code for implementing the main
2 // class for big integers: gmpint which replaces BBI and uses NTL
3 // @author TPOC: contact@palisade-crypto.org
4 //
5 // @copyright Copyright (c) 2019, New Jersey Institute of Technology (NJIT)
6 // All rights reserved.
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 // 1. Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution. THIS SOFTWARE IS
14 // PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
15 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 // EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 
25 #ifndef LBCRYPTO_MATH_BIGINTNTL_UBINTNTL_H
26 #define LBCRYPTO_MATH_BIGINTNTL_UBINTNTL_H
27 
28 #include "config_core.h"
29 #ifdef WITH_NTL
30 
31 #include <NTL/ZZ.h>
32 #include <NTL/ZZ_limbs.h>
33 
34 #include <exception>
35 #include <fstream>
36 #include <functional>
37 #include <iostream>
38 #include <limits>
39 #include <memory>
40 #include <string>
41 #include <type_traits>
42 #include <typeinfo>
43 #include <vector>
44 
45 #include "utils/exception.h"
46 #include "utils/inttypes.h"
47 #include "utils/memory.h"
48 
49 #include "utils/debug.h"
50 
55 namespace NTL {
56 // log2 constants
63 template <usint N>
64 struct Log2 {
65  static const usint value = 1 + Log2<N / 2>::value;
66 };
67 
73 template <>
74 struct Log2<2> {
75  static const usint value = 1;
76 };
77 
78 class myZZ : public NTL::ZZ, public lbcrypto::BigIntegerInterface<myZZ> {
79  public:
80  // CONSTRUCTORS
81 
85  myZZ();
86 
92  myZZ(const NTL::ZZ &val);
93 
99  myZZ(NTL::ZZ &&val);
100 
101  // TODO: figure out how to do && for wrapper
102  // myZZ(NTL::myZZ_p &&a);
103 
109  explicit myZZ(const std::string &strval);
110 
116  myZZ(uint64_t val);
117 #if defined(HAVE_INT128)
118  myZZ(unsigned __int128 val);
119 #endif
120 
126  myZZ(int val) : myZZ(uint64_t(val)) {}
127  myZZ(uint32_t val) : myZZ(uint64_t(val)) {}
128  myZZ(long val) : myZZ(uint64_t(val)) {}
129  myZZ(long long val) : myZZ(uint64_t(val)) {}
130 
136  template <typename T>
137  myZZ(const bigintnat::NativeIntegerT<T> &val) : myZZ(val.ConvertToInt()) {}
138 
144  myZZ(double val)
145  __attribute__((deprecated("Cannot construct from a double")));
146 
147  // ASSIGNMENT OPERATORS
148 
155  const myZZ &operator=(const myZZ &val);
156 
157  // TODO move assignment operator?
158 
165  inline const myZZ &operator=(std::string strval) {
166  *this = myZZ(strval);
167  return *this;
168  }
169 
176  const myZZ &operator=(uint64_t val) {
177  *this = myZZ(val);
178  return *this;
179  }
180 
181  // ACCESSORS
182 
188  void SetValue(const std::string &strval);
189 
195  void SetValue(const myZZ &val);
196 
197  void SetIdentity() { *this = 1; }
198 
199  // ARITHMETIC OPERATIONS
200 
207  myZZ Add(const myZZ &b) const {
208  return *static_cast<const ZZ *>(this) + static_cast<const ZZ &>(b);
209  }
210 
217  const myZZ &AddEq(const myZZ &b) {
218  *static_cast<ZZ *>(this) += static_cast<const ZZ &>(b);
219  return *this;
220  }
221 
229  myZZ Sub(const myZZ &b) const {
230  return (*this < b)
231  ? ZZ(0)
232  : (*static_cast<const ZZ *>(this) - static_cast<const ZZ &>(b));
233  }
234 
242  const myZZ &SubEq(const myZZ &b) {
243  if (*this < b) {
244  *this = ZZ(0);
245  } else {
246  *static_cast<ZZ *>(this) -= static_cast<const ZZ &>(b);
247  }
248  return *this;
249  }
250 
257  myZZ Mul(const myZZ &b) const {
258  return *static_cast<const ZZ *>(this) * static_cast<const ZZ &>(b);
259  }
260 
267  const myZZ &MulEq(const myZZ &b) {
268  *static_cast<ZZ *>(this) *= static_cast<const ZZ &>(b);
269  return *this;
270  }
271 
278  myZZ DividedBy(const myZZ &b) const {
279  return *static_cast<const ZZ *>(this) / static_cast<const ZZ &>(b);
280  }
281 
288  const myZZ &DividedByEq(const myZZ &b) {
289  *static_cast<ZZ *>(this) /= static_cast<const ZZ &>(b);
290  return *this;
291  }
292 
299  myZZ Exp(const usint p) const { return power(*this, p); }
300 
307  const myZZ &ExpEq(const usint p) {
308  *this = power(*this, p);
309  return *this;
310  }
311 
320  myZZ MultiplyAndRound(const myZZ &p, const myZZ &q) const;
321 
330  const myZZ &MultiplyAndRoundEq(const myZZ &p, const myZZ &q);
331 
339  myZZ DivideAndRound(const myZZ &q) const;
340 
348  const myZZ &DivideAndRoundEq(const myZZ &q);
349 
350  // MODULAR ARITHMETIC OPERATIONS
351 
358  myZZ Mod(const myZZ &modulus) const {
359  return *static_cast<const ZZ *>(this) % static_cast<const ZZ &>(modulus);
360  }
361 
368  const myZZ &ModEq(const myZZ &modulus) {
369  *static_cast<ZZ *>(this) %= static_cast<const ZZ &>(modulus);
370  return *this;
371  }
372 
378  myZZ ComputeMu() const {
379  myZZ temp(1);
380  temp <<= (2 * this->GetMSB() + 3);
381  return temp.DividedBy(*this);
382  return temp;
383  }
384 
394  myZZ Mod(const myZZ &modulus, const myZZ &mu) const {
395  return *static_cast<const ZZ *>(this) % static_cast<const ZZ &>(modulus);
396  }
397 
407  const myZZ &ModEq(const myZZ &modulus, const myZZ &mu) {
408  *static_cast<ZZ *>(this) %= static_cast<const ZZ &>(modulus);
409  return *this;
410  }
411 
419  myZZ ModAdd(const myZZ &b, const myZZ &modulus) const {
420  return AddMod(this->Mod(modulus), b.Mod(modulus), modulus);
421  }
422 
430  const myZZ &ModAddEq(const myZZ &b, const myZZ &modulus) {
431  AddMod(*this, this->Mod(modulus), b.Mod(modulus), modulus);
432  return *this;
433  }
434 
442  myZZ ModAddFast(const myZZ &b, const myZZ &modulus) const {
443  return AddMod(*this, b, modulus);
444  }
445 
453  const myZZ &ModAddFastEq(const myZZ &b, const myZZ &modulus) {
454  *this = AddMod(*this, b, modulus);
455  return *this;
456  }
457 
466  myZZ ModAdd(const myZZ &b, const myZZ &modulus, const myZZ &mu) const {
467  return AddMod(*this, b, modulus);
468  }
469 
478  const myZZ &ModAddEq(const myZZ &b, const myZZ &modulus, const myZZ &mu) {
479  *this = AddMod(*this, b, modulus);
480  return *this;
481  }
482 
492  myZZ ModSub(const myZZ &b, const myZZ &modulus) const {
493  myZZ newthis(*this % modulus);
494  myZZ newb(b % modulus);
495  if (newthis >= newb) {
496  myZZ tmp(SubMod(newthis, newb, modulus)); // normal mod sub
497  return tmp;
498  } else {
499  myZZ tmp(newthis + modulus - newb); // signed mod
500  return tmp;
501  }
502  }
503 
513  const myZZ &ModSubEq(const myZZ &b, const myZZ &modulus) {
514  this->ModEq(modulus);
515  myZZ newb(b % modulus);
516  if (*this >= newb) {
517  SubMod(*this, *this, newb, modulus); // normal mod sub
518  return *this;
519  } else {
520  this->AddEq(modulus);
521  this->SubEq(newb); // signed mod
522  return *this;
523  }
524  }
525 
533  myZZ ModSubFast(const myZZ &b, const myZZ &modulus) const {
534  if (*this >= b) {
535  return SubMod(*this, b, modulus); // normal mod sub
536  } else {
537  return (*this + modulus - b); // signed mod
538  }
539  }
540 
548  const myZZ &ModSubFastEq(const myZZ &b, const myZZ &modulus) {
549  if (*this >= b) {
550  return *this = SubMod(*this, b, modulus); // normal mod sub
551  } else {
552  return *this = (*this + modulus - b); // signed mod
553  }
554  }
555 
564  myZZ ModSub(const myZZ &b, const myZZ &modulus, const myZZ &mu) const {
565  myZZ newthis(*this % modulus);
566  myZZ newb(b % modulus);
567  if (newthis >= newb) {
568  myZZ tmp(SubMod(newthis, newb, modulus)); // normal mod sub
569  return tmp;
570  } else {
571  myZZ tmp(newthis + modulus - newb); // signed mod
572  return tmp;
573  }
574  }
575 
584  const myZZ &ModSubEq(const myZZ &b, const myZZ &modulus, const myZZ &mu) {
585  this->ModEq(modulus);
586  myZZ newb(b % modulus);
587  if (*this >= newb) {
588  SubMod(*this, *this, newb, modulus); // normal mod sub
589  return *this;
590  } else {
591  this->AddEq(modulus);
592  this->SubEq(newb); // signed mod
593  return *this;
594  }
595  }
596 
604  myZZ ModMul(const myZZ &b, const myZZ &modulus) const {
605  return MulMod(this->Mod(modulus), b.Mod(modulus), modulus);
606  }
607 
615  const myZZ &ModMulEq(const myZZ &b, const myZZ &modulus) {
616  MulMod(*this, this->Mod(modulus), b.Mod(modulus), modulus);
617  return *this;
618  }
619 
628  myZZ ModMul(const myZZ &b, const myZZ &modulus, const myZZ &mu) const {
629  return MulMod(this->Mod(modulus), b.Mod(modulus), modulus);
630  }
631 
640  const myZZ &ModMulEq(const myZZ &b, const myZZ &modulus, const myZZ &mu) {
641  MulMod(*this, this->Mod(modulus), b.Mod(modulus), modulus);
642  return *this;
643  }
644 
652  inline myZZ ModMulFast(const myZZ &b, const myZZ &modulus) const {
653  return MulMod(*this, b, modulus);
654  }
655 
664  const myZZ &ModMulFastEq(const myZZ &b, const myZZ &modulus) {
665  *this = MulMod(*this, b, modulus);
666  return *this;
667  }
668 
677  inline myZZ ModMulFast(const myZZ &b, const myZZ &modulus,
678  const myZZ &mu) const {
679  return MulMod(*this, b, modulus);
680  }
681 
691  const myZZ &ModMulFastEq(const myZZ &b, const myZZ &modulus, const myZZ &mu) {
692  *this = MulMod(*this, b, modulus);
693  return *this;
694  }
695 
696  myZZ ModMulFastConst(const myZZ &b, const myZZ &modulus,
697  const myZZ &bInv) const {
698  PALISADE_THROW(lbcrypto::not_implemented_error,
699  "ModMulFastConst is not implemented for backend 6");
700  }
701 
702  const myZZ &ModMulFastConstEq(const myZZ &b, const myZZ &modulus,
703  const myZZ &bInv) {
704  PALISADE_THROW(lbcrypto::not_implemented_error,
705  "ModMulFastConstEq is not implemented for backend 6");
706  }
707 
715  inline myZZ ModExp(const myZZ &b, const myZZ &modulus) const {
716  myZZ res;
717  PowerMod(res, *this, b, modulus);
718  return res;
719  }
720 
728  const myZZ &ModExpEq(const myZZ &b, const myZZ &modulus) {
729  PowerMod(*this, *this, b, modulus);
730  return *this;
731  }
732 
739  myZZ ModInverse(const myZZ &modulus) const {
740  if (modulus == myZZ(0)) {
741  PALISADE_THROW(lbcrypto::math_error, "zero has no inverse");
742  }
743  myZZ tmp(0);
744  try {
745  tmp = InvMod(*this % modulus, modulus);
746  } catch (InvModErrorObject
747  &e) { // note this code requires NTL Excptions coto be turned
748  // on. TODO: provide alternative when that is off.
749  std::stringstream errmsg;
750  errmsg << "ModInverse exception "
751  << " this: " << *this << " modulus: " << modulus << "GCD("
752  << e.get_a() << "," << e.get_n() << "!=1" << std::endl;
753  PALISADE_THROW(lbcrypto::math_error, errmsg.str());
754  }
755  return tmp;
756  }
757 
764  const myZZ &ModInverseEq(const myZZ &modulus) {
765  if (modulus == myZZ(0)) {
766  PALISADE_THROW(lbcrypto::math_error, "zero has no inverse");
767  }
768  try {
769  *this = InvMod(*this % modulus, modulus);
770  } catch (InvModErrorObject
771  &e) { // note this code requires NTL Excptions coto be turned
772  // on. TODO: provide alternative when that is off.
773  std::stringstream errmsg;
774  errmsg << "ModInverse exception "
775  << " this: " << *this << " modulus: " << modulus << "GCD("
776  << e.get_a() << "," << e.get_n() << "!=1" << std::endl;
777  PALISADE_THROW(lbcrypto::math_error, errmsg.str());
778  }
779  return *this;
780  }
781 
788  myZZ LShift(usshort shift) const {
789  return *static_cast<const ZZ *>(this) << shift;
790  }
791 
798  const myZZ &LShiftEq(usshort shift) {
799  *static_cast<ZZ *>(this) <<= shift;
800  return *this;
801  }
802 
809  myZZ RShift(usshort shift) const {
810  return *static_cast<const ZZ *>(this) >> shift;
811  }
812 
819  const myZZ &RShiftEq(usshort shift) {
820  *static_cast<ZZ *>(this) >>= shift;
821  return *this;
822  }
823 
824  // COMPARE
825 
826  // comparison method inline for speed
827  int Compare(const myZZ &a) const { return compare(*this, a); }
828 
829  // CONVERTING
830 
831  // palisade conversion methods
832  uint64_t ConvertToInt() const;
833 
834  uint64_t ConvertToUint64() const;
835 
836  double ConvertToDouble() const;
837 
845  static myZZ FromBinaryString(const std::string &bitString);
846 
847  // OTHER FUNCTIONS
848 
849  // adapter kit that wraps ZZ with BACKEND 2 functionality
850 
851  static const myZZ &zero();
852 
853  usint GetMSB() const;
854 
862  usint GetLengthForBase(usint base) const { return GetMSB(); }
863 
879  usint GetDigitAtIndexForBase(usint index, usint base) const;
880 
881  // variable to store the log(base 2) of the number of bits in the
882  // limb data type.
883  static const usint m_log2LimbBitLength;
884 
892  usint GetBitRangeAtIndex(usint index, usint length) const;
893 
900  uschar GetBitAtIndex(usint index) const;
901 
906  static myZZ Allocator() { return 0; }
907 
908  // STRINGS & STREAMS
909 
910  // palisade string conversion
911  const std::string ToString() const;
912 
913  static const std::string IntegerTypeName() { return "UBNTLINT"; }
914 
915  // big integer stream output
916  friend std::ostream &operator<<(std::ostream &os, const myZZ &ptr_obj);
917 
922  std::string GetInternalRepresentation(void) const {
923  std::string ret("");
924  const ZZ_limb_t *zlp = ZZ_limbs_get(*this);
925 
926  for (size_t i = 0; i < (size_t)this->size(); i++) {
927  ret += std::to_string(zlp[i]);
928  if (i < ((size_t)this->size() - 1)) {
929  ret += " ";
930  }
931  }
932  return ret;
933  }
934 
936 
937  template <class Archive>
938  typename std::enable_if<!cereal::traits::is_text_archive<Archive>::value,
939  void>::type
940  save(Archive &ar, std::uint32_t const version) const {
941  void *data = this->rep.rep;
942  ::cereal::size_type len = 0;
943  if (data == nullptr) {
944  ar(::cereal::binary_data(&len, sizeof(len)));
945  } else {
946  len = _ntl_ALLOC(this->rep.rep);
947 
948  ar(::cereal::binary_data(&len, sizeof(len)));
949  ar(::cereal::binary_data(data, len * sizeof(_ntl_gbigint)));
950  ar(::cereal::make_nvp("mb", m_MSB));
951  }
952  }
953 
954  template <class Archive>
955  typename std::enable_if<cereal::traits::is_text_archive<Archive>::value,
956  void>::type
957  save(Archive &ar, std::uint32_t const version) const {
958  ar(::cereal::make_nvp("v", ToString()));
959  }
960 
961  template <class Archive>
962  typename std::enable_if<!cereal::traits::is_text_archive<Archive>::value,
963  void>::type
964  load(Archive &ar, std::uint32_t const version) {
965  if (version > SerializedVersion()) {
966  PALISADE_THROW(lbcrypto::deserialize_error,
967  "serialized object version " + std::to_string(version) +
968  " is from a later version of the library");
969  }
970  ::cereal::size_type len;
971  ar(::cereal::binary_data(&len, sizeof(len)));
972  if (len == 0) {
973  *this = 0;
974  return;
975  }
976 
977  void *mem = malloc(len * sizeof(_ntl_gbigint));
978  ar(::cereal::binary_data(mem, len * sizeof(_ntl_gbigint)));
979  WrappedPtr<_ntl_gbigint_body, Deleter> newrep;
980  newrep.rep = reinterpret_cast<_ntl_gbigint_body *>(mem);
981  _ntl_gswap(&this->rep, &newrep);
982 
983  ar(::cereal::make_nvp("mb", m_MSB));
984  }
985 
986  template <class Archive>
987  typename std::enable_if<cereal::traits::is_text_archive<Archive>::value,
988  void>::type
989  load(Archive &ar, std::uint32_t const version) {
990  if (version > SerializedVersion()) {
991  PALISADE_THROW(lbcrypto::deserialize_error,
992  "serialized object version " + std::to_string(version) +
993  " is from a later version of the library");
994  }
995  std::string s;
996  ar(::cereal::make_nvp("v", s));
997  *this = s;
998  }
999 
1000  std::string SerializedObjectName() const { return "NTLInteger"; }
1001 
1002  static uint32_t SerializedVersion() { return 1; }
1003 
1004  private:
1005  // adapter kits
1006  void SetMSB();
1007 
1015  // todo: rename to MSB2NLimbs()
1016  static usint ceilIntByUInt(const ZZ_limb_t Number);
1017 
1018  mutable uint32_t m_MSB;
1019  usint GetMSBLimb_t(ZZ_limb_t x) const;
1020 };
1021 // class ends
1022 
1023 NTL_DECLARE_RELOCATABLE((myZZ *))
1024 } // namespace NTL
1025 
1026 #endif
1027 
1028 #endif // LBCRYPTO_MATH_BIGINTNTL_UBINTNTL_H
myZZ(int val)
Definition: ubintntl.h:126
const myZZ & LShiftEq(usshort shift)
Definition: ubintntl.h:798
myZZ DividedBy(const myZZ &b) const
Definition: ubintntl.h:278
const myZZ & ModMulFastEq(const myZZ &b, const myZZ &modulus, const myZZ &mu)
Definition: ubintntl.h:691
myZZ ModAdd(const myZZ &b, const myZZ &modulus, const myZZ &mu) const
Definition: ubintntl.h:466
myZZ Add(const myZZ &b) const
Definition: ubintntl.h:207
myZZ ModMulFast(const myZZ &b, const myZZ &modulus) const
Definition: ubintntl.h:652
myZZ ComputeMu() const
Definition: ubintntl.h:378
myZZ Mod(const myZZ &modulus) const
Definition: ubintntl.h:358
const myZZ & ModExpEq(const myZZ &b, const myZZ &modulus)
Definition: ubintntl.h:728
const myZZ & ExpEq(const usint p)
Definition: ubintntl.h:307
myZZ Sub(const myZZ &b) const
Definition: ubintntl.h:229
static myZZ Allocator()
Definition: ubintntl.h:906
const myZZ & ModMulEq(const myZZ &b, const myZZ &modulus)
Definition: ubintntl.h:615
myZZ ModInverse(const myZZ &modulus) const
Definition: ubintntl.h:739
myZZ ModSub(const myZZ &b, const myZZ &modulus, const myZZ &mu) const
Definition: ubintntl.h:564
myZZ Exp(const usint p) const
Definition: ubintntl.h:299
const myZZ & SubEq(const myZZ &b)
Definition: ubintntl.h:242
const myZZ & ModEq(const myZZ &modulus)
Definition: ubintntl.h:368
myZZ RShift(usshort shift) const
Definition: ubintntl.h:809
myZZ(const bigintnat::NativeIntegerT< T > &val)
Definition: ubintntl.h:137
Definition: exception.h:119
std::enable_if<!cereal::traits::is_text_archive< Archive >::value, void >::type save(Archive &ar, std::uint32_t const version) const
SERIALIZATION.
Definition: ubintntl.h:940
Definition: exception.h:147
Definition: exception.h:113
const myZZ & AddEq(const myZZ &b)
Definition: ubintntl.h:217
std::string GetInternalRepresentation(void) const
Definition: ubintntl.h:922
const myZZ & ModMulFastEq(const myZZ &b, const myZZ &modulus)
Definition: ubintntl.h:664
myZZ LShift(usshort shift) const
Definition: ubintntl.h:788
Struct to find log value of N. Needed in the preprocessing step of ubint to determine bitwidth...
Definition: ubintntl.h:64
const myZZ & ModInverseEq(const myZZ &modulus)
Definition: ubintntl.h:764
myZZ ModMul(const myZZ &b, const myZZ &modulus, const myZZ &mu) const
Definition: ubintntl.h:628
Definition: ubintntl.h:78
myZZ ModMul(const myZZ &b, const myZZ &modulus) const
Definition: ubintntl.h:604
myZZ ModSub(const myZZ &b, const myZZ &modulus) const
Definition: ubintntl.h:492
const myZZ & ModEq(const myZZ &modulus, const myZZ &mu)
Definition: ubintntl.h:407
myZZ ModExp(const myZZ &b, const myZZ &modulus) const
Definition: ubintntl.h:715
myZZ ModAdd(const myZZ &b, const myZZ &modulus) const
Definition: ubintntl.h:419
myZZ ModMulFast(const myZZ &b, const myZZ &modulus, const myZZ &mu) const
Definition: ubintntl.h:677
const myZZ & ModMulEq(const myZZ &b, const myZZ &modulus, const myZZ &mu)
Definition: ubintntl.h:640
const myZZ & DividedByEq(const myZZ &b)
Definition: ubintntl.h:288
const myZZ & ModAddEq(const myZZ &b, const myZZ &modulus, const myZZ &mu)
Definition: ubintntl.h:478
const myZZ & ModAddFastEq(const myZZ &b, const myZZ &modulus)
Definition: ubintntl.h:453
const myZZ & ModSubEq(const myZZ &b, const myZZ &modulus)
Definition: ubintntl.h:513
const myZZ & operator=(std::string strval)
Definition: ubintntl.h:165
usint GetLengthForBase(usint base) const
Definition: ubintntl.h:862
myZZ ModAddFast(const myZZ &b, const myZZ &modulus) const
Definition: ubintntl.h:442
Definition: interface.h:33
myZZ ModSubFast(const myZZ &b, const myZZ &modulus) const
Definition: ubintntl.h:533
const myZZ & ModSubFastEq(const myZZ &b, const myZZ &modulus)
Definition: ubintntl.h:548
Main class for big integers represented as an array of native (primitive) unsigned integers...
Definition: backend.h:60
const myZZ & RShiftEq(usshort shift)
Definition: ubintntl.h:819
const myZZ & MulEq(const myZZ &b)
Definition: ubintntl.h:267
const myZZ & ModSubEq(const myZZ &b, const myZZ &modulus, const myZZ &mu)
Definition: ubintntl.h:584
myZZ Mod(const myZZ &modulus, const myZZ &mu) const
Definition: ubintntl.h:394
const myZZ & ModAddEq(const myZZ &b, const myZZ &modulus)
Definition: ubintntl.h:430
myZZ Mul(const myZZ &b) const
Definition: ubintntl.h:257
const myZZ & operator=(uint64_t val)
Definition: ubintntl.h:176