예제 #1
0
        public void Bench(int max, int N)
        {
            var ctxt = Create(max, max, alice.PublicKey);

            System.Diagnostics.Trace.WriteLine("max: " + max);             //number of recipients
            //length of cyphertext, ratio of cyphertext to plaintext length
            System.Diagnostics.Trace.WriteLine("length " + ctxt.Length + " " + ctxt.Length / content.Length);
            var start = DateTime.Now;

            for (var i = 0; i < N; i++)
            {
                PrivateBox.Decrypt(ctxt, alice.PrivateKey, max);
            }
            var hit = DateTime.Now - start;

            System.Diagnostics.Trace.WriteLine("hit " + hit / N);             //ms to decrypt a message that was for us

            start = DateTime.Now;
            for (var i = 0; i < N; i++)
            {
                PrivateBox.Decrypt(ctxt, bob.PrivateKey, max);
            }
            var miss = DateTime.Now - start;

            System.Diagnostics.Trace.WriteLine("miss " + miss / N);             //ms to fail to decrypt a message not for us

            System.Diagnostics.Trace.WriteLine("ratio " + miss / hit);          //how much miss is bigger than hit.
        }
예제 #2
0
        public void TestSimple()
        {
            var msg = "hello there!";

            var pubKeys = new byte[][] { alice.PublicKey, bob.PublicKey };
            var prvKeys = new byte[][] { alice.PrivateKey, bob.PrivateKey };

            var ctxt = PrivateBox.Encrypt(msg, pubKeys);

            foreach (var sk in prvKeys)
            {
                var txt = System.Text.Encoding.UTF8.GetString(PrivateBox.Decrypt(ctxt, sk));

                Assert.AreNotSame(msg, txt);
            }
        }