PALISADE Lattice Crypto Library  1.11.9
A lattice crypto library for software engineers by software engineers.
binaryuniformgenerator.h
1 // @file binaryuniformgenerator.cpp This code provides generation of a uniform
2 // distribution of binary values (modulus 2). Discrete uniform generator relies
3 // on the built-in C++ generator for 32-bit unsigned integers defined in
4 // <random>.
5 // @author TPOC: contact@palisade-crypto.org
6 //
7 // @copyright Copyright (c) 2019, New Jersey Institute of Technology (NJIT)
8 // All rights reserved.
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 // 1. Redistributions of source code must retain the above copyright notice,
12 // this list of conditions and the following disclaimer.
13 // 2. Redistributions in binary form must reproduce the above copyright notice,
14 // this list of conditions and the following disclaimer in the documentation
15 // and/or other materials provided with the distribution. THIS SOFTWARE IS
16 // PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
17 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 // EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 
27 #ifndef LBCRYPTO_MATH_BINARYUNIFORMGENERATOR_H_
28 #define LBCRYPTO_MATH_BINARYUNIFORMGENERATOR_H_
29 
30 #include <random>
31 #include "math/distributiongenerator.h"
32 
33 namespace lbcrypto {
34 
35 template <typename VecType>
37 
39 
43 template <typename VecType>
44 class BinaryUniformGeneratorImpl : public DistributionGenerator<VecType> {
45  public:
51 
56  typename VecType::Integer GenerateInteger() const;
57 
63  VecType GenerateVector(const usint size,
64  const typename VecType::Integer &modulus) const;
65 
66  private:
67  static std::bernoulli_distribution m_distribution;
68 };
69 
70 } // namespace lbcrypto
71 
72 #endif // LBCRYPTO_MATH_BINARYUNIFORMGENERATOR_H_
A generator of the Binary Uniform Distribution.
Definition: binaryuniformgenerator.h:36
BinaryUniformGeneratorImpl()
Basic constructor for Binary Uniform Generator.
Definition: binaryuniformgenerator.h:49
Abstract class describing generator requirements.
Definition: distributiongenerator.h:188
VecType::Integer GenerateInteger() const
Generates a random value within the Binary Uniform Distribution.
Definition: binaryuniformgenerator.cpp:38
Definition: binfhecontext.h:36
VecType GenerateVector(const usint size, const typename VecType::Integer &modulus) const
Generates a vector of random values within the Binary Uniform Distribution.
Definition: binaryuniformgenerator.cpp:44