Example #1
0
        public Plaintext Decrypt(PrivateKey d, Ciphertext c)
        {
            if (!(c is ElGamalCiphertext))
                throw new ArgumentException("Ciphertext must be ElGamalCiphertext!");

            var ciphertext = c as ElGamalCiphertext;

            var M = ciphertext.C2 - (ciphertext.C1 * d.Value);

            return _encoder.DecodeMessage(M);
        }
Example #2
0
 public void TestCiphertextCyclic()
 {
     var str = c.ToString();
     var c2 = new Ciphertext(str);
     Assert.AreEqual(c, c2);
 }
Example #3
0
 public void Setup()
 {
     c = new Ciphertext(new byte[] { 72, 69, 73, 76 });
 }