Skip to content

Commit 01cfdb0

Browse files
Improved Sharing
1 parent 7da4d36 commit 01cfdb0

File tree

2 files changed

+163
-199
lines changed

2 files changed

+163
-199
lines changed

inc/Util/Sharing.hpp

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -127,26 +127,13 @@ class Sharing {
127127
std::vector<uint64_t> SampleRandomBitslicedPolynomial();
128128

129129
private:
130-
/**
131-
* @brief Converts a polynomial represented as coefficient vector to an fq_t
132-
* polynomial.
133-
* @param polynomial The polynomial represented as coefficient vector.
134-
* @param polynomial_fq The converted polynomial stored as an fq_t.
135-
*/
136-
void ConvertPolynomialToFq(Polynomial& polynomial, fq_t& polynomial_fq) const;
137-
138130
/**
139131
* @brief Converts an fq_t polynomial to a polynomial represented as
140132
* coefficient vector.
141133
* @param polynomial_fq The polynomial represented as an fq_t.
142134
* @param polynomial_fq The converted polynomial stored as coefficient vector.
143135
*/
144-
void ConvertFqToPolynomial(fq_t& polynomial_fq, Polynomial& polynomial) const;
145-
146-
Polynomial ConvertBitsetToPolynomial(
147-
const boost::dynamic_bitset<>& bitset) const;
148-
boost::dynamic_bitset<> ConvertPolynomialToBitset(
149-
const Polynomial& polynomial) const;
136+
void ConvertFqToPolynomial(fq_t& polynomial_fq, Polynomial& polynomial);
150137

151138
void SampleRandomPolynomial(fq_t& random_polynomial_fq);
152139

@@ -173,8 +160,6 @@ class Sharing {
173160
*/
174161
bool IsInField(const Polynomial& polynomial) const;
175162

176-
uint64_t GetLengthOfElementsInBits() const;
177-
178163
/**
179164
* @brief Encodes an unshared polynomial X into its shared representation
180165
* Sh(X).
@@ -185,7 +170,7 @@ class Sharing {
185170
* that it satisfies the additive sharing property. Further, 'o' denotes the
186171
* operation under the finite field.
187172
*
188-
* @param polynomial The unshared polynomial to be encoded.
173+
* @param polynomial_fq The unshared polynomial to be encoded.
189174
* @param number_of_shares The number of shares to generate, denoted as d.
190175
* @param is_additive_masking A boolean indicating the operation used:
191176
* - true: The operation is additive, so '+' is used.
@@ -194,7 +179,7 @@ class Sharing {
194179
* * @return A vector of d polynomials representing the shared
195180
* representation Sh(X).
196181
*/
197-
std::vector<Polynomial> Encode(Polynomial& polynomial,
182+
std::vector<Polynomial> Encode(fq_t& polynomial_fq,
198183
uint64_t number_of_shares,
199184
bool is_additive_masking);
200185

@@ -213,16 +198,17 @@ class Sharing {
213198
* finite field.
214199
* @return The decoded (unshared) polynomial.
215200
*/
216-
Polynomial Decode(std::vector<Polynomial> shared_polynomial,
217-
bool is_additive_masking) const;
201+
Polynomial Decode(std::vector<fq_t>& shared_polynomial_fq,
202+
bool is_additive_masking);
218203

219204
uint64_t prime_base_;
220205
uint64_t extension_degree_;
221206
uint64_t size_coefficients_bits_;
222-
boost::uniform_int<uint64_t> dist_;
223-
boost::variate_generator<boost::mt19937&, boost::uniform_int<uint64_t>> gen_;
207+
uint64_t length_of_elements_in_bits_;
224208

225209
fmpz_t prime_fmpz_;
226210
fq_ctx_t ctx_fq_;
211+
flint_rand_t random_state_;
212+
fmpz_mod_poly_t fmpz_poly_;
227213
fmpz_mod_ctx_t ctx_fmpz_mod_;
228214
};

0 commit comments

Comments
 (0)