Created
May 1, 2019 19:54
-
-
Save kevinkub/2bd60161bd0757bd508a177818ccdc5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from axolotl.tests.inmemoryaxolotlstore import InMemoryAxolotlStore, InMemoryIdentityKeyStore, InMemoryPreKeyStore, InMemorySessionStore, InMemorySignedPreKeyStore | |
from axolotl.sessioncipher import SessionCipher | |
from axolotl.util.keyhelper import KeyHelper | |
class Entity: | |
def __init__(self): | |
self.__sessionStore = InMemorySessionStore() | |
self.__preKeyStore = InMemoryPreKeyStore() | |
self.__signedPreKeyStore = InMemorySignedPreKeyStore() | |
self.__identityStore = InMemoryIdentityKeyStore() | |
self.__identityKeyPair = KeyHelper.generateIdentityKeyPair() | |
def channel_to(self, recepient): | |
return SessionCipher(self.__sessionStore, self.__preKeyStore, self.__signedPreKeyStore, self.__identityStore, recepient, 1) | |
a = Entity() | |
b = Entity() | |
c = Entity() | |
keyExAtoB = a.channel_to("b").sessionBuilder.processInitKeyExchangeMessage() | |
keyExBtoA = b.channel_to("a").sessionBuilder.processKeyExchangeMessage(keyExAtoB) | |
a.channel_to("b").sessionBuilder.processKeyExchangeMessage(keyExBtoA) | |
keyExAtoC = a.channel_to("c").sessionBuilder.processInitKeyExchangeMessage() | |
keyExCtoA = c.channel_to("a").sessionBuilder.processKeyExchangeMessage(keyExAtoC) | |
a.channel_to("c").sessionBuilder.processKeyExchangeMessage(keyExCtoA) | |
msg1 = a.channel_to("b").encrypt("Hello World 1") | |
msg1 = b.channel_to("a").decryptMsg(msg1) | |
msg2 = b.channel_to("a").encrypt("Hello World 2") | |
msg2 = a.channel_to("b").decryptMsg(msg2) | |
msg3 = a.channel_to("c").encrypt("Hello World 3") | |
msg3 = c.channel_to("a").decryptMsg(msg3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment