1 /******************************************************************************* 2 HooghSchoenmakersSkoricVillegasVRHE.hh, 3 |V|erifiable |R|otation of |H|omomorphic |E|ncryptions 4 5 Sebastiaan de Hoogh, Berry Schoenmakers, Boris Skoric, and Jose Villegas: 6 'Verifiable Rotation of Homomorphic Encryptions', 7 Public Key Cryptography 2009, LNCS 5443, pp. 393--410, Springer 2009. 8 9 This file is part of LibTMCG. 10 11 Copyright (C) 2009, 2015, 2016, 2018 Heiko Stamer <HeikoStamer@gmx.net> 12 13 LibTMCG is free software; you can redistribute it and/or modify 14 it under the terms of the GNU General Public License as published by 15 the Free Software Foundation; either version 2 of the License, or 16 (at your option) any later version. 17 18 LibTMCG is distributed in the hope that it will be useful, 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 GNU General Public License for more details. 22 23 You should have received a copy of the GNU General Public License 24 along with LibTMCG; if not, write to the Free Software 25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 26 *******************************************************************************/ 27 28 #ifndef INCLUDED_HooghSchoenmakersSkoricVillegasVRHE_HH 29 #define INCLUDED_HooghSchoenmakersSkoricVillegasVRHE_HH 30 31 // C and STL header 32 #include <cstdlib> 33 #include <iostream> 34 #include <vector> 35 36 // GNU multiple precision library 37 #include <gmp.h> 38 39 // erasure-free distributed coinflip protocol 40 #include "JareckiLysyanskayaASTC.hh" 41 42 class HooghSchoenmakersSkoricVillegasPUBROTZK 43 { 44 private: 45 mpz_t *fpowm_table_g, *fpowm_table_h; 46 47 public: 48 mpz_t p, q, g, h; 49 50 HooghSchoenmakersSkoricVillegasPUBROTZK 51 (mpz_srcptr p_ENC, mpz_srcptr q_ENC, mpz_srcptr g_ENC, mpz_srcptr h_ENC); 52 bool CheckElement 53 (mpz_srcptr a) const; 54 void Prove_interactive 55 (size_t r, const std::vector<mpz_ptr> &s, 56 const std::vector<mpz_ptr> &alpha, const std::vector<mpz_ptr> &c, 57 std::istream &in, std::ostream &out) const; 58 void Prove_interactive_publiccoin 59 (size_t r, const std::vector<mpz_ptr> &s, 60 const std::vector<mpz_ptr> &alpha, const std::vector<mpz_ptr> &c, 61 JareckiLysyanskayaEDCF *edcf, 62 std::istream &in, std::ostream &out) const; 63 void Prove_noninteractive 64 (size_t r, const std::vector<mpz_ptr> &s, 65 const std::vector<mpz_ptr> &alpha, const std::vector<mpz_ptr> &c, 66 std::ostream &out) const; 67 bool Verify_interactive 68 (const std::vector<mpz_ptr> &alpha, const std::vector<mpz_ptr> &c, 69 std::istream &in, std::ostream &out) const; 70 bool Verify_interactive_publiccoin 71 (const std::vector<mpz_ptr> &alpha, const std::vector<mpz_ptr> &c, 72 JareckiLysyanskayaEDCF *edcf, 73 std::istream &in, std::ostream &out) const; 74 bool Verify_noninteractive 75 (const std::vector<mpz_ptr> &alpha, const std::vector<mpz_ptr> &c, 76 std::istream &in) const; 77 ~HooghSchoenmakersSkoricVillegasPUBROTZK 78 (); 79 }; 80 81 // ============================================================================= 82 83 class HooghSchoenmakersSkoricVillegasVRHE 84 { 85 private: 86 mpz_t *fpowm_table_g, *fpowm_table_h; 87 HooghSchoenmakersSkoricVillegasPUBROTZK *pub_rot_zk; 88 const unsigned long int F_size, G_size; 89 90 public: 91 mpz_t p, q, g, h; 92 93 HooghSchoenmakersSkoricVillegasVRHE 94 (unsigned long int fieldsize = TMCG_DDH_SIZE, 95 unsigned long int subgroupsize = TMCG_DLSE_SIZE); 96 HooghSchoenmakersSkoricVillegasVRHE 97 (mpz_srcptr p_ENC, mpz_srcptr q_ENC, mpz_srcptr g_ENC, mpz_srcptr h_ENC, 98 unsigned long int fieldsize = TMCG_DDH_SIZE, 99 unsigned long int subgroupsize = TMCG_DLSE_SIZE); 100 HooghSchoenmakersSkoricVillegasVRHE 101 (std::istream &in, 102 unsigned long int fieldsize = TMCG_DDH_SIZE, 103 unsigned long int subgroupsize = TMCG_DLSE_SIZE); 104 bool CheckGroup 105 () const; 106 bool CheckElement 107 (mpz_srcptr a) const; 108 void PublishGroup 109 (std::ostream &out) const; 110 void Prove_interactive 111 (size_t r, const std::vector<mpz_ptr> &s, 112 const std::vector<std::pair<mpz_ptr, mpz_ptr> > &X, 113 const std::vector<std::pair<mpz_ptr, mpz_ptr> > &Y, 114 std::istream &in, std::ostream &out) const; 115 void Prove_interactive_publiccoin 116 (size_t r, const std::vector<mpz_ptr> &s, 117 const std::vector<std::pair<mpz_ptr, mpz_ptr> > &X, 118 const std::vector<std::pair<mpz_ptr, mpz_ptr> > &Y, 119 JareckiLysyanskayaEDCF *edcf, 120 std::istream &in, std::ostream &out) const; 121 void Prove_noninteractive 122 (size_t r, const std::vector<mpz_ptr> &s, 123 const std::vector<std::pair<mpz_ptr, mpz_ptr> > &X, 124 const std::vector<std::pair<mpz_ptr, mpz_ptr> > &Y, 125 std::ostream &out) const; 126 bool Verify_interactive 127 (const std::vector<std::pair<mpz_ptr, mpz_ptr> > &X, 128 const std::vector<std::pair<mpz_ptr, mpz_ptr> > &Y, 129 std::istream &in, std::ostream &out) const; 130 bool Verify_interactive_publiccoin 131 (const std::vector<std::pair<mpz_ptr, mpz_ptr> > &X, 132 const std::vector<std::pair<mpz_ptr, mpz_ptr> > &Y, 133 JareckiLysyanskayaEDCF *edcf, 134 std::istream &in, std::ostream &out) const; 135 bool Verify_noninteractive 136 (const std::vector<std::pair<mpz_ptr, mpz_ptr> > &X, 137 const std::vector<std::pair<mpz_ptr, mpz_ptr> > &Y, 138 std::istream &in) const; 139 ~HooghSchoenmakersSkoricVillegasVRHE 140 (); 141 }; 142 143 #endif 144