Ejemplo n.º 1
0
        public void MultiplicativeInverseShouldBeCalculationCorrect(byte number, MultiplicativeInverseCalculationWay way,
                                                                    byte expectedInverse)
        {
            //arrange
            var gfUnderTest = new GaloisField();

            //act
            var actualInverse = gfUnderTest.MultiplicativeInverse(number, way);

            //assert
            Assert.Equal(expectedInverse, actualInverse);
        }
Ejemplo n.º 2
0
        public byte MultiplicativeInverse(byte number, MultiplicativeInverseCalculationWay way)
        {
            if (number == 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            return(way switch
            {
                MultiplicativeInverseCalculationWay.ExtendedEuclideanAlgorithm => MultiplicativeInverseUsingExtendedGCD(
                    number),
                MultiplicativeInverseCalculationWay.Exponentiation => MultiplicativeInverseUsingExponentiation(number),
                _ => throw new ArgumentOutOfRangeException()
            });