nethereum/nethereum/message-signing

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Sign and verify Ethereum messages with Nethereum. Use when the user wants to sign a message, verify a signature, recover a signer address, use personal_sign, or implement login-with-Ethereum style authentication.

Install

npx vskill@latest install nethereum/nethereum/message-signing

SKILL.md

Message Signing with Nethereum

NuGet: Nethereum.Signer

Source: PersonalSignDocExampleTests, SignerDocExampleTests

Required Usings

csharp
using Nethereum.Signer;
using Nethereum.Util;
using Nethereum.Hex.HexConvertors.Extensions;

Sign a UTF-8 Message and Recover Address

The most common pattern. Signs using the Ethereum personal_sign prefix (\x19Ethereum Signed Message:\n + length).

csharp
var signer = new EthereumMessageSigner();
var message = "Hello from Nethereum";
var signature = signer.EncodeUTF8AndSign(message, new EthECKey(privateKey));
var recoveredAddress = signer.EncodeUTF8AndEcRecover(message, signature);
// recoveredAddress matches the signer's public address

Sign Raw Bytes

Use when the payload is binary rather than a UTF-8 string.

csharp
var signer = new EthereumMessageSigner();
var data = new byte[] { 0x48, 0x65, 0x6c, 0x6c, 0x6f }; // "Hello"
var signature = signer.Sign(data, privateKey);
var recoveredAddress = signer.EcRecover(data, signature);
Assert.True(expectedAddress.IsTheSameAddress(recoveredAddress));

Verify External Wallet Signature (MetaMask, MEW)

Works with any wallet that implements personal_sign. Pass the original message and the hex signature.

csharp
var expectedAddress = "0xe651c5051ce42241765bbb24655a791ff0ec8d13";
var message = "wee test message 18/09/2017 02:55PM";
var signature = "0xf5ac62a395216a84bd595069f1bb79f1ee08a15f07bb9d9349b3b185e69b20c60061dbe5cdbe7b4ed8d8fea707972f03c21dda80d99efde3d96b42c91b2703211b";
var signer = new EthereumMessageSigner();
var recoveredAddress = signer.EncodeUTF8AndEcRecover(message, signature);
Assert.True(expectedAddress.IsTheSameAddress(recoveredAddress));

HashAndSign / HashAndEcRecover Shortcuts

Shorthand that hashes the message before signing. Useful when you want a deterministic hash-based signature without the personal_sign prefix.

csharp
var signer = new EthereumMessageSigner();
var message = "test";
var signature = signer.HashAndSign(message, privateKey);
var recovered = signer.HashAndEcRecover(message, signature);
Assert.True(expectedAddress.IsTheSameAddress(recovered));

Low-S Signature Verification (VerifyAllowingOnlyLowS)

EIP-2 requires the S value of ECDSA signatures to be in the lower half of the curve order. Use VerifyAllowingOnlyLowS for strict validation.

csharp
var ecKey = new EthECKey(privateKey);
var message = "test message";
var signer = new EthereumMessageSigner();
var signature = signer.EncodeUTF8AndSign(message, ecKey);
var prefixedHash = signer.HashPrefixedMessage(message);
var ethSignature = MessageSigner.ExtractEcdsaSignature(signature);
Assert.True(ecKey.VerifyAllowingOnlyLowS(prefixedHash, ethSignature));

EC Key Management

Generate a new key or reconstruct from a known private key.

csharp
// Generate a new random key
var ecKey = EthECKey.GenerateKey();
var privateKeyHex = ecKey.GetPrivateKey();
var publicKeyBytes = ecKey.GetPubKey();
var address = ecKey.GetPublicAddress();
// Reconstruct from existing private key
var reconstructed = new EthECKey(privateKeyHex);
Assert.Equal(address, reconstructed.GetPublicAddress());

Method Reference

MethodPurpose
EncodeUTF8AndSignSign UTF-8 string with personal_sign prefix
EncodeUTF8AndEcRecoverRecover address from UTF-8 signed message
Sign(byte[], key)Sign raw bytes with personal_sign prefix
EcRecover(byte[], sig)Recover address from raw byte signature
HashAndSignHash then sign (no personal prefix)
HashAndEcRecoverHash then recover (no personal prefix)
HashPrefixedMessageGet the prefixed hash without signing
ExtractEcdsaSignatureParse hex signature into ECDSA components
VerifyAllowingOnlyLowSStrict EIP-2 low-S verification

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/nethereum/nethereum/message-signing/badge)](https://verified-skill.com/skills/nethereum/nethereum/message-signing)

Something wrong with this skill or its page? Tell us.