playcrypt.simulator package

Submodules

playcrypt.simulator.base_sim module

class playcrypt.simulator.base_sim.BaseSim(game, adversary)[source]

Bases: object

This is the base simulator class that all simulators inherit from. It has the base constructor which all simulators use.

playcrypt.simulator.bind_sim module

class playcrypt.simulator.bind_sim.BINDSim(game, adversary)[source]

Bases: playcrypt.simulator.base_sim.BaseSim

This simulator was written to be used with GameBIND. It simulates the game with an Adversary and allows you to compute an approximate advantage.

compute_advantage(trials=10)[source]

Adv = Pr[Bind => true]

Returns

Approximate advantage computed using the above equation.

compute_success_ratio(trials=1000)[source]

Runs the game trials times and computes the ratio of successful runs over total runs. This is fewer runs than usual because RSA math is expensive/slow.

Returns

successes / total_runs

run()[source]

Runs the game with the adversary provided to the constructor.

Returns

True for success and False for failure.

playcrypt.simulator.cca_sim module

class playcrypt.simulator.cca_sim.CCASim(game, adversary)[source]

Bases: playcrypt.simulator.base_sim.BaseSim

This simulator was written to be used with GameCCA. It simulates the game with an Adversary and allows you to compute an approximate advantage.

compute_advantage(trials)[source]

Adv = Pr[Right => 1] - Pr[Left => 1]

Returns

Approximate advantage computed using the above equation.

compute_success_ratio(b, trials=1000)[source]

Tries game in world and computes the ratio of success / total runs.

Parameters

world – Which world to compute for.

Returns

successes / total_runs

run(b)[source]

Runs the game in a specific world.

Parameters

world – 1 or 0, for different worlds.

Returns

True for success and False for failure.

playcrypt.simulator.cr_sim module

class playcrypt.simulator.cr_sim.CRSim(game, adversary)[source]

Bases: playcrypt.simulator.base_sim.BaseSim

compute_advantage(trials=1000)[source]

Adv = Pr[CR(H,A)->true]

Returns

Approximate advantage computed using the above equation.

compute_success_ratio(trials)[source]

Runs the game trials times and computes the ratio of successful runs over total runs.

Returns

successes / total_runs

run()[source]

Runs the game with the adversary provided to the constructor.

Returns

True for success and False for failure.

playcrypt.simulator.ctxt_sim module

class playcrypt.simulator.ctxt_sim.CTXTSim(game, adversary)[source]

Bases: playcrypt.simulator.base_sim.BaseSim

This simulator was written to be used with GameINTCTXT. It simulates the game with an Adversary and allows you to compute an approximate advantage.

compute_advantage(trials=1000)[source]

Adv = Pr[UFCMA => True]

Returns

Approximate advantage computed using the above equation.

compute_success_ratio(trials=1000)[source]

Runs the game trials times and computes the ratio of successful runs over total runs.

Returns

successes / total_runs

run()[source]

Runs the game with the adversary provided to the constructor.

Returns

True for success and False for failure.

playcrypt.simulator.kr_sim module

class playcrypt.simulator.kr_sim.KRSim(game, adversary)[source]

Bases: playcrypt.simulator.base_sim.BaseSim

This simulator was written to be used with GameKR. It simulates the game with an Adversary and allows you to compute an approximate advantage.

compute_advantage(trials=1000)[source]

Adv = Pr[KR => true]

Returns

Approximate advantage computed using the above equation.

compute_success_ratio(trials=1000)[source]

Runs the game 1000 times and computes the ratio of successful runs over total runs.

Returns

successes / total_runs

run()[source]

Runs the game with the adversary provided to the constructor.

Returns

True for success and False for failure.

playcrypt.simulator.lr_sim module

class playcrypt.simulator.lr_sim.LRSim(game, adversary)[source]

Bases: playcrypt.simulator.base_sim.BaseSim

This simulator was written to be used with GameLR. It simulates the game with an Adversary and allows you to compute an approximate advantage.

compute_advantage(trials=1000)[source]

Adv = Pr[Right => 1] - Pr[Left => 1]

Returns

Approximate advantage computed using the above equation.

compute_success_ratio(b, trials=1000)[source]

Tries game in world and computes the ratio of success / total runs.

Parameters

world – Which world to compute for.

Returns

successes / total_runs

run(b)[source]

Runs the game in a specific world.

Parameters

world – 1 or 0, for different worlds.

Returns

True for success and False for failure.

playcrypt.simulator.ufcma_sim module

class playcrypt.simulator.ufcma_sim.UFCMASim(game, adversary)[source]

Bases: playcrypt.simulator.base_sim.BaseSim

This simulator was written to be used with GameUFCMA. It simulates the game with an Adversary and allows you to compute an approximate advantage.

compute_advantage(n=1000)[source]

Adv = Pr[UFCMA => True]

Returns

Approximate advantage computed using the above equation.

compute_success_ratio(n=1000)[source]

Runs the game n times and computes the ratio of successful runs over total runs.

Returns

successes / total_runs

run()[source]

Runs the game with the adversary provided to the constructor.

Returns

1 for success and 0 for failure.

playcrypt.simulator.world_sim module

class playcrypt.simulator.world_sim.WorldSim(game, adversary)[source]

Bases: playcrypt.simulator.base_sim.BaseSim

This simulator was written to be used with GamePRF. It simulates the game with an Adversary and allows you to compute an approximate advantage.

compute_advantage(trials=1000)[source]

Adv = Pr[Real => 1] - Pr[Rand => 1]

Returns

Approximate advantage computed using the above equation.

compute_success_ratio(world, trials=1000)[source]

Tries game in world and computes the ratio of success / total runs.

Parameters

world – Which world to compute for.

Returns

successes / total_runs

run(world)[source]

Runs the game in a specific world.

Parameters

world – 1 or 0, for different worlds.

Returns

1 for success and 0 for failure.

Module contents