public void Can_do_roundtrip() { PrivateKey privateKey = new PrivateKey(NetTestVectors.StaticKeyA.Hex); byte[] plainText = { 1, 2, 3, 4, 5 }; _cryptoRandom.EnqueueRandomBytes("0x0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a"); _cryptoRandom.EnqueueRandomBytes(NetTestVectors.EphemeralKeyA.Hex); byte[] cipherText = _eciesCipher.Encrypt(privateKey.PublicKey, plainText, null); // public(65) | IV(16) | cipher(...) byte[] deciphered = _eciesCipher.Decrypt(privateKey, cipherText); Assert.AreEqual(plainText, deciphered); }
private void InitializeRandom(bool preEip8Format = false) { // WARN: order reflects the internal implementation of the service (tests may fail after any refactoring) if (preEip8Format) { _testRandom.EnqueueRandomBytes(NetTestVectors.NonceA, NetTestVectors.EphemeralKeyA.KeyBytes, NetTestVectors.NonceB, NetTestVectors.EphemeralKeyB.KeyBytes); } else { _testRandom.EnqueueRandomBytes(NetTestVectors.NonceA, NetTestVectors.EphemeralKeyA.KeyBytes, _trueCryptoRandom.GenerateRandomBytes(100), NetTestVectors.NonceB, NetTestVectors.EphemeralKeyB.KeyBytes, _trueCryptoRandom.GenerateRandomBytes(100)); } }