public void CorruptedUser() { Keys keys = Keys.Create(); ISignedDocument signedDocument = SignedDocument.Create(keys, DocumentConverter.STRING.Get("It's a test with a basic document.")); var corruptedDocument = new SignedDocument( document: signedDocument.Document, publicKey: Keys.Create().PublicKey, signature: signedDocument.Signature); Assert.IsTrue(signedDocument.Verify()); Assert.IsFalse(corruptedDocument.Verify()); }
public void CorruptedTransactions() { Keys user1keys = Keys.Create(); Keys user2Keys = Keys.Create(); ISignedDocument signedDocument = SignedDocument.Create(user1keys, DocumentConverter.STRING.Get("It's a test with a basic document.")); ISignedTransaction signedTransaction1 = signedDocument .ToSignedTransactionRoot() .Add(user1keys, DocumentConverter.STRING.Get("Updated.")); ISignedTransaction signedTransaction2 = signedTransaction1 .Add(user2Keys, DocumentConverter.STRING.Get("Add a signature to the document.")); ISignedTransaction corruptedTransaction = new SignedTransaction(signedTransaction1.PreviousSignedTransaction, DocumentConverter.STRING.Get("Replace with a corrupted document"), signedTransaction1.PublicKey, signedTransaction1.Signature); signedTransaction2 = new SignedTransaction(corruptedTransaction, signedTransaction2.Document, signedTransaction2.PublicKey, signedTransaction2.Signature); Assert.IsFalse(signedTransaction2.Verify()); }
public SignedTransactionRoot(ISignedDocument signedDocument) { _signedDocument = signedDocument ?? throw new ArgumentNullException(nameof(signedDocument)); }
public static ISignedTransaction ToSignedTransactionRoot(this ISignedDocument signedDocument) => new SignedTransactionRoot(signedDocument);