January 26, 2026

Capitalizations Index – B ∞/21M

用Nethereum來簽章 – My blockchain development Journey – Medium

用Nethereum來簽章 – My blockchain development Journey – Medium

以太坊私鑰可用於簽名消息。之後的消息可以由任何人驗證,因為地址
(或公鑰)是公開的,只要解密後取得地址與簽章的人的地址相同就可以確認由簽章人簽章的。
該過程依賴於橢圓曲線加密和恢復來自ECDSA簽名的公鑰。所以,為了驗證,我們需要提供消息(message),簽名(signature)和地址(address)。

自2017年8月起,Nethereum得到了Juan Blanco的支持。程序集名稱為Nethereum.Signer(可在NuGet上取的)。

建立專案

  1. 建立專案資料夾
>mkdir Signing

2. 使用 donet 指令來建立控制台應用程式 (console application)

Signing >  donet new console

3. Install Nethereum packages.

Signing > dotnet add package Nethereum.Signer

簽章

簽章時需要訊息與用戶私鑰

//signing
var message = "This is the message!";
var signer = new Nethereum.Signer.MessageSigner();
var signature = signer.HashAndSign(message, privateKey);
Console.WriteLine("signature: " ,signature);
// signature: 0xc98e7b9b26b9d066d48a8e4fb6fb09b40ca601061f3076067432368ef03e3bf453309bf62b32298f0eb4c85910e73a29f2bcb7e39f0c493d8adcd66486f4eefd1b

驗證

驗證部分需要消息,簽名和以後提供的地址。如果恢復的地址等於提供的地址,則驗證成功。通過這種方式,驗證顯示是否擁有提供地址的人擁有它的私鑰。

//verification
var address = signer.HashAndEcRecover(message, signature);
Console.WriteLine(address == providedAddress);
// result : True

完整的程式碼

using System;
using Nethereum.Signer;
using Nethereum.Signer.Crypto;
namespace Signing
" ,signature);
       //verification
var address = signer.HashAndEcRecover(message, signature);
Console.WriteLine("n result : " ,address == providedAddress);
     }
}
}

Source code : https://github.com/kennethhutw/NethereumMessageSigning

我這樣做是因為我愛它,但如果你想我喝杯咖啡,我不會拒絕。 :O ) Thanks ^^

donation :

XEM : NCWZSUF4FPXJY3L3Y7657QNVBIUZ5D54F4TNJ64S

Ether : 0xf2d15dEAf62b8c4AFC0343006579E8E662c120D9

Bitcoin : 332UiyAfSXyvhqCYgDgBkNLFSf25ccNV9i

*Do CLAP, COMMENT and SHARE! I also welcome any business opportunities that arises**

Connect:

LinkedIn

Telegram

Facebook

Published at Sun, 14 Apr 2019 05:03:35 +0000

Previous Article

Bitcoin Price (BTC) Uptrend Intact & Dips Remain Attractive To Buyers

Next Article

#BlockchainAfrica20 Blockchain Africa Conference 2020

You might be interested in …

CNBC, Jamie Dimon, Fake News and Bitcoin

Based upon the last 24 hours of activity online,  CNBC has been posting a sizable amount of fake news out into the msm  regarding bitcoin. Here are some  examples: https://www.cnbc.com/2017/09/14/bitcoin-is-dropping-right-now-after-a-big-chinese-exchange-said-it-is-closing.html Just wondering why they hate […]

Re: [ANN] [ICO] TaaS: Token-sebagai-Layanan | Pendanaan-tertutup

Re: [ANN] [ICO] TaaS: Token-sebagai-Layanan | Pendanaan-tertutup dari tread yang saya baca bagus bgt projek nya, bagus nya karena Projek ini menjanjikan listing di market terkenal sepeti Bitrex,Poloniex dan kraken jarang projek ICO yang menjanjikan […]