Loading...
Loading...
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.
npx skill4agent add stuartf303/sorcha cryptographyCryptoResult<T>// 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)// 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;var keyRing = await _keyManager.CreateMasterKeyRingAsync(WalletNetworks.ED25519, password: null);
// keyRing.Mnemonic = "word1 word2 ... word12" — user must backup
// keyRing.MasterKeySet contains derived keys| Concept | Usage | Example |
|---|---|---|
| Algorithm selection | |
| Error handling | |
| Public/private pair | |
| Full wallet with mnemonic | |
| Secure memory clearing | Call when done with keys |
// Encryption provider abstraction handles platform differences
var encrypted = await _encryptionProvider.EncryptAsync(privateKey, "wallet-key-id");
// Windows: DPAPI, Linux: Secret Service, Dev: AES-GCMvar address = _walletUtilities.PublicKeyToWallet(publicKey, (byte)WalletNetworks.ED25519);
// Returns: "ws1q8tuvvdykly8n0fy5jkuu8cjw0fu0p6jl5rp9g..."Fetch latest cryptography documentation with Context7.
mcp__context7__resolve-library-idmcp__context7__query-docs