public void CryptoSignKeypair_Generation_Should_Success() { //Arrange Byte[] ssk = new Byte[TweetNaCl.SignSecretKeyBytes]; //Act Byte[] spk = TweetNaCl.CryptoSignKeypair(ssk); //Assert Assert.AreEqual(Encoding.ASCII.GetString(spk).Length, 32, "Public Key for message sign generation failed."); Assert.AreEqual(Encoding.ASCII.GetString(ssk).Length, 64, "Secret Key for message sign generation failed."); }
public void CryptoSign_Should_Success() { //Arrange String message = "test"; Byte[] bMessage = Encoding.UTF8.GetBytes(message); Byte[] ssk = new Byte[TweetNaCl.SignSecretKeyBytes]; Byte[] sMessage; //Act var spk = TweetNaCl.CryptoSignKeypair(ssk); sMessage = TweetNaCl.CryptoSign(bMessage, ssk); //Assert Assert.AreEqual(Encoding.ASCII.GetString(sMessage).Length, bMessage.Length + TweetNaCl.SignBytes, "Message sign failed."); }
public void CryptoSignOpen_Should_Success() { //Arrange String message = "test"; Byte[] bMessage = Encoding.UTF8.GetBytes(message); Byte[] ssk = new Byte[TweetNaCl.SignSecretKeyBytes]; Byte[] sMessage = new Byte[TweetNaCl.SignBytes + bMessage.Length]; Byte[] cMessage = new Byte[bMessage.Length]; var spk = TweetNaCl.CryptoSignKeypair(ssk); sMessage = TweetNaCl.CryptoSign(bMessage, ssk); //Act cMessage = TweetNaCl.CryptoSignOpen(sMessage, spk); Assert.AreEqual(cMessage.Length, bMessage.Length, "Message sign verification failed."); Assert.AreEqual(Encoding.UTF8.GetString(cMessage), message, "Messages sign verification failed."); }