public void GMul128_IsCommutative(byte[] left, byte[] right) { // Act byte[] r1 = GaloisMultiplication.GMul128(left, right); byte[] r2 = GaloisMultiplication.GMul128(right, left); // Assert Assert.IsTrue(r1.Select((s, i) => new { value = s, index = i }).All(a => a.value == r2[a.index])); }
public void GMul128_IsDistributive(byte[] x, byte[] y, byte[] z) { // Act byte[] a1 = Add(x, y); byte[] r1 = GaloisMultiplication.GMul128(a1, z); byte[] m1 = GaloisMultiplication.GMul128(x, z); byte[] m2 = GaloisMultiplication.GMul128(y, z); byte[] r2 = Add(m1, m2); // Assert Assert.IsTrue(r1.Select((s, i) => new { value = s, index = i }).All(a => a.value == r2[a.index])); }
public void GMul128_SquaringFinitFieldSize_ShouldHaveStartResult(byte[] value) { // Arrange byte[] r = value; // Act for (int i = 0; i < 128; i++) { r = GaloisMultiplication.GMul128(r, r); } // Assert Assert.IsTrue(value.Select((s, i) => new { value = s, index = i }).All(a => a.value == r[a.index])); }