def A_2(fn): output1 = fn("\x00" * block_len) y1, y2 = split(output1) output2 = fn(y1) y3, y4 = split(output2) if (y2 == y3): return 1 #I think I'm in Real else: return 0 #I think I'm in Rand pass from crypto.games.game_prf import GamePRF from crypto.simulator.world_sim import WorldSim if __name__ == '__main__': g_1 = GamePRF(G1, key_len, block_len, 2 * block_len) s_1 = WorldSim(g_1, A_1) g_2 = GamePRF(G2, key_len, block_len, 2 * block_len) s_2 = WorldSim(g_2, A_2) print "The advantage of your adversary A_1 is ~" + \ str(s_1.compute_advantage()) print "The advantage of your adversary A_2 is ~" + \ str(s_2.compute_advantage())
""" for all 128-bit strings k, x. Show that F is not a secure PRF by presenting a practical adversary A such that Adv(prf, F, A) is close to one. Fill in the code for adversary A, verify it's advantage by running your code and describe the running time. """ def A(fn): """ You must fill in this method. This is the adversary that the problem is asking for. :param fn: This is the oracle supplied by GamePRF, you can call this oracle to get an "encryption" of the data you pass into it. :return: return 1 to indicate your adversary believes it is the real world and return 0 to indicate that your adversary believes it is in the random world. """ return None from crypto.games.game_prf import GamePRF from crypto.simulator.world_sim import WorldSim if __name__ == '__main__': g = GamePRF(F, 16, 32) s = WorldSim(g, A) print "The advantage of your adversary is ~" + str(s.compute_advantage())
def A_2(fn): """ You must fill in this method. :param fn: This is the oracle supplied by GamePRF, you can call this oracle to get an "encryption" of the data you pass into it. :return: return 1 to indicate your adversary believes it is the real world and return 0 to indicate that your adversary believes it is in the random world. """ pass from crypto.games.game_prf import GamePRF from crypto.simulator.world_sim import WorldSim if __name__ == '__main__': g_1 = GamePRF(G(1), key_len, 2*block_len) s_1 = WorldSim(g_1, A_1) g_2 = GamePRF(G(2), key_len, 2*block_len) s_2 = WorldSim(g_2, A_2) print "The advantage of your adversary A_1 is ~" + \ str(s_1.compute_advantage()) print "The advantage of your adversary A_2 is ~" + \ str(s_2.compute_advantage())
oracle. Fill in the code for adversary A, verify it's advantage by running your code and describe the running time. """ def A(fn): """ You must fill in this method. :param fn: This is the oracle supplied by GamePRF, you can call this oracle to get an "encryption" of the data you pass into it. :return: return 1 to indicate your adversary believes it is the real world and return 0 to indicate that your adversary believes it is in the random world. """ pass """ Formally prove that: 1. Your adversary has an advantage of 1 - 2^-128. ---&--- [Answer here]. """ from crypto.games.game_prf import GamePRF from crypto.simulator.world_sim import WorldSim if __name__ == '__main__': g = GamePRF(F, key_len, block_len) s = WorldSim(g, A) print "The advantage of your adversary is ~" + str(s.compute_advantage())