Class: CryptoApi ​
Defined in: packages/api/src/crypto.ts:442
Aggregated cryptographic operations sub-facade.
Provides direct access to the four sub-facades (keypair, multikey, cryptosuite, proof) plus top-level convenience methods that orchestrate the full signing/verification pipeline using their stateful defaults.
Example ​
const api = createApi();
const kp = api.crypto.keypair.generate();
const mk = api.crypto.multikey.create('#key-1', 'did:btcr2:test', kp);
// Set the active multikey — flows through to cryptosuite and proof
api.crypto.activate(mk);
// Now sign without threading instances
const signed = api.crypto.signDocument(unsignedDoc, proofConfig);Constructors ​
Constructor ​
new CryptoApi():
CryptoApi
Returns ​
CryptoApi
Properties ​
cryptosuite ​
readonlycryptosuite:CryptosuiteApi
Defined in: packages/api/src/crypto.ts:450
Schnorr Cryptosuite operations (optionally stateful).
keypair ​
readonlykeypair:KeyPairApi
Defined in: packages/api/src/crypto.ts:444
Schnorr keypair operations.
multikey ​
readonlymultikey:MultikeyApi
Defined in: packages/api/src/crypto.ts:447
Schnorr Multikey operations (optionally stateful).
proof ​
readonlyproof:DataIntegrityProofApi
Defined in: packages/api/src/crypto.ts:453
Data Integrity Proof operations (optionally stateful).
Methods ​
activate() ​
activate(
mk):this
Defined in: packages/api/src/crypto.ts:463
Activate a multikey and propagate through the full pipeline. Sets the current multikey, creates a cryptosuite from it, and creates a proof instance from the cryptosuite — all three sub-facades become ready for stateful operations.
Parameters ​
mk ​
The multikey to activate (must include a secret key for signing).
Returns ​
this
this for chaining.
deactivate() ​
deactivate():
void
Defined in: packages/api/src/crypto.ts:475
Clear stateful defaults from all sub-facades.
Returns ​
void
sign() ​
sign(
data):Bytes
Defined in: packages/api/src/crypto.ts:487
Sign data using the current multikey. Shorthand for crypto.multikey.sign(data).
Parameters ​
data ​
The data to sign.
Returns ​
The signature bytes.
signDocument() ​
signDocument(
document,config):SignedBTCR2Update
Defined in: packages/api/src/crypto.ts:512
Sign a BTCR2 update document using the current proof instance. Shorthand for crypto.proof.addProof(document, config).
Requires activate to have been called first, or the three sub-facades to have been configured individually.
Parameters ​
document ​
The unsigned BTCR2 update document.
config ​
The Data Integrity proof configuration.
Returns ​
The signed document with proof attached.
verify() ​
verify(
data,signature):boolean
Defined in: packages/api/src/crypto.ts:498
Verify a signature using the current multikey. Shorthand for crypto.multikey.verify(data, signature).
Parameters ​
data ​
The data that was signed.
signature ​
The signature to verify.
Returns ​
boolean
true if the signature is valid.
verifyDocument() ​
verifyDocument(
document):VerificationResult
Defined in: packages/api/src/crypto.ts:522
Verify a signed BTCR2 update document using the current cryptosuite. Shorthand for crypto.cryptosuite.verifyProof(document).
Parameters ​
document ​
The signed document to verify.
Returns ​
The full verification result.