Nethereum.Signer.AzureKeyVault 5.8.0

Prefix Reserved
dotnet add package Nethereum.Signer.AzureKeyVault --version 5.8.0
                    
NuGet\Install-Package Nethereum.Signer.AzureKeyVault -Version 5.8.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nethereum.Signer.AzureKeyVault" Version="5.8.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nethereum.Signer.AzureKeyVault" Version="5.8.0" />
                    
Directory.Packages.props
<PackageReference Include="Nethereum.Signer.AzureKeyVault" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nethereum.Signer.AzureKeyVault --version 5.8.0
                    
#r "nuget: Nethereum.Signer.AzureKeyVault, 5.8.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nethereum.Signer.AzureKeyVault@5.8.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nethereum.Signer.AzureKeyVault&version=5.8.0
                    
Install as a Cake Addin
#tool nuget:?package=Nethereum.Signer.AzureKeyVault&version=5.8.0
                    
Install as a Cake Tool

Nethereum.Signer.AzureKeyVault

Azure Key Vault integration for Ethereum transaction signing with cloud-based Hardware Security Module (HSM) backed keys.

Overview

Nethereum.Signer.AzureKeyVault provides external signing capability for Ethereum transactions and messages using Azure Key Vault as a secure key management solution. Private keys are generated and stored in Azure's FIPS 140-2 Level 2 validated HSMs, and signing operations are performed remotely without exposing the private key.

Key Features:

  • Cloud-based HSM (Hardware Security Module) signing
  • Private keys never leave Azure Key Vault
  • FIPS 140-2 Level 2 (standard tier) or Level 3 (premium HSM tier) validated
  • Support for Legacy, EIP-1559, and EIP-7702 transactions
  • Message signing with secp256k1 (ES256K)
  • Azure Active Directory authentication (Managed Identity, Service Principal, etc.)
  • Scalable for enterprise and serverless architectures
  • Audit logging and access control via Azure RBAC

Use Cases:

  • Enterprise custody solutions
  • Serverless transaction signing (Azure Functions, App Service)
  • Multi-region hot wallet infrastructure
  • Regulatory compliance requiring HSM-backed keys
  • Secure key management without on-premises HSM hardware
  • API-based signing services

Installation

dotnet add package Nethereum.Signer.AzureKeyVault

Dependencies

External:

  • Azure.Security.KeyVault.Keys (v4.2.0) - Azure Key Vault SDK for key operations and cryptography

Nethereum:

  • Nethereum.Signer - Core signing infrastructure (provides EthExternalSignerBase)

Prerequisites

Azure Setup

  1. Create Azure Key Vault:

    az keyvault create --name my-ethereum-vault --resource-group my-rg --location eastus
    
  2. Create secp256k1 Key:

    az keyvault key create --vault-name my-ethereum-vault --name ethereum-key --kty EC --curve SECP256K1 --ops sign verify
    
  3. Configure Access Policy:

    # Grant your identity permission to sign
    az keyvault set-policy --name my-ethereum-vault --upn user@domain.com --key-permissions sign get
    
    # Or use Managed Identity for Azure resources
    az keyvault set-policy --name my-ethereum-vault --object-id <managed-identity-object-id> --key-permissions sign get
    

Authentication Options

  • DefaultAzureCredential - Auto-detects: Managed Identity, Azure CLI, VS Code, etc.
  • ManagedIdentityCredential - For Azure VMs, App Service, Functions
  • ClientSecretCredential - Service Principal with client secret
  • ClientCertificateCredential - Service Principal with certificate

Quick Start

using Nethereum.Signer.AzureKeyVault;
using Nethereum.Web3.Accounts;
using Azure.Identity;

// Authenticate to Azure (DefaultAzureCredential tries multiple methods)
var credential = new DefaultAzureCredential();

// Create external signer
var signer = new AzureKeyVaultExternalSigner(
    keyName: "ethereum-key",
    vaultUri: "https://my-ethereum-vault.vault.azure.net/",
    credential: credential
);

// Create external account
var account = new ExternalAccount(signer, chainId: 1);
await account.InitialiseAsync();

// Use with Web3
var web3 = new Web3.Web3(account, "https://mainnet.infura.io/v3/YOUR-PROJECT-ID");

Console.WriteLine($"Address: {account.Address}");

API Reference

AzureKeyVaultExternalSigner

External signer implementation for Azure Key Vault.

public class AzureKeyVaultExternalSigner : EthExternalSignerBase
{
    // Constructors
    public AzureKeyVaultExternalSigner(string keyName, string vaultUri, TokenCredential credential);
    public AzureKeyVaultExternalSigner(string keyName, KeyClient keyClient, TokenCredential credential);

    // Properties
    public CryptographyClient CryptoClient { get; }
    public KeyClient KeyClient { get; }
    public string KeyName { get; }
    public bool UseLegacyECDSA256 { get; set; } = true; // Use "ECDSA256" instead of "ES256K"
    public override bool CalculatesV { get; } = false;
    public override ExternalSignerTransactionFormat ExternalSignerTransactionFormat { get; } = ExternalSignerTransactionFormat.Hash;
    public override bool Supported1559 { get; } = true;

    // Methods
    protected override Task<byte[]> GetPublicKeyAsync();
    protected override Task<ECDSASignature> SignExternallyAsync(byte[] hash);
    public override Task SignAsync(LegacyTransaction transaction);
    public override Task SignAsync(LegacyTransactionChainId transaction);
    public override Task SignAsync(Transaction1559 transaction);
    public override Task SignAsync(Transaction7702 transaction);
}

Important Notes

Key Creation

# Standard tier (FIPS 140-2 Level 2)
az keyvault key create \
  --vault-name my-vault \
  --name ethereum-key \
  --kty EC \
  --curve SECP256K1 \
  --ops sign verify

# Premium tier (FIPS 140-2 Level 3 HSM)
az keyvault key create \
  --vault-name my-premium-vault \
  --name ethereum-hsm-key \
  --kty EC-HSM \
  --curve SECP256K1 \
  --ops sign verify

Important:

  • Use --curve SECP256K1 (Ethereum's curve)
  • Only sign and verify operations needed
  • HSM keys (EC-HSM) cannot be exported
  • Standard keys (EC) can be exported with proper permissions

Authentication Methods

Method Use Case Code
DefaultAzureCredential Development, auto-detect new DefaultAzureCredential()
ManagedIdentityCredential Azure services (Functions, App Service) new ManagedIdentityCredential()
ClientSecretCredential Service principal new ClientSecretCredential(tenant, client, secret)
ClientCertificateCredential Certificate auth new ClientCertificateCredential(tenant, client, cert)
AzureCliCredential Local development (az login) new AzureCliCredential()

Transaction Types Supported

Type Supported Notes
Legacy Yes EIP-155 with chain ID (no raw Legacy without chain ID)
EIP-1559 (Type 2) Yes MaxFeePerGas, MaxPriorityFeePerGas
EIP-2930 (Type 1) Yes Access lists
EIP-7702 (Type 4) Yes Account abstraction

Security Considerations

Private Key Security:

  • Private keys never leave Azure Key Vault
  • Signing operations performed server-side in Azure HSMs
  • Standard tier: FIPS 140-2 Level 2 validated
  • Premium tier: FIPS 140-2 Level 3 validated HSMs
  • HSM keys (EC-HSM) cannot be exported by anyone, including Microsoft

Access Control:

# Use Azure RBAC for fine-grained access control
az role assignment create \
  --role "Key Vault Crypto User" \
  --assignee <user-or-managed-identity> \
  --scope /subscriptions/<subscription-id>/resourceGroups/<rg>/providers/Microsoft.KeyVault/vaults/<vault-name>

# Or Key Vault Access Policies (legacy)
az keyvault set-policy \
  --name my-vault \
  --object-id <object-id> \
  --key-permissions sign get

Audit Logging:

  • Enable Azure Monitor for Key Vault
  • All signing operations logged
  • View in Azure Portal under "Monitoring" → "Logs"
  • Query: AzureDiagnostics | where ResourceProvider == "MICROSOFT.KEYVAULT"

Cost Considerations

Tier Cost per 10,000 operations Key Storage FIPS Level
Standard ~$0.03 $1/month per key Level 2
Premium HSM ~$1.00 $5/month per key Level 3

Optimization Tips:

  • Cache public key (doesn't change)
  • Use Managed Identity (no secrets management)
  • Consider rate limiting for high-volume scenarios
  • Monitor with Azure Application Insights

Error Handling

using Azure;

try
{
    var signature = await account.TransactionManager.SignTransactionAsync(transactionInput);
}
catch (RequestFailedException ex) when (ex.Status == 403)
{
    // Access denied - check Key Vault permissions
    Console.WriteLine($"Access denied: {ex.Message}");
}
catch (RequestFailedException ex) when (ex.Status == 404)
{
    // Key not found
    Console.WriteLine($"Key not found: {ex.Message}");
}
catch (RequestFailedException ex)
{
    // Other Azure errors
    Console.WriteLine($"Azure error: {ex.Status} - {ex.Message}");
}

Performance

  • Latency: ~100-300ms per signing operation (network + HSM)
  • Throughput: Thousands of operations per second per vault
  • Caching: Cache public key to avoid repeated Key Vault calls

Comparison with Other Solutions

Solution Security Cost Latency Use Case
Azure Key Vault HSM-backed Medium ~200ms Enterprise, cloud-native
Ledger/Trezor Hardware wallet Low User-dependent Development, manual signing
AWS KMS HSM-backed Medium ~200ms AWS-based infrastructure
HDWallet Software Free <1ms Development, non-production

Used By (Consumers)

  • Enterprise custody solutions
  • Serverless signing services
  • Multi-region hot wallet infrastructure
  • API-based signing platforms

Dependencies

  • Nethereum.Signer - Core signing
  • Azure.Security.KeyVault.Keys - Azure Key Vault SDK

Alternatives

  • Nethereum.Signer.AWSKeyManagement - AWS KMS integration
  • Nethereum.Signer.Ledger - Ledger hardware wallet
  • Nethereum.Signer.Trezor - TREZOR hardware wallet

Additional Resources

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.8.0 88 1/6/2026
5.0.0 347 5/28/2025
4.29.0 313 2/10/2025
4.28.0 1,720 1/7/2025
4.27.1 198 12/24/2024
4.27.0 197 12/24/2024
4.26.0 303 10/1/2024
4.25.0 212 9/19/2024
4.21.4 733 8/9/2024
4.21.3 237 7/22/2024
4.21.2 223 6/26/2024
4.21.1 211 6/26/2024
4.21.0 252 6/18/2024
4.20.0 297 3/28/2024
4.19.0 260 2/16/2024
4.18.0 1,876 11/21/2023
4.17.1 218 9/28/2023
4.17.0 201 9/27/2023
4.16.0 575 8/14/2023
4.15.2 3,109 7/11/2023
4.15.1 254 7/11/2023
4.15.0 259 7/11/2023
4.14.0 1,188 3/19/2023
4.13.0 428 2/18/2023
4.12.0 460 12/9/2022
4.11.0 643 10/27/2022
4.9.0 577 9/27/2022
4.8.0 566 8/24/2022
4.7.0 1,265 7/20/2022
4.6.1 585 6/18/2022
4.6.0 642 6/16/2022
4.5.0 1,319 5/13/2022
4.4.1 590 4/27/2022
4.4.0 611 4/27/2022
4.3.0 652 4/12/2022
4.2.0 748 2/18/2022
4.1.1 2,488 11/4/2021
4.1.0 565 10/15/2021
4.0.5 694 8/12/2021
4.0.4 505 8/10/2021
4.0.3 491 8/8/2021
4.0.2 529 8/5/2021
4.0.1 2,737 7/28/2021
4.0.0 717 7/26/2021
3.8.0 928 7/3/2020
3.7.1 1,537 2/13/2020
3.7.0 660 2/13/2020
3.6.0 813 1/27/2020
3.5.0 728 12/31/2019
3.4.0 858 7/29/2019
3.3.0 854 4/23/2019
3.2.0 835 4/8/2019
3.1.2 860 3/13/2019
3.1.1 770 3/12/2019
3.1.0 753 3/12/2019
3.0.0 1,989 11/28/2018
3.0.0-rc3 866 10/25/2018
3.0.0-rc2 721 10/24/2018