NBitcoin Nugetパッケージを使用しています。私はプライベートとパブのキー(アドレス)を作成しようとします。その後、私は何らかのメッセージに署名して、この署名をパブキーで検証しようとします。しかし、NBitcoinは、秘密鍵オブジェクトを持つBitcoinSecretオブジェクトを使って検証します。だから、なぜこのオブジェクトを使ってNBitcoinを検証するのでしょうか?また、アドレス(pubKey)、署名、メッセージを使用して、秘密鍵なしで署名を検証する方法はありますか? おかげ秘密キーなしで確認する方法(NBitcoin)
static void Main(string[] args)
{
Key Key = new Key(); //Create private key
//We can take private key
var privateKey = Key.GetBitcoinSecret(Network.Main);
//Get the public key, and derive the address on the Main network
BitcoinAddress address = privateKey.PubKey.GetAddress(Network.Main);
For the sign to data , create secret object.
BitcoinSecret secret = new BitcoinSecret(Key, Network.Main);
string message = $"I am Nicolas";
Console.WriteLine("Message:" + message + "\n");
sign message with private key.
string signature = secret.PrivateKey.SignMessage(message);
Console.WriteLine("Signature:" + signature + "\n");
/* Now I dont understand this code. For the verify , I know that we need
to signature message , message and pub or adres value.\n But in this code using
again private secret object which has got private key. How we can verify
signature messaga with pub or address and message (dont include private key)*/
if (secret.PubKey.VerifyMessage(message, signature))
{
Console.WriteLine("thats okey");
}
Console.Read();
}