MetacoSA / NBitcoin

Comprehensive Bitcoin library for the .NET framework.
MIT License
1.85k stars 839 forks source link

VerifyMessage does not exist #1172

Open robotlovecoffee opened 1 year ago

robotlovecoffee commented 1 year ago

I'm trying to do a simple verification of an address and the samples provide code that will not compile.

'BitcoinPubKeyAddress' does not contain a definition for 'VerifyMessage' and no accessible extension method 'VerifyMessage' accepting a first argument of type 'BitcoinPubKeyAddress' could be found (are you missing a using directive or an assembly reference?) [NBitcoinTraining]

I just want to provide a message, have the user sign and return back to the program and then verify that it is correct.

TylerOlsen commented 1 year ago

It seems this method was removed starting with version 7 - I too was wondering how to validate a signature via NBitcoin, specifically from a segwit bech32 address - does the library currently not support this? If not, can anyone recommend any alternatives?

Been working on something custom in the meantime, but it's been tough (new to bc and crypto in general)

knocte commented 1 year ago

You could fork the repo and go back to version previous to 7?

Cadey commented 11 months ago

@TylerOlsen Did you get an alternative for this. I just had the same issue

TylerOlsen commented 11 months ago

@Cadey I did find an alternative, I specifically needed to verify BIP322 messages signed with a taproot address (for ordinals) so this may not be applicable to you, but I just cloned the branch of btc-core that supported this (https://github.com/bitcoin/bitcoin/pull/24058) and verified messages via RPC - problem solved!

I highly recommend doing something similar, because I spent too much time trying to build my own implementation that just wouldn't work 😂 the above should only take an hour of work and a few hours of downloading for a pruned node.

Good luck!

Cadey commented 11 months ago

Your uses case is exactly the same as mine :) Need to validate messages signed with a taproot address :)

Cadey commented 11 months ago

@TylerOlsen sorry to bother you again, I did try to validate the message with a node but it keeps rejecting it.

Ive tried making sure the "Magicbytes" are included in the message which did catch me out at first, but its like the verifyMessage function doesn't support taproot addresses or something.....

Cadey commented 11 months ago

Ohhhh sorry, I see what you did. You compiled a node from that branch.... sorry, didnt read what you said properly