diff --git a/threshold_encryption/TEDecryptionShare.cpp b/threshold_encryption/TEDecryptionShare.cpp index 465f3aef..01d9c6aa 100644 --- a/threshold_encryption/TEDecryptionShare.cpp +++ b/threshold_encryption/TEDecryptionShare.cpp @@ -26,15 +26,21 @@ along with libBLS. If not, see . namespace libBLS { -TEDecryptionShare::TEDecryptionShare( const algebra::G2Point& _share, size_t _signerIndex ) +TEDecryptionShare::TEDecryptionShare( + const algebra::G2Point& _share, size_t _signerIndex, bool _validate ) : signerIndex( _signerIndex ), share( _share ) { - share.validate(); + if ( _validate ) { + share.validate(); + } } -TEDecryptionShare::TEDecryptionShare( const std::string& _hexaEncoded, size_t _signerIndex ) +TEDecryptionShare::TEDecryptionShare( + const std::string& _hexaEncoded, size_t _signerIndex, bool _validate ) : signerIndex( _signerIndex ) { share = algebra::G2Point::fromString( _hexaEncoded, Base::HEXA ); - share.validate(); + if ( _validate ) { + share.validate(); + } } size_t TEDecryptionShare::getSignerIndex() const { diff --git a/threshold_encryption/TEDecryptionShare.h b/threshold_encryption/TEDecryptionShare.h index e852e5d0..46dff9e3 100644 --- a/threshold_encryption/TEDecryptionShare.h +++ b/threshold_encryption/TEDecryptionShare.h @@ -40,18 +40,23 @@ class TEDecryptionShare { public: /** - * @param _signerIndex Index of the signer * @param _share Decryption share - * @note Validates that the share is well formed and non-zero. + * @param _signerIndex Index of the signer + * @param _validate Whether to validate the share or not (Optional, default: true) + * Note: Validation is a costly operation, so it can be skipped if the share is already known to + * be valid. */ - TEDecryptionShare( const algebra::G2Point& _share, size_t _signerIndex ); + TEDecryptionShare( const algebra::G2Point& _share, size_t _signerIndex, bool _validate = true ); /** - * @param _signerIndex Index of the signer * @param _hexaEncoded Hexa encoded string of the share - * @note Used when building from serialized decription share + * @param _signerIndex Index of the signer + * @param _validate Whether to validate the share or not (Optional, default: true) + * Note: Validation is a costly operation, so it can be skipped if the share is already known to + * be valid. */ - TEDecryptionShare( const std::string& _hexaEncoded, size_t _signerIndex ); + TEDecryptionShare( + const std::string& _hexaEncoded, size_t _signerIndex, bool _validate = true ); size_t getSignerIndex() const;