Skip to content
Wallet and Entity Collection draft updates
Documentation menu

9.4. Choose crypto and signing custody

Feature guides / 9. Updates, rollover, and revocation

An entity needs public cryptographic operations and a stable signing identity. The host application supplies both through crypto: { engine, keyring }. It can use software keys, an operating-system keystore, or a remote signing service.

CryptoEngine performs verification, public-key validation, hashing and secure randomness. A Signer holds one immutable private-key binding. Keyring.entry(purpose, context?) returns that binding and its published public keys together. These contracts live in @oidfed/crypto; core supplies JWT profiles and Federation rules.

Configure software custody

Load a private signing JWK with a kid and an alg supported by SoftwareSigner.

import { MemoryRotatingKeyring } from "@oidfed/crypto";
import { createWebCryptoEngine, SoftwareSigner } from "@oidfed/crypto/web";
import { TrustAnchor } from "@oidfed/authority";
import { historicalKeysFromKeyring, MemoryFederationStorage } from "@oidfed/core";

export async function createEduGain(privateKey: ConstructorParameters<typeof SoftwareSigner>[0]) {
  const engine = createWebCryptoEngine();
  const keyring = new MemoryRotatingKeyring({ federation: new SoftwareSigner(privateKey) });
  const eduGain = await TrustAnchor.create({
    entityId: "https://edugain.example",
    crypto: { engine, keyring, history: historicalKeysFromKeyring(keyring) },
    storage: new MemoryFederationStorage({ namespace: "https://edugain.example" }),
    metadata: { federation_entity: {
      federation_fetch_endpoint: "https://edugain.example/fetch",
      federation_list_endpoint: "https://edugain.example/list",
      federation_historical_keys_endpoint: "https://edugain.example/history",
    } },
  });
  return { eduGain, keyring };
}

SoftwareSigner uses the private parameters to sign and exposes its public JWK for publication. Opaque host signers implement Signer directly and need no exportable private key. React Native applications use the same contracts with their chosen native implementation; the library needs no React Native adapter or Credo dependency.

Keep publication and signing together

Build an Entity Configuration from entry.publishedJwks and sign with that entry. The host factories follow this rule. A signer must keep using its captured private-key handle after rotation; resolving a mutable “current key” alias inside sign() breaks the contract.

The public Federation set requires distinct, nonempty identifiers and valid public material. Core's preparePublicJwkSet returns a detached JSON snapshot, rejects private material, and preserves public extensions. Backend key import establishes mathematical usability separately. Received protocol sets retain their protocol-specific rules for missing or duplicate identifiers.

Keep key history factual

A basic keyring is enough for signing. Configure crypto.history when an authority advertises the historical-keys endpoint. historicalKeysFromKeyring converts withdrawn records: exp is the earlier recorded retirement or revocation, and revocation details are retained. It does not derive key issuance or validity-start times from activation or publication. Supply a custom history source when those additional facts are known.

Persist private custody and lifecycle state, coordinate replicas, and choose propagation and overlap intervals. The memory keyring is process-local. Revocation affects future selection and publication; existing snapshots retain their callbacks, and the host controls backend revocation and compromise response. Remote cached evidence remains subject to the federation's revocation policy.

See Federation key management, historical keys, and the migration guide.

Next: 9.5. Publish, propagate, and switch federation keys

View source on GitHub