Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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