Name of the signature algorithm. It is a human readable equivalent of
the signatureCode, however it is also used as last segment in
Nonstandard Signatures, which is used as an alg
field of JWT header
when UCANs are serialized to JWT.
Integer corresponding to the byteprefix of the Crypto.SigAlg. It is used to tag signature so it can self describe what algorithm was used.
The signer
field is a self reference (usually a getter). It's sole
purpose is to allow splitting signer and verifier through destructuring.
import * as Principal from "@ucanto/principal"
const { signer, verifier } = Principal.from(archive)
The verifier
field just like the signer
exists to allow splitting
them apart through destructuring.
Source data before it was byte encoding into payload.
Takes byte encoded payload and produces a verifiable signature.
Returns archive of this signer which will have keys byte encoded when underlying keys are extractable or in CryptoKey form otherwise.
This allows a storing non extractable archives into indexedDB and storing extractable archives on disk ofter serializing them using IPLD code.
This aligns with a best practice that in browsers inextricable keys should be used and extractable keys in node.
import * as CBOR from '@ipld/dag-cbor'
const save = async (signer: Signer) => {
const archive = signer.toArchive()
if (globalThis.indexedDB) {
await IDB_OBJECT_STORE.add(archive)
} else {
await fs.writeFile(KEY_PATH, CBOR.encode(archive))
}
}
Wraps key of this signer into a signer with a different DID. This is primarily used to wrap SignerKey into a Signer that has did of different method.
import { ed25519 } from "@ucanto/principal"
const demo = async () => {
const key = await ed25519.generate()
key.did() // 'did:key:z6Mkqa4oY9Z5Pf5tUcjLHLUsDjKwMC95HGXdE1j22jkbhz6r'
const gozala = key.withDID('did:web:gozala.io')
gozala.did() // 'did:web:gozala.io'
}
Generated using TypeDoc
Signer corresponding to
did:key
identified principal.