Passkey.Net 1.0.0

dotnet add package Passkey.Net --version 1.0.0
                    
NuGet\Install-Package Passkey.Net -Version 1.0.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="Passkey.Net" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Passkey.Net" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Passkey.Net" />
                    
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 Passkey.Net --version 1.0.0
                    
#r "nuget: Passkey.Net, 1.0.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 Passkey.Net@1.0.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=Passkey.Net&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Passkey.Net&version=1.0.0
                    
Install as a Cake Tool

Passkey.Net

.NET and .NET Framework library for FIDO2 passkey creation and authentication.

Built on top of Ctap.Net for secure USB/NFC authenticator communication.

Perfect for passwordless auth flows in any .NET app integrating passkeys.

Provides Security Key controlling functions like PIN setting and PIN changing.

Installation

Install via NuGet:

dotnet add package Passkey.Net

Or in your .csproj:

<PackageReference Include="Passkey.Net" Version="1.0.0" />

The latest version: https://www.nuget.org/packages/Passkey.Net/1.0.0

How to use

You simply need to look for a FIDO security key device, choose one and create an object of Passkey class using the found device. Then call the passkey related functions for that device.


foreach (var device in FidoSecurityKeyDevices.AllDevices)
{
    using (var passkey = new Passkey(device, UserActionCallback)) // Make sure the passkey object is disposed when finished
    {
        var registrationResponse = passkey.Create(new JObject()
        {
            ["challenge"] = "pgIfj2fnom8rJdb4_h1gKqDkq-gxHFksI-m2aR5T-PNNycBfENAM4ksEBvoXky6d",
            ["rp"] = new JObject()
            {
                ["id"] = "login.microsoft.com",
                ["name"] = "Microsoft"
            },
            ["user"] = new JObject()
            {
                ["id"] = "T0Y6Ehqp2EfQP0iExdt54DFwdWuaH7qIZbZGpOc92RGnvbXyRPvU-8AOp9r1T7Cebfc3",
                ["name"] = "user@domain.com",
                ["displayName"] = "Vahidreza Arian"
            },
            ["pubKeyCredParams"] = new JArray()
            {
                new JObject()
                {
                    ["type"] = "public-key",
                    ["alg"] = -7
                },
                new JObject()
                {
                    ["type"] = "public-key",
                    ["alg"] = -256
                }
            },
            ["extensions"] = new JObject()
            {
                ["hmacCreateSecret"] = true,
                ["enforceCredentialProtectionPolicy"] = true
            }
        }, UserVerification.Preferred, UserPresence.Required);

        var authenticationResponse = passkey.Authenticate(new JObject()
        {
            ["challenge"] = "pgIfj2fnom8rJdb4_h1gKqDkq-gxHFksI-m2aR5T-PNNycBfENAM4ksEBvoXky6d",
            ["rpId"] = "login.microsoft.com",
            ["extensions"] = new JObject()
            {
                ["hmacGetSecret"] = new JObject()
                {
                    ["salt1"] = "qB3fJ9tL2kP8mR5vN0wY4hC7eD1gK6sU9xZ2nM3rT5pQ8vF0jA"
                }
            }
        }, UserVerification.Required, UserPresence.Required);
    }
}

// This callback makes the library handle the GetPin and SetPin functions along with notifying you of user actio requirement
// You can handle this callback and implement a UI
UserActionCallbackResult UserActionCallback(UserActionCallbackArgs args)
{
    if (args.Action == UserActionCallbackActions.TouchSecurityKey)
    {
        Console.WriteLine("Touch your security key");
        return null;
    }
    else if (args.Action == UserActionCallbackActions.GetPin)
    {
        Console.Write("Enter the Security Key PIN: ");
    }
    else if (args.Action == UserActionCallbackActions.GetPinWithWrongPinMessage)
    {
        Console.WriteLine("Security key pin was wrong!");
        Console.Write("Enter the Security Key PIN: ");
    }
    else if (args.Action == UserActionCallbackActions.SetPin)
    {
        Console.Write("Please set a pin first\n");
        Console.Write("Enter the Security Key PIN: ");
    }

    var pin = new StringBuilder();
    ConsoleKeyInfo key;
    do
    {
        key = Console.ReadKey(true);
        if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
        {
            pin.Append(key.KeyChar);
            Console.Write("*");
        }
        else if (key.Key == ConsoleKey.Backspace && pin.Length > 0)
        {
            pin.Remove(pin.Length - 1, 1);
            Console.Write("\b \b");
        }
    } while (key.Key != ConsoleKey.Enter);
    Console.WriteLine();

    return new UserActionCallbackResult(pin.ToString());
}
Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed.  net10.0-windows7.0 is compatible. 
.NET Framework net472 is compatible.  net48 was computed.  net481 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
1.0.0 44 2/16/2026

Initial release of a class library which provides passkey creation and authentication.