keystore

Encrypt and decrypt Ethereum private keys using Web3 Secret Storage keystore JSON files in .NET.

2.3k|744|Updated Nov 23, 2015
One-click install
npx skills add https://github.com/Nethereum/Nethereum --skill keystore
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: keystore
Source: https://github.com/Nethereum/Nethereum/tree/main/plugins/nethereum-skills/skills/keystore
Command: npx skills add https://github.com/Nethereum/Nethereum --skill keystore

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires Nethereum.KeyStore, Nethereum.Signer.

What problem does it solve?

Ethereum private keys stored in plaintext are a security risk. This Skill shows how to encrypt private keys into password-protected Web3 Secret Storage (keystore JSON) files and decrypt them back into usable accounts in C#/.NET applications.

Core Features & Use Cases

  • Scrypt Encryption: Generate keystore JSON files using the recommended Scrypt KDF, with support for custom parameters (e.g., light N=32 for WASM, mobile, or tests).
  • PBKDF2 Support: Encrypt with the legacy PBKDF2 KDF for compatibility with older keystore formats.
  • Auto-Detect Decryption: Decrypt any keystore JSON file with automatic KDF type detection (scrypt or pbkdf2) and load it into a Nethereum account.
  • Use Case: A wallet application needs to let users export password-protected backups of their keys. Use this Skill to generate a keystore JSON file with Scrypt encryption, then later decrypt it to restore the account for signing transactions.

Quick Start

Use the keystore skill to encrypt my Ethereum private key into a password-protected keystore JSON file with Scrypt and save it to disk.

Frequently Asked Questions about keystore

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I encrypt an Ethereum private key to a keystore JSON file in C#?▼

Use Nethereum.KeyStore's KeyStoreScryptService to call EncryptAndGenerateKeyStoreAsJson with a password, the private key bytes, and the address. The resulting JSON string can be written to a file as a standard Web3 Secret Storage keystore.

How to decrypt an Ethereum keystore file with a password in .NET?▼

Use KeyStoreService.DecryptKeyStoreFromJson with the password and the keystore JSON content. It auto-detects whether the file uses scrypt or pbkdf2, and the returned private key bytes can be loaded into a Nethereum Account.

Scrypt vs PBKDF2 for Ethereum keystore encryption, which should I use?▼

Scrypt is the recommended KDF for new keystore files via KeyStoreScryptService. PBKDF2 through KeyStorePbkdf2Service is considered legacy and should mainly be used for compatibility with older keystore files.

Can I use lighter Scrypt parameters for mobile or WebAssembly apps?▼

Yes, pass custom ScryptParams such as N=32, R=8, P=6 to EncryptAndGenerateKeyStoreAsJson for faster encryption in WASM, mobile, or test environments. Lower parameters reduce security margin, so use them only where performance constraints require it.

How do I detect whether a keystore file uses scrypt or pbkdf2?▼

Call KeyStoreKdfChecker.GetKdfType with the keystore JSON string. It returns "scrypt" or "pbkdf2", letting you pick the appropriate decryption service or confirm the file format before processing.