@@ -46,30 +46,36 @@ int main() {
4646 * correction. Lets see error detection at work first
4747 */
4848
49+ scl::details::ShamirSSFactory<Fp> factory (
50+ 1 , prg, scl::details::SecurityLevel::CORRECT);
4951 /* We create 4 shamir shares with a threshold of 1.
5052 */
51- auto shamir_shares = scl::CreateShamirShares (secret, 4 , 1 , prg );
53+ auto shamir_shares = factory. Share (secret);
5254 std::cout << shamir_shares << " \n " ;
5355
5456 /* Of course, these can be reconstructed. The second parameter is the
5557 * threshold. This performs reconstruction with error detection.
5658 */
57- auto shamir_reconstructed = scl::ReconstructShamir (shamir_shares, 1 );
59+ auto recon = factory.GetInterpolator ();
60+ auto shamir_reconstructed =
61+ recon.Reconstruct (shamir_shares, scl::details::SecurityLevel::DETECT);
5862 std::cout << shamir_reconstructed << " \n " ;
5963
6064 /* If we introduce an error, then reconstruction fails
6165 */
6266 shamir_shares[2 ] = Fp (123 );
6367 try {
64- std::cout << scl::ReconstructShamir (shamir_shares, 1 ) << " \n " ;
68+ std::cout << recon.Reconstruct (shamir_shares,
69+ scl::details::SecurityLevel::DETECT)
70+ << " \n " ;
6571 } catch (std::logic_error& e) {
6672 std::cout << e.what () << " \n " ;
6773 }
6874
6975 /* On the other hand, we can use the robust reconstruction since the threshold
7076 * is low enough. I.e., because 4 >= 3*1 + 1.
7177 */
72- auto r = scl::ReconstructShamirRobust (shamir_shares, 1 );
78+ auto r = recon. Reconstruct (shamir_shares);
7379 std::cout << r << " \n " ;
7480
7581 /* With a bit of extra work, we can even learn which share had the error.
@@ -79,26 +85,26 @@ int main() {
7985 * default these are just the field elements 1 through 4.
8086 */
8187 Vec alphas = {Fp (1 ), Fp (2 ), Fp (3 ), Fp (4 )};
82- auto pe = scl::ReconstructShamirRobust (shamir_shares, alphas, 1 );
88+ auto pe = scl::details:: ReconstructShamirRobust (shamir_shares, alphas, 1 );
8389
8490 /* pe is a pair of polynomials. The first is the original polynomial used for
8591 * generating the shares and the second is a polynomial whose roots tell which
8692 * share had errors.
8793 *
8894 * The secret is embedded in the constant term.
8995 */
90- std::cout << pe[ 0 ] .Evaluate (Fp (0 )) << " \n " ;
96+ std::cout << std::get< 0 >(pe) .Evaluate (Fp (0 )) << " \n " ;
9197
9298 /* This will be 0, indicating that the share corresponding to party 3 had an
9399 * error.
94100 */
95- std::cout << pe[ 1 ] .Evaluate (Fp (3 )) << " \n " ;
101+ std::cout << std::get< 1 >(pe) .Evaluate (Fp (3 )) << " \n " ;
96102
97103 /* Lastly, if there's too many errors, then correction is not possible
98104 */
99105 shamir_shares[1 ] = Fp (22 );
100106 try {
101- scl::ReconstructShamirRobust (shamir_shares, 1 );
107+ recon. Reconstruct (shamir_shares);
102108 } catch (std::logic_error& e) {
103109 std::cout << e.what () << " \n " ;
104110 }
0 commit comments