public void TestReedSolomonCode(int fieldPower, MatrixInt irreduciblePolynoimial, MatrixInt message, MatrixInt errorVector)
        {
            var galoisField     = new GaloisField(2, fieldPower, irreduciblePolynoimial);
            var generator       = new ParityCheckMatrixGeneratorGeneric();
            var reedSolomonCode = new ReedSolomonCode(galoisField, generator);

            var encodedMessage = reedSolomonCode.Encode(message, errorVector);

            var originalMessage = reedSolomonCode.DecodeAndCorrect(encodedMessage);

            Assert.True(message == originalMessage);
        }
Esempio n. 2
0
        public void TestMcElieceCryptosystem(MatrixInt message, MatrixInt errorVector, MatrixInt scrambler, IList <int> permutation, IList <int> mask)
        {
            var galoisField = new GaloisField(2, 3);

            var generator       = new ParityCheckMatrixGeneratorGeneric();
            var reedSolomonCode = new ReedSolomonCode(galoisField, generator);

            var mcElieseCryptosystem = new McEliece(reedSolomonCode, scrambler, permutation, mask);

            var encryptedMessage = mcElieseCryptosystem.EncryptMessage(mcElieseCryptosystem.PublicKey, message, errorVector);
            var originalMessage  = mcElieseCryptosystem.DecryptMessage(encryptedMessage);

            Assert.True(message == originalMessage);
        }