nextleap-project / muacryptcc

Claimchain plugin for Muacrypt
0 stars 1 forks source link

upgrade claimchain-core to fix test failing non deterministically #11

Closed azul closed 6 years ago

azul commented 6 years ago

Only saw this once and cannot reproduce:

_______________________ test_add_claim_with_access_control[filestore] ________________________

make_account = <function maker at 0x7fb3bd7f2ed8>

    def test_add_claim_with_access_control(make_account):
        cc_alice = make_account("alice")
        cc_bob = make_account("bo")
        bob_pk = cc_bob.get_public_key()

        assert not cc_alice.read_claim("bob_hair")

        cc_alice.add_claim(
            claim=("bob_hair", "black")
        )
        cc_alice.commit_to_chain()
        assert cc_alice.read_claim("bob_hair")

        cc_alice.register_peer('bob', cc_bob.head_imprint, '', pk=bob_pk)
        cc_alice.add_claim(claim=("bob_feet", "4"), reader='bob')
        cc_alice.commit_to_chain()
>       assert cc_alice.read_claim("bob_feet", reader=cc_bob)

tests/test_plugin.py:51: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
muacryptcc/plugin.py:150: in read_claim
    value = View(chain)[claimkey.encode('utf-8')]
../claimchain-core/claimchain/state.py:253: in __getitem__
    vrf_value, claim_lookup_key = self._lookup_capability(claim_label)
../claimchain-core/claimchain/state.py:239: in _lookup_capability
    claim_label, cap)
../claimchain-core/claimchain/utils/profiling.py:37: in wrapped
    return func(*args, **kwargs)
../claimchain-core/claimchain/core.py:129: in decode_capability
    enc_key, b"\x00"*pp.enc_key_size, enc_body, tag)
../../.virtualenvs/0/local/lib/python2.7/site-packages/petlib/cipher.py:220: in quick_gcm_dec
    dec.set_tag(tag)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <petlib.cipher.CipherOperation object at 0x7fb3bda62368>, tag = ''

    def set_tag(self, tag):
        """Specify the GCM authenticator tag. Must be done before finalizing decryption

            Example:
                AES-GCM decryption and check:

                >>> aes = Cipher.aes_128_gcm()              # Define an AES-GCM cipher
                >>> ciphertext, tag = (b'dV\\xb9:\\xd0\\xbe', b'pA\\xbe?\\xfc\\xd1&\\x03\\x1438\\xc5\\xf8In\\xaa')
                >>> dec = aes.dec(key=b"A"*16, iv=b"A"*16)  # Get a decryption CipherOperation
                >>> dec.update_associated(b"Hello")         # Feed in the non-secret assciated data.
                >>> plaintext = dec.update(ciphertext)      # Feed in the ciphertext for decryption.
                >>> dec.set_tag(tag)                        # Provide the AES-GCM tag for integrity.
                >>> nothing = dec.finalize()                # Check and finalize.
                >>> assert plaintext == b'World!'

            """
        ok = (_C.EVP_CIPHER_CTX_ctrl(self.ctx, _C.EVP_CTRL_GCM_SET_TAG, len(tag), tag))
>       if not ok: raise Exception("Cipher exception: Set tag failed.")
E       Exception: Cipher exception: Set tag failed.

../../.virtualenvs/0/local/lib/python2.7/site-packages/petlib/cipher.py:385: Exception
bogdan-kulynych commented 6 years ago

That's a petlib issue that has been fixed in the latest version of claimchain-core.

azul commented 6 years ago

@bogdan-kulynych wow... Thanks for the hint!

So what i need to do is update my virtualenv to use the latest claimchain-core i guess. Ah... we're useing @hpk42 / claimchain-core. That's behind the mainline i guess.

I will update the issue title to reflect that.

azul commented 6 years ago

claimchain/claimchain-core#6 fixed this. We need at least version 0.2.1 to include that fix.