Proof of concept for running the Dining Philosophers algorithm using a pubsub backend. To run: run the waiter (waiter.py) with the expected number of diners run each diner (diner.py), selecting either one or none of them to be the payer (-p) For pubnub, a config file, pubnub_keys.cfg, is required in the src folder, with the following format: [pubnub] publish: <publish key> subscribe: <subscribe key> secret: <secret key> Each diner will establish a shared secret with each other diner. After that, they each determine whether the NSA paid or one of the diners paid. The waiter exists for diner discovery and coordination but otherwise does not assist the process. It could be replaced with other, out of band config and coordination. The code suffers all of the drawbacks of the original algorithm, most notably collisions. If an even number of diners indicate that they paid, the wrong answer will be computed. In addition, it is assumed that diners are obeying the protocol as well as not eavesdropping on channels they don't belong to. A minimum of three diners is required. To run firebase implementation: requests module is required to be installed (pip install requests) config required: firebase.cfg file, alongside the firebase.py file, with the following format: [firebase] root: <your firebase root> Currently hardcoded to 3 diners. Will be updating this in the future. To run the waiter: ./firebase.py To run a diner: ./firebase.py -d [-p] # include the -p as well if this diner is paying So, run the waiter and then 3 diners once the waiter indicates that it is ready
gsoltis/DiningCryptographers
Proof of concept of dining philosophers algorithm using a pubsub backend
Python