public SessionBuilder(IAxolotlStore store, AxolotlAddress remoteAddress) : this(store, store, store, store, remoteAddress) { }
private void RunInteraction(IAxolotlStore aliceStore, IAxolotlStore bobStore) { SessionCipher aliceSessionCipher = new SessionCipher(aliceStore, BOB_ADDRESS); SessionCipher bobSessionCipher = new SessionCipher(bobStore, ALICE_ADDRESS); String originalMessage = "smert ze smert"; CiphertextMessage aliceMessage = aliceSessionCipher.Encrypt (Encoding.UTF8.GetBytes (originalMessage)); Assert.True(aliceMessage.GetKeyType() == CiphertextMessage.WHISPER_TYPE); byte[] plaintext = bobSessionCipher.Decrypt(new WhisperMessage(aliceMessage.Serialize())); Assert.True(new string(plaintext.Select(x => (char)x).ToArray()).Equals(originalMessage)); var bobMessage = bobSessionCipher.Encrypt (Encoding.UTF8.GetBytes (originalMessage)); Assert.True(bobMessage.GetKeyType() == CiphertextMessage.WHISPER_TYPE); plaintext = aliceSessionCipher.Decrypt(new WhisperMessage(bobMessage.Serialize())); Assert.True(new string(plaintext.Select(x => (char)x).ToArray()).Equals(originalMessage)); for (int i=0;i<10;i++) { String loopingMessage = ("What do we mean by saying that existence precedes essence? " + "We mean that man first of all exists, encounters himself, " + "surges up in the world--and defines himself aftward. " + i); var aliceLoopingMessage = aliceSessionCipher.Encrypt (Encoding.UTF8.GetBytes (loopingMessage)); byte[] loopingPlaintext = bobSessionCipher.Decrypt(new WhisperMessage(aliceLoopingMessage.Serialize())); Assert.True (new String (loopingPlaintext.Select(x => (char)x).ToArray()).Equals (Encoding.UTF8.GetBytes (loopingMessage))); } for (int i = 0; i < 10; i++) { String loopingMessage = ("What do we mean by saying that existence precedes essence? " + "We mean that man first of all exists, encounters himself, " + "surges up in the world--and defines himself aftward. " + i); var bobLoopingMessage = bobSessionCipher.Encrypt (Encoding.UTF8.GetBytes (loopingMessage)); byte[] loopingPlaintext = aliceSessionCipher.Decrypt(new WhisperMessage(bobLoopingMessage.Serialize())); Assert.True (new String (loopingPlaintext.Select(x => (char)x).ToArray()).Equals (Encoding.UTF8.GetBytes (loopingMessage))); } var aliceOutOfOrderMessages = new HashSet<Tuple<String, CiphertextMessage>>(); for (int i = 0; i < 10; i++) { string loopingMessage = ("What do we mean by saying that existence precedes essence? " + "We mean that man first of all exists, encounters himself, " + "surges up in the world--and defines himself aftward. " + i); var aliceLoopingMessage = aliceSessionCipher.Encrypt (Encoding.UTF8.GetBytes (loopingMessage)); aliceOutOfOrderMessages.Add(new Tuple<string, CiphertextMessage>(loopingMessage, aliceLoopingMessage)); } for (int i = 0; i < 10; i++) { string loopingMessage = ("What do we mean by saying that existence precedes essence? " + "We mean that man first of all exists, encounters himself, " + "surges up in the world--and defines himself aftward. " + i); var aliceLoopingMessage = aliceSessionCipher.Encrypt (Encoding.UTF8.GetBytes (loopingMessage)); byte[] loopingPlaintext = bobSessionCipher.Decrypt(new WhisperMessage(aliceLoopingMessage.Serialize())); Assert.True (new string (loopingPlaintext.Select(x => (char)x).ToArray()).Equals (Encoding.UTF8.GetBytes (loopingMessage))); } for (int i=0;i<10;i++) { String loopingMessage = ("You can only desire based on what you know: " + i); CiphertextMessage bobLoopingMessage = bobSessionCipher.Encrypt (Encoding.UTF8.GetBytes (loopingMessage)); byte[] loopingPlaintext = aliceSessionCipher.Decrypt(new WhisperMessage(bobLoopingMessage.Serialize())); Assert.True (new string (loopingPlaintext.Select(x => (char)x).ToArray()).Equals (Encoding.UTF8.GetBytes (loopingMessage))); } foreach (var aliceOutOfOrderMessage in aliceOutOfOrderMessages) { byte[] outOfOrderPlaintext = bobSessionCipher.Decrypt(new WhisperMessage(aliceOutOfOrderMessage.Item2.Serialize())); Assert.True(new string(outOfOrderPlaintext.Select(x => (char)x).ToArray()).Equals(aliceOutOfOrderMessage.Item1)); } }