Skip to main content

PublicKey

Namespace: Wisej.Ext.WebAuthn

Assembly: Wisej.Ext.WebAuthn (4.1.0.0)

Represents information about a public key retrieved from the client.

public class PublicKey

Constructors​

Instance member PublicKey()​

Creates a new instance of PublicKey.

Example:

var publicKey = new PublicKey
{
CredentialID = storedCredentialID,
Data = storedKeyData
};

Instance member PublicKey(credentialID, data)​

Creates a new instance of PublicKey with the given configuration.

NameTypeDescription
credentialIDStringThe base64 credential ID received upon registration.
dataObjectThe dynamic COSE public key object received upon registration.

Example:

CredentialsResponse response = await WebAuthn.CreateAsync(
challenge, rp, user, parameters, selection, 60000, AttestationConveyancePreference.None);

PublicKey registered = response.AuthenticatorData.PublicKey;
var copy = new PublicKey(registered.CredentialID, registered.Data);

Instance member PublicKey(json)​

Creates a new instance of PublicKey with the given JSON configuration.

NameTypeDescription
jsonStringThe serialized JSON string of the PublicKey object.

The JSON must contain the CredentialID and Data members. Use this overload to restore a public key saved in a database after registration.

Example:

// Restore the public key saved when the user registered.
string json = LoadPublicKeyJson(userId);
var publicKey = new PublicKey(json);

bool valid = WebAuthn.Validate(
publicKey,
response.AuthenticatorData.Base64,
response.ClientData.Base64,
response.Signature);

Properties​

Instance member Algorithm​

COSEAlgorithmIdentifier: The public key algorithm used.

Instance member CredentialID​

String: The credential ID returned from the client.

Instance member Data​

Object: The public key data returned from the client.