diff --git a/bls/BLSPrivateKeyShare.cpp b/bls/BLSPrivateKeyShare.cpp index 517fd835..ee4b6297 100644 --- a/bls/BLSPrivateKeyShare.cpp +++ b/bls/BLSPrivateKeyShare.cpp @@ -128,7 +128,11 @@ BLSPrivateKeyShare::generateSampleKeys( size_t _requiredSigners, size_t _totalSi std::vector< libff::alt_bn128_Fr > skeys = dkg_obj.SecretKeyContribution( pol ); libff::alt_bn128_Fr common_skey = pol.at( 0 ); - std::shared_ptr< BLSPublicKey > pkey_ptr = std::make_shared< BLSPublicKey >( common_skey ); + std::shared_ptr< BLSPublicKey > pkey_ptr = std::make_shared< BLSPublicKey >( + common_skey, + _requiredSigners, + _totalSigners + ); for ( size_t i = 0; i < _totalSigners; ++i ) { std::string key_str = libBLS::ThresholdUtils::fieldElementToString( skeys.at( i ) ); diff --git a/bls/BLSPublicKey.cpp b/bls/BLSPublicKey.cpp index cd5c39f3..1c078de5 100644 --- a/bls/BLSPublicKey.cpp +++ b/bls/BLSPublicKey.cpp @@ -50,16 +50,24 @@ BLSPublicKey::BLSPublicKey( const std::shared_ptr< std::vector< std::string > > } } -BLSPublicKey::BLSPublicKey( const libff::alt_bn128_G2& pkey ) { +BLSPublicKey::BLSPublicKey( const libff::alt_bn128_G2& pkey, size_t t, size_t n ) + : t( t ), n( n ) { libBLS::ThresholdUtils::initCurve(); + // do not check signers for compatibility + // libBLS::ThresholdUtils::checkSigners( t, n ); + libffPublicKey = std::make_shared< libff::alt_bn128_G2 >( pkey ); if ( libffPublicKey->is_zero() ) { throw libBLS::ThresholdUtils::IsNotWellFormed( "Zero BLS Public Key" ); } } -BLSPublicKey::BLSPublicKey( const libff::alt_bn128_Fr& skey ) { +BLSPublicKey::BLSPublicKey(const libff::alt_bn128_Fr& skey, size_t t, size_t n ) + : t( t ), n( n ) { + // do not check signers for compatibility + // libBLS::ThresholdUtils::checkSigners( t, n ); + libffPublicKey = std::make_shared< libff::alt_bn128_G2 >( skey * libff::alt_bn128_G2::one() ); if ( libffPublicKey->is_zero() ) { throw libBLS::ThresholdUtils::IsNotWellFormed( "Public Key is equal to zero or corrupt" ); diff --git a/bls/BLSPublicKey.h b/bls/BLSPublicKey.h index 04e9c389..18d32599 100644 --- a/bls/BLSPublicKey.h +++ b/bls/BLSPublicKey.h @@ -38,8 +38,10 @@ class BLSPublicKey { public: BLSPublicKey( const std::shared_ptr< std::vector< std::string > > ); - BLSPublicKey( const libff::alt_bn128_Fr& skey ); - BLSPublicKey( const libff::alt_bn128_G2& skey ); + // default value set to 0 for compatibility + BLSPublicKey( const libff::alt_bn128_Fr& skey, size_t t = 0, size_t n = 0 ); + // default value set to 0 for compatibility + BLSPublicKey( const libff::alt_bn128_G2& skey, size_t t = 0, size_t n = 0 ); BLSPublicKey( std::shared_ptr< std::map< size_t, std::shared_ptr< BLSPublicKeyShare > > > map_pkeys_koefs,