Example #1
0
import sm_py

if __name__ == '__main__':
    aliceKeys = sm_py.key_init()["keys"]
    bobKeys = sm_py.key_init()["keys"]
    secret = "test"
    step1 = sm_py.step_1(secret, aliceKeys)
    aliceKeys = step1["keys"]
    print(step1["message"])
    step2 = sm_py.step_2(step1["message"], bobKeys)
    bobKeys = step2["keys"]
    step3 = sm_py.step_3("test", bobKeys)
    bobKeys = step3["keys"]
    print(step3["message"])
    step4 = sm_py.step_4(step3["message"], aliceKeys)
    aliceKeys = step4["keys"]
    print(step4["message"])
    step5 = sm_py.step_5(step4["message"], bobKeys)
    bobKeys = step5["keys"]
    print(step5["success"])
    print(step5["message"])
    step6 = sm_py.step_6(step5["message"], aliceKeys)
    print(step6["success"])
Example #2
0
                                 "typeSMP": 5,
                                 "payload": step4["message"],
                             }
                         }
                         smParams = json.dumps(smPayload)
                         smReq = urllib2.Request(
                             smUrl, data=smParams, headers={"content-type": "application/json"}
                         )
                         try:
                             response = urllib2.urlopen(smReq)
                         except:
                             # print('Socialist millionaire protocol failed')
                             # print('after 4')
                             sys.exit()
                     elif step == 6:
                         step6 = sm_py.step_6(payload, smKeys)
                         if step6["success"] != 1:
                             # print('Socialist millionaire protocol failed')
                             # print('after 6')
                             sys.exit()
                         smWait = False
     except:
         print("Socialist millionaire protocol failed")
         # print('on receive')
         sys.exit()
     sleep(0.01)
 a.initState(
     OTHER_NICK,
     binascii.a2b_base64(obj["identity"].strip()),
     binascii.a2b_base64(obj["handshakekey"].strip()),
     binascii.a2b_base64(obj["ratchet"].strip()),