def testBoxing(): msg = b'Hey there, a msg for you' # Generate the key pairs for Alice and bob, if secret keys already exist # they can be passed in, otherwise new keys will be automatically generated bob = SecretKey() alice = SecretKey() """ Alice: aA (a is alices private key, A is Alice's public key) A = G*a Bob: bB B = G*b hash(a*B) == hash(b*A) : hypothesis hash(a*G*b) == hash(b*G*a) : substitution hash(G*a*b) == hash(G*a*b) : commutative property of ECC math True! """ # Create the boxes, this is an object which represents the combination of the # sender's secret key and the receiver's public key bob_box = Box(bob.sk, alice.pk) alice_box = Box(alice.sk, bob.pk) # Bob's box encrypts messages for Alice bob_ctxt = bob_box.encrypt(msg) # Alice's box decrypts messages from Bob bclear = alice_box.decrypt(bob_ctxt) # Alice can send encrypted messages which only Bob can decrypt alice_ctxt = alice_box.encrypt(msg) aclear = bob_box.decrypt(alice_ctxt) print(bob.for_json()) print("bob's public key" + bob.hex_pk().hex()) print("bob's secret key" + bob.hex_sk().hex())