1818 * along with this program. If not, see <https://www.gnu.org/licenses/>.
1919 */
2020
21- #include < scl/math.h>
22- #include < scl/secret_sharing.h>
23-
2421#include < iostream>
2522#include < stdexcept>
2623
24+ #include < scl/math.h>
25+ #include < scl/secret_sharing.h>
26+
2727int main () {
2828 using Fp = scl::Fp<32 >;
2929 using Vec = scl::Vec<Fp>;
30- scl::PRG prg;
30+
31+ auto prg = scl::PRG::Create ();
3132
3233 /* We can easily create an additive secret sharing of some secret value:
3334 */
@@ -46,8 +47,8 @@ int main() {
4647 * correction. Lets see error detection at work first
4748 */
4849
49- scl::details::ShamirSSFactory<Fp> factory (
50- 1 , prg, scl::details ::SecurityLevel::CORRECT);
50+ auto factory =
51+ scl::ShamirSSFactory<Fp>:: Create ( 1 , prg, scl::SecurityLevel::CORRECT);
5152 /* We create 4 shamir shares with a threshold of 1.
5253 */
5354 auto shamir_shares = factory.Share (secret);
@@ -56,17 +57,15 @@ int main() {
5657 /* Of course, these can be reconstructed. The second parameter is the
5758 * threshold. This performs reconstruction with error detection.
5859 */
59- auto recon = factory.GetInterpolator ();
6060 auto shamir_reconstructed =
61- recon. Reconstruct (shamir_shares, scl::details ::SecurityLevel::DETECT);
61+ factory. Recover (shamir_shares, scl::SecurityLevel::DETECT);
6262 std::cout << shamir_reconstructed << " \n " ;
6363
6464 /* If we introduce an error, then reconstruction fails
6565 */
6666 shamir_shares[2 ] = Fp (123 );
6767 try {
68- std::cout << recon.Reconstruct (shamir_shares,
69- scl::details::SecurityLevel::DETECT)
68+ std::cout << factory.Recover (shamir_shares, scl::SecurityLevel::DETECT)
7069 << " \n " ;
7170 } catch (std::logic_error& e) {
7271 std::cout << e.what () << " \n " ;
@@ -75,7 +74,7 @@ int main() {
7574 /* On the other hand, we can use the robust reconstruction since the threshold
7675 * is low enough. I.e., because 4 >= 3*1 + 1.
7776 */
78- auto r = recon. Reconstruct (shamir_shares);
77+ auto r = factory. Recover (shamir_shares);
7978 std::cout << r << " \n " ;
8079
8180 /* With a bit of extra work, we can even learn which share had the error.
@@ -104,7 +103,7 @@ int main() {
104103 */
105104 shamir_shares[1 ] = Fp (22 );
106105 try {
107- recon. Reconstruct (shamir_shares);
106+ factory. Recover (shamir_shares);
108107 } catch (std::logic_error& e) {
109108 std::cout << e.what () << " \n " ;
110109 }
0 commit comments