@@ -140,6 +140,140 @@ BlindsCache<C1, C2>::~BlindsCache()
140140
141141template BlindsCache<Selene, Helios>::~BlindsCache ();
142142// ----------------------------------------------------------------------------------------------------------------------
143+ // ----------------------------------------------------------------------------------------------------------------------
144+ // TODO: macro the below
145+ template <>
146+ std::shared_ptr<OutputBlind> BlindsCache<Selene, Helios>::get_blinded_o_blind_async(const SeleneScalar o_blind)
147+ {
148+ std::shared_ptr<OutputBlind> pending_o_blind = std::make_shared<OutputBlind>();
149+
150+ m_tpool->submit (&m_waiter,
151+ [pending_o_blind, o_blind]()
152+ {
153+ // Do the expensive calculation
154+ const uint8_t *blind_ptr = fcmp_pp::blind_o_blind (o_blind);
155+ *pending_o_blind = fcmp_pp::o_blind_to_buf (blind_ptr);
156+ },
157+ true );
158+
159+ return pending_o_blind;
160+ }
161+ // ----------------------------------------------------------------------------------------------------------------------
162+ template <>
163+ std::shared_ptr<OutputBlind> BlindsCache<Selene, Helios>::get_blinded_i_blind_async(const SeleneScalar i_blind)
164+ {
165+ std::shared_ptr<OutputBlind> pending_i_blind = std::make_shared<OutputBlind>();
166+
167+ m_tpool->submit (&m_waiter,
168+ [pending_i_blind, i_blind]()
169+ {
170+ // Do the expensive calculation
171+ const uint8_t *blind_ptr = fcmp_pp::blind_i_blind (i_blind);
172+ *pending_i_blind = fcmp_pp::i_blind_to_buf (blind_ptr);
173+ },
174+ true );
175+
176+ return pending_i_blind;
177+ }
178+ // ----------------------------------------------------------------------------------------------------------------------
179+ template <>
180+ std::shared_ptr<OutputBlind> BlindsCache<Selene, Helios>::get_blinded_i_blind_blind_async(
181+ const SeleneScalar i_blind_blind)
182+ {
183+ std::shared_ptr<OutputBlind> pending_i_blind_blind = std::make_shared<OutputBlind>();
184+
185+ m_tpool->submit (&m_waiter,
186+ [pending_i_blind_blind, i_blind_blind]()
187+ {
188+ // Do the expensive calculation
189+ const uint8_t *blind_ptr = fcmp_pp::blind_i_blind_blind (i_blind_blind);
190+ *pending_i_blind_blind = fcmp_pp::i_blind_blind_to_buf (blind_ptr);
191+ },
192+ true );
193+
194+ return pending_i_blind_blind;
195+ }
196+ // ----------------------------------------------------------------------------------------------------------------------
197+ template <>
198+ std::shared_ptr<OutputBlind> BlindsCache<Selene, Helios>::get_blinded_c_blind_async(const SeleneScalar c_blind)
199+ {
200+ std::shared_ptr<OutputBlind> pending_c_blind = std::make_shared<OutputBlind>();
201+
202+ m_tpool->submit (&m_waiter,
203+ [pending_c_blind, c_blind]()
204+ {
205+ // Do the expensive calculation
206+ const uint8_t *blind_ptr = fcmp_pp::blind_c_blind (c_blind);
207+ *pending_c_blind = fcmp_pp::c_blind_to_buf (blind_ptr);
208+ },
209+ true );
210+
211+ return pending_c_blind;
212+ }
213+ // ----------------------------------------------------------------------------------------------------------------------
214+ template <>
215+ std::shared_ptr<BranchBlind> BlindsCache<Selene, Helios>::get_c1_branch_blind_async()
216+ {
217+ std::shared_ptr<BranchBlind> pending_branch_blind = std::make_shared<BranchBlind>();
218+
219+ m_tpool->submit (&m_waiter,
220+ [pending_branch_blind]()
221+ {
222+ // Do the expensive calculation
223+ const uint8_t *branch_blind_ptr = fcmp_pp::selene_branch_blind ();
224+ *pending_branch_blind = fcmp_pp::selene_blind_to_buf (branch_blind_ptr);
225+ },
226+ true );
227+
228+ return pending_branch_blind;
229+ }
230+ // ----------------------------------------------------------------------------------------------------------------------
231+ template <>
232+ std::shared_ptr<BranchBlind> BlindsCache<Selene, Helios>::get_c2_branch_blind_async()
233+ {
234+ std::shared_ptr<BranchBlind> pending_branch_blind = std::make_shared<BranchBlind>();
235+
236+ m_tpool->submit (&m_waiter,
237+ [pending_branch_blind]()
238+ {
239+ // Do the expensive calculation
240+ const uint8_t *branch_blind_ptr = fcmp_pp::helios_branch_blind ();
241+ *pending_branch_blind = fcmp_pp::helios_blind_to_buf (branch_blind_ptr);
242+ },
243+ true );
244+
245+ return pending_branch_blind;
246+ }
247+ // ----------------------------------------------------------------------------------------------------------------------
248+ template <>
249+ void BlindsCache<Selene, Helios>::calc_needed_branch_blinds_async()
250+ {
251+ std::lock_guard<std::mutex> guard (m_mutex);
252+
253+ while (true )
254+ {
255+ const std::size_t n_c1_branch_blinds = m_pending_c1_branch_blinds.size ();
256+ const std::size_t n_c2_branch_blinds = m_pending_c2_branch_blinds.size ();
257+
258+ // Check if we need to calculate more branch blinds
259+ if (need_more_c1_blinds (m_prepare_n_min_inputs, m_output_blindings.size (), m_n_tree_layers, n_c1_branch_blinds))
260+ {
261+ // Calculate c1 branch blind in the background
262+ m_pending_c1_branch_blinds.push_back (this ->get_c1_branch_blind_async ());
263+ continue ;
264+ }
265+
266+ if (need_more_c2_blinds (m_prepare_n_min_inputs, m_output_blindings.size (), m_n_tree_layers, n_c2_branch_blinds))
267+ {
268+ // Calculate c1 branch blind in the background
269+ m_pending_c2_branch_blinds.push_back (this ->get_c2_branch_blind_async ());
270+ continue ;
271+ }
272+
273+ break ;
274+ }
275+ }
276+ // ----------------------------------------------------------------------------------------------------------------------
143277template <typename C1, typename C2>
144278void BlindsCache<C1, C2>::set_n_tree_layers(uint8_t n_tree_layers)
145279{
@@ -225,40 +359,6 @@ template uint8_t *BlindsCache<Selene, Helios>::get_output_blinds(const OutputPai
225359 FcmpRerandomizedOutputCompressed &rerandomized_output_out);
226360// ----------------------------------------------------------------------------------------------------------------------
227361template <>
228- std::shared_ptr<BranchBlind> BlindsCache<Selene, Helios>::get_c1_branch_blind_async()
229- {
230- std::shared_ptr<BranchBlind> pending_branch_blind = std::make_shared<BranchBlind>();
231-
232- m_tpool->submit (&m_waiter,
233- [pending_branch_blind]()
234- {
235- // Do the expensive calculation
236- const uint8_t *branch_blind_ptr = fcmp_pp::selene_branch_blind ();
237- *pending_branch_blind = fcmp_pp::selene_blind_to_buf (branch_blind_ptr);
238- },
239- true );
240-
241- return pending_branch_blind;
242- }
243- // ----------------------------------------------------------------------------------------------------------------------
244- template <>
245- std::shared_ptr<BranchBlind> BlindsCache<Selene, Helios>::get_c2_branch_blind_async()
246- {
247- std::shared_ptr<BranchBlind> pending_branch_blind = std::make_shared<BranchBlind>();
248-
249- m_tpool->submit (&m_waiter,
250- [pending_branch_blind]()
251- {
252- // Do the expensive calculation
253- const uint8_t *branch_blind_ptr = fcmp_pp::helios_branch_blind ();
254- *pending_branch_blind = fcmp_pp::helios_blind_to_buf (branch_blind_ptr);
255- },
256- true );
257-
258- return pending_branch_blind;
259- }
260- // ----------------------------------------------------------------------------------------------------------------------
261- template <>
262362std::vector<const uint8_t *> BlindsCache<Selene, Helios>::get_c1_branch_blinds(uint8_t n_layers, uint8_t n_inputs)
263363{
264364 // See how many branch blinds we will need to respond with
@@ -326,105 +426,6 @@ void BlindsCache<C1, C2>::clear()
326426
327427template void BlindsCache<Selene, Helios>::clear();
328428// ----------------------------------------------------------------------------------------------------------------------
329- template <>
330- void BlindsCache<Selene, Helios>::calc_needed_branch_blinds_async()
331- {
332- std::lock_guard<std::mutex> guard (m_mutex);
333-
334- while (true )
335- {
336- const std::size_t n_c1_branch_blinds = m_pending_c1_branch_blinds.size ();
337- const std::size_t n_c2_branch_blinds = m_pending_c2_branch_blinds.size ();
338-
339- // Check if we need to calculate more branch blinds
340- if (need_more_c1_blinds (m_prepare_n_min_inputs, m_output_blindings.size (), m_n_tree_layers, n_c1_branch_blinds))
341- {
342- // Calculate c1 branch blind in the background
343- m_pending_c1_branch_blinds.push_back (this ->get_c1_branch_blind_async ());
344- continue ;
345- }
346-
347- if (need_more_c2_blinds (m_prepare_n_min_inputs, m_output_blindings.size (), m_n_tree_layers, n_c2_branch_blinds))
348- {
349- // Calculate c1 branch blind in the background
350- m_pending_c2_branch_blinds.push_back (this ->get_c2_branch_blind_async ());
351- continue ;
352- }
353-
354- break ;
355- }
356- }
357- // ----------------------------------------------------------------------------------------------------------------------
358- // ----------------------------------------------------------------------------------------------------------------------
359- // TODO: macro the below
360- template <>
361- std::shared_ptr<OutputBlind> BlindsCache<Selene, Helios>::get_blinded_o_blind_async(const SeleneScalar o_blind)
362- {
363- std::shared_ptr<OutputBlind> pending_o_blind = std::make_shared<OutputBlind>();
364-
365- m_tpool->submit (&m_waiter,
366- [pending_o_blind, o_blind]()
367- {
368- // Do the expensive calculation
369- const uint8_t *blind_ptr = fcmp_pp::blind_o_blind (o_blind);
370- *pending_o_blind = fcmp_pp::o_blind_to_buf (blind_ptr);
371- },
372- true );
373-
374- return pending_o_blind;
375- }
376- // ----------------------------------------------------------------------------------------------------------------------
377- template <>
378- std::shared_ptr<OutputBlind> BlindsCache<Selene, Helios>::get_blinded_i_blind_async(const SeleneScalar i_blind)
379- {
380- std::shared_ptr<OutputBlind> pending_i_blind = std::make_shared<OutputBlind>();
381-
382- m_tpool->submit (&m_waiter,
383- [pending_i_blind, i_blind]()
384- {
385- // Do the expensive calculation
386- const uint8_t *blind_ptr = fcmp_pp::blind_i_blind (i_blind);
387- *pending_i_blind = fcmp_pp::i_blind_to_buf (blind_ptr);
388- },
389- true );
390-
391- return pending_i_blind;
392- }
393- // ----------------------------------------------------------------------------------------------------------------------
394- template <>
395- std::shared_ptr<OutputBlind> BlindsCache<Selene, Helios>::get_blinded_i_blind_blind_async(
396- const SeleneScalar i_blind_blind)
397- {
398- std::shared_ptr<OutputBlind> pending_i_blind_blind = std::make_shared<OutputBlind>();
399-
400- m_tpool->submit (&m_waiter,
401- [pending_i_blind_blind, i_blind_blind]()
402- {
403- // Do the expensive calculation
404- const uint8_t *blind_ptr = fcmp_pp::blind_i_blind_blind (i_blind_blind);
405- *pending_i_blind_blind = fcmp_pp::i_blind_blind_to_buf (blind_ptr);
406- },
407- true );
408-
409- return pending_i_blind_blind;
410- }
411- // ----------------------------------------------------------------------------------------------------------------------
412- template <>
413- std::shared_ptr<OutputBlind> BlindsCache<Selene, Helios>::get_blinded_c_blind_async(const SeleneScalar c_blind)
414- {
415- std::shared_ptr<OutputBlind> pending_c_blind = std::make_shared<OutputBlind>();
416-
417- m_tpool->submit (&m_waiter,
418- [pending_c_blind, c_blind]()
419- {
420- // Do the expensive calculation
421- const uint8_t *blind_ptr = fcmp_pp::blind_c_blind (c_blind);
422- *pending_c_blind = fcmp_pp::c_blind_to_buf (blind_ptr);
423- },
424- true );
425-
426- return pending_c_blind;
427- }
428429// ----------------------------------------------------------------------------------------------------------------------
429430template <typename C1, typename C2>
430431void BlindsCache<C1, C2>::export_serializable_members(
0 commit comments