One more test for Mac
MODIFY
WalletWasabi.Tests/UnitTests/Crypto/MacTests.cs
WalletWasabi.Tests/UnitTests/Crypto/MacTests.cs
@@ -37,5 +37,29 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
Assert.True(mac.VerifyMAC(sk, attribute));
}
+
+ [Fact]
+ [Trait("UnitTest", "UnitTest")]
+ public void CanDetectInvalidMAC()
+ {
+ var rnd = new SecureRandom();
+ var sk = new CoordinatorSecretKey(rnd);
+
+ var attribute = rnd.GetScalar() * Generators.G; // any random point
+ var differentAttribute = rnd.GetScalar() * Generators.G; // any other random point
+ var t = rnd.GetScalar();
+
+ // Create MAC for realAttribute and verify with fake/wrong attribute
+ var mac = MAC.ComputeMAC(sk, attribute, t);
+ Assert.False(mac.VerifyMAC(sk, differentAttribute));
+
+ var differentT = rnd.GetScalar();
+ var differentMac = MAC.ComputeMAC(sk, attribute, differentT);
+ Assert.NotEqual(mac, differentMac);
+
+ mac = MAC.ComputeMAC(sk, attribute, differentT);
+ var differentSk = new CoordinatorSecretKey(rnd);
+ Assert.False(mac.VerifyMAC(differentSk, attribute));
+ }
}
}
\ No newline at end of file

One more test for Mac