Exemplo n.º 1
0
    def test_load_save_client_data(self):
        oram = PathORAM.setup(os.path.join(self.tmpdir.name, "test"),
                              BLOCK_SIZE,
                              BLOCK_COUNT,
                              storage_type="file",
                              ignore_existing=True)
        data = b"hello world"
        data += b"\x00" * (oram.block_size - len(data))
        oram.write_block(0, bytes(data))
        oram.close()
        privatekv.utils.save_oram_client_data(oram, path=self.tmpdir.name)

        key, stash, pm = privatekv.utils.read_oram_client_data(
            "test", path=self.tmpdir.name)
        oram = PathORAM(os.path.join(self.tmpdir.name, "test"),
                        stash,
                        pm,
                        key=key,
                        storage_type="file")
        self.assertEqual(data, oram.read_block(0))
        oram.close()
            print("inserts %d / %d" % (i, inserts))

        keys_file = open("keys", "w")
        for key in list(keys):
            keys_file.write(key + "\n")
        keys_file.close()

        oram.close()
        privatekv.utils.save_oram_client_data(oram)

    else:
        key, stash, position_map = privatekv.utils.read_oram_client_data("test")
        oram = PathORAM("test", stash, position_map, key=key,
                        storage_type="s3", bucket_name=args.b, ignore_lock=True)
        kv = privatekv.store.KVORAM(oram)
   
        keys = set()

        keys_file = open("keys", "r")
        for key in keys_file.readlines():
            keys.add(key.rstrip())
        keys_file.close()
    
        for i in range(len(keys)):
            key = list(keys)[i]
            for j in range(i+1):
                val = kv.get(key)
                print("gets %d / %d" % (j, (i+1)))

        oram.close()