protected override void ValidateMessage(ChannelAnnouncementMessage message, byte[] rawData) { var witness = SHA256.ComputeHash(SHA256.ComputeHash(rawData.SubArray(258, rawData.Length - 258))); if (!Secp256K1.VerifySignature(witness, message.NodeSignature1, message.NodeId1)) { throw new MessageValidationException(message, "ChannelAnnouncementMessage: Invalid Signature (Node 1)", true); } if (!Secp256K1.VerifySignature(witness, message.NodeSignature2, message.NodeId2)) { throw new MessageValidationException(message, "ChannelAnnouncementMessage: Invalid Signature (Node 2)", true); } if (!Secp256K1.VerifySignature(witness, message.BitcoinSignature1, message.BitcoinKey1)) { throw new MessageValidationException(message, "ChannelAnnouncementMessage: Invalid Signature (Bitcoin Key 1)", true); } if (!Secp256K1.VerifySignature(witness, message.BitcoinSignature2, message.BitcoinKey2)) { throw new MessageValidationException(message, "ChannelAnnouncementMessage: Invalid Signature (Bitcoin Key 2)", true); } if (!message.ChainHash.SequenceEqual(_networkParameters.ChainHash)) { throw new MessageValidationException(message, "ChannelAnnouncementMessage: Invalid chain hash (ChannelAnnouncementMessage)"); } }
public void VerifyInvalidSignatureTest() { byte[] witness = "6b32bec9a3aeda57863bdc41d880f47944bf234a2628b084b46d4351d88195d2".HexToByteArray(); byte[] signature = "fe531b7551494341543459bce877275b7c4f2e7ad416279fc7aa732af90ccb9339fa3c2d59dd2c8b4cc68957d59bfc5186d164739a8b37d450ab1fcb50700322".HexToByteArray(); ECKeyPair publicKey = new ECKeyPair("03933884aaf1d6b108397e5efe5c86bcf2d8ca8d2f700eda99db9214fc2712b134", false); Assert.False(Secp256K1.VerifySignature(witness, signature, publicKey)); }
protected override void ValidateMessage(NodeAnnouncementMessage message, byte[] rawData) { var witness = SHA256.ComputeHash(SHA256.ComputeHash(rawData.SubArray(66, rawData.Length - 66))); if (!Secp256K1.VerifySignature(witness, message.Signature, message.NodeId)) { throw new MessageValidationException(message, "NodeAnnouncementMessage: Invalid Signature", true); } }