secret_vis_tree_test.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:PACE-python 作者: mit-ll 项目源码 文件源码
def test_encrypt_decrypt(self):
        '''
        Tests encrypting and decrypting the shares 
        '''
        DummyPKI = DummyEncryptionPKI()

        expressions = ['a&b',
                       'a&b&c',
                       'a|b',
                       'a|b|c',
                       '(a&b)|c',
                       '(a|b)&c',
                       'a|(b&c)',
                       'a&(b|c)',
                       '(a&b)|(b&c)',
                       '(a|b)&(c|d)']


        for e in expressions:
            secret = Random.get_random_bytes(16)
            encrypted_shares = SecretVisTreeEncryptor.encrypt_secret_shares(e,
                                                                            secret,
                                                                            Keytor('VIS_AES_CBC',DummyPKI,16),
                                                                            Pycrypto_AES_CBC)
            share = SecretVisTreeEncryptor.decrypt_secret_shares(e, 
                                                          encrypted_shares,
                                                          Keytor('VIS_AES_CBC',DummyPKI,16),
                                                          Pycrypto_AES_CBC)
            self.assertEqual(share, secret)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号