cryptography
Original:🇺🇸 English
Translated
Applies multi-algorithm cryptography (ED25519, P-256, RSA-4096) using Sorcha.Cryptography. Use when: implementing signing, verification, encryption, key generation, HD wallets, or address encoding.
1installs
Sourcestuartf303/sorcha
Added on
NPX Install
npx skill4agent add stuartf303/sorcha cryptographyTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Cryptography Skill
Sorcha.Cryptography provides multi-algorithm support (ED25519, P-256, RSA-4096), symmetric encryption (AES, ChaCha20), and BIP39/44 HD wallet derivation. All operations return for explicit error handling—no exceptions for crypto failures.
CryptoResult<T>Quick Start
Key Generation
csharp
// Inject ICryptoModule
var keySetResult = await _cryptoModule.GenerateKeySetAsync(WalletNetworks.ED25519);
if (!keySetResult.IsSuccess)
throw new InvalidOperationException($"Key generation failed: {keySetResult.Status}");
var keySet = keySetResult.Value!;
// keySet.PrivateKey.Key = 64 bytes (ED25519)
// keySet.PublicKey.Key = 32 bytes (ED25519)Signing & Verification
csharp
// Hash then sign
byte[] hash = SHA256.HashData(transactionData);
var signResult = await _cryptoModule.SignAsync(
hash,
(byte)WalletNetworks.ED25519,
keySet.PrivateKey.Key!);
// Verify
var status = await _cryptoModule.VerifyAsync(
signResult.Value!,
hash,
(byte)WalletNetworks.ED25519,
keySet.PublicKey.Key!);
bool isValid = status == CryptoStatus.Success;HD Wallet Creation
csharp
var keyRing = await _keyManager.CreateMasterKeyRingAsync(WalletNetworks.ED25519, password: null);
// keyRing.Mnemonic = "word1 word2 ... word12" — user must backup
// keyRing.MasterKeySet contains derived keysKey Concepts
| Concept | Usage | Example |
|---|---|---|
| Algorithm selection | |
| Error handling | |
| Public/private pair | |
| Full wallet with mnemonic | |
| Secure memory clearing | Call when done with keys |
Common Patterns
Platform-Specific Key Storage
csharp
// Encryption provider abstraction handles platform differences
var encrypted = await _encryptionProvider.EncryptAsync(privateKey, "wallet-key-id");
// Windows: DPAPI, Linux: Secret Service, Dev: AES-GCMAddress Generation
csharp
var address = _walletUtilities.PublicKeyToWallet(publicKey, (byte)WalletNetworks.ED25519);
// Returns: "ws1q8tuvvdykly8n0fy5jkuu8cjw0fu0p6jl5rp9g..."See Also
- patterns - Algorithm selection, signing workflows, key management
- workflows - Wallet creation, transaction signing, encryption
Related Skills
- See the nbitcoin skill for HD wallet derivation paths (BIP32/39/44)
- See the postgresql skill for encrypted key storage patterns
- See the xunit and fluent-assertions skills for testing crypto code
Documentation Resources
Fetch latest cryptography documentation with Context7.
How to use Context7:
- Use to search for "libsodium" or "System.Security.Cryptography"
mcp__context7__resolve-library-id - Query with using the resolved library ID
mcp__context7__query-docs
Recommended Queries:
- "ED25519 signing verification"
- "AES-GCM authenticated encryption"
- "BIP39 mnemonic seed derivation"