Guides

Become an issuer

Make an issuer key, sign credentials Once accepts, and get the key into the registry.

An issuer checks people and signs their credentials. Once trusts an issuer once its BabyJubJub public key is active in the program's issuer registry; from then on, a person holding a credential it signed can enroll.

Make the key

The issuer signs with a 32-byte secret seed. Its public point, the issuer key, derived with circomlib-compatible BabyJubJub EdDSA over Poseidon, is what the registry holds and what the person's device checks the credential against. Keep the seed where your signing service can read it and nothing else can: anyone with it can sign credentials Once accepts as yours.

Sign a credential

The person's device sends you its holder public key along with the details you check. Once the check passes, sign the fields with issueCredential:

ts
import { randomBytes } from 'node:crypto'
import { credentialRoot, issueCredential, pointHex, publicKey, signatureHex, verifyCredential } from '@once/sdk'

// The issuer key: 32 secret bytes. Its public point is what the registry holds.
const seed = randomBytes(32)
console.log('issuer key', pointHex(publicKey(seed)))

// The person's device sends its holder public key; here a random one stands in.
const holder = publicKey(randomBytes(32))
const unix = (iso: string) => BigInt(Date.parse(iso) / 1000)

const vc = await issueCredential(seed, {
  subjectId: 'demo-0472',
  name: 'Alex Sample',
  dob: unix('1997-05-14T00:00:00Z'),
  placeOfBirth: 'Sample City',
  sex: 'unspecified',
  nationality: 'Sampleland',
  validFrom: unix('2015-05-14T00:00:00Z'),
  validUntil: unix('2027-11-26T00:00:00Z'),
  holder,
  issuerId: 'did:example:issuer',
  credentialType: 'OncePersonCredential',
})

console.log('verifies', verifyCredential(vc))
console.log('root', credentialRoot(vc.values).toString(16).padStart(64, '0'))
console.log('signature', signatureHex(vc.signature))
text
issuer key 043c5af9b8d11728fcaf606ab721162f37193e45f93df3d32d67d7b4dd06cb8a
verifies true
root 172e1a47d01cc446f30fdee160888aa57220b3cc3aadba58bf6a51fa336c3803
signature 0663c4a3f9ff1d7f42fe4f92098e650b76cf17e9aa0299a1d3762f2827adeba4cb8e272d897c0b25ded3863d90cd873e84ec082b43c59e21e9a476f8b1a39f04

issueCredential encodes the fields into the 16 values of Credentials and issuers, builds their root and signs it. Strings are hashed as given, byte for byte, so decide one canonical spelling and encoding for each field before you issue anything.

Keep a person the same person

The person secret comes from seven fields: subject ID, name, date of birth, place of birth, sex, nationality and validFrom. Change any byte of them and the same human becomes a new person to Once, with a new person nullifier and new scope nullifiers. So when you reissue to someone, after a renewal or to a new wallet's holder key:

  • Keep those seven fields exactly as they were, validFrom included. Set validFrom once per person and store it; the demo issuer anchors it to the person's 18th birthday so that it comes out the same on every issue.
  • Change validUntil and the holder key freely.
  • Issue only credentials that are already valid: validFrom at or before now.

validUntil decides how long the person can take part. Enrolling needs it in the future, and each claim needs it after the scope's closing time.

Hand it to the person

The app reads a credential in the W3C shape the demo issuer returns from POST /v1/issuer/credentials: the subject fields as the person entered them, issuer with your id and packed public key, validFrom and validUntil as ISO times, and proof with type BabyJubJubEdDSAPoseidon, the root and the signature as hex. pointHex and signatureHex give the packed forms. The full shape is under Credential in the API reference.

Get registered

The registry admin adds your public key with set_issuer. From then on:

  • The OPRF nodes answer requests whose authorize proof names your key.
  • enroll accepts credentials you signed.

The admin can retire the key with the same instruction, after which no new enrollment with your credentials is accepted. People already enrolled stay enrolled. Your key and its status are on chain at ["issuer", x, y], listed under Issuer.