示例#1
0
 def _verify_bls_key_proof_of_possession(self, key_proof, pk):
     if self.bls_crypto_verifier is None:
         return True
     key_proof_bls = IndyCryptoBlsUtils.bls_from_str(key_proof, cls=ProofOfPossession)
     pk_bls = IndyCryptoBlsUtils.bls_from_str(pk, cls=VerKey)
     return self.bls_crypto_verifier.verify_key_proof_of_possession(key_proof_bls,
                                                                    pk_bls)
示例#2
0
def test_create_and_store_bls_keys(bls_crypto_factory):
    pk, key_proof = bls_crypto_factory.generate_and_store_bls_keys()
    assert pk
    assert isinstance(pk, str)
    assert bls_crypto_factory.create_bls_crypto_verifier() \
        .verify_key_proof_of_possession(IndyCryptoBlsUtils.bls_from_str(key_proof, cls=ProofOfPossession),
                                        IndyCryptoBlsUtils.bls_from_str(pk, cls=VerKey))
示例#3
0
 def _create_bls_crypto_signer(self, sk: str, pk: str,
                               group_params: GroupParams):
     sk_bls = IndyCryptoBlsUtils.bls_from_str(sk,
                                              cls=SignKey)  # type: SignKey
     pk_bls = IndyCryptoBlsUtils.bls_from_str(pk,
                                              cls=VerKey)  # type: VerKey
     return BlsCryptoSignerIndyCrypto(sk=sk_bls,
                                      pk=pk_bls,
                                      params=group_params)
    def _load_keys_for_root(self):
        keys = {}
        for _, txn in self._ledger.getAllTxn():
            if get_type(txn) != NODE:
                continue

            data = get_payload_data(txn)[DATA]
            node_name = data[ALIAS]

            if not config.VALIDATE_BLS_SIGNATURE_WITHOUT_KEY_PROOF and \
                    data.get(BLS_KEY_PROOF, None) is None:
                logger.warning(
                    "{} has no proof of possession for BLS public key.".format(
                        node_name))
                keys[node_name] = None
                continue

            key_str = data.get(BLS_KEY, None)
            if key_str is None:
                keys[node_name] = None
                continue

            key_bls = IndyCryptoBlsUtils.bls_from_str(key_str, cls=VerKey)
            keys[node_name] = key_bls
        return keys
def test_verify_non_base_58_pk_multi_signature(bls_signer1, bls_signer2, bls_verifier, message):
    pk1 = bls_signer1.pk
    pk2 = bls_signer2.pk

    sigs = []
    sigs.append(bls_signer1.sign(message))
    sigs.append(bls_signer2.sign(message))

    multi_sig = bls_verifier.create_multi_sig(sigs)

    pks = [pk1, IndyCryptoBlsUtils.bls_from_str('Incorrect pk 1', cls=VerKey)]
    assert not bls_verifier.verify_multi_sig(multi_sig, message, pks)

    pks = [IndyCryptoBlsUtils.bls_from_str('Incorrect pk 1', cls=VerKey), pk2]
    assert not bls_verifier.verify_multi_sig(multi_sig, message, pks)

    pks = [IndyCryptoBlsUtils.bls_from_str('Incorrect pk 1', cls=VerKey),
           IndyCryptoBlsUtils.bls_from_str('Incorrect pk 2', cls=VerKey)]
    assert not bls_verifier.verify_multi_sig(multi_sig, message, pks)
    def _load_keys_for_root(self, pool_state_root_hash):
        self._current_bls_keys = {}
        for data in self._node.write_manager.get_all_node_data_for_root_hash(
                pool_state_root_hash):
            node_name = data[ALIAS]
            if BLS_KEY not in data:
                continue

            if not self._node.poolManager.config.VALIDATE_BLS_SIGNATURE_WITHOUT_KEY_PROOF and \
                    data.get(BLS_KEY_PROOF, None) is None:
                logger.warning("{} has no proof of possession for BLS public key.".format(node_name))
                self._current_bls_keys[node_name] = None
                continue

            key_str = data.get(BLS_KEY, None)
            if key_str is None:
                self._current_bls_keys[node_name] = None
                continue

            key_bls = IndyCryptoBlsUtils.bls_from_str(key_str, cls=VerKey)
            self._current_bls_keys[node_name] = key_bls