NBitcoin Nuget 패키지를 사용하고 있습니다. 개인 및 출판 키 (주소)를 만들려고합니다. 그리고 나서, 나는 어떤 메시지에 사인을 한 다음이 사인을 pub key로 확인하려고합니다. 그러나 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();
}