@@ -30,8 +30,7 @@ All public functions are exported from the package entry point:
3030``` js
3131import {
3232 // DID document operations
33- create , addVm , createEvent , deriveHeartbeatKeyPair ,
34- hashDidKey , setHeartbeatFrequency ,
33+ create , addVm , createEvent , deriveHeartbeatKeyPair , hashDidKey ,
3534 // CEL operations
3635 createCel , addEvent , getPreviousEventHash , witness ,
3736 read , loadFromFile , saveToFile ,
@@ -55,7 +54,7 @@ initial signed create event already wrapped in a Cryptographic Event Log.
5554| Parameter | Type | Description |
5655| -----------| ------| -------------|
5756| ` options.curve ` | string | Elliptic curve for key generation. Default: ` 'P-256' ` . |
58- | ` options.heartbeatFrequency ` | string | ISO 8601 duration for the required heartbeat interval. Default: ` 'P10Y ' ` . |
57+ | ` options.heartbeatFrequency ` | string | ISO 8601 duration for the required heartbeat interval. Default: ` 'P1M ' ` . |
5958
6059``` js
6160const {keyPair , heartbeatSecret , didDocument , cryptographicEventLog } =
@@ -87,24 +86,25 @@ const {keyPair: authKeyPair, didDocument: updatedDoc} = await addVm({
8786
8887---
8988
90- ### ` createEvent({type, data, assertionMethod, previousEventHash, [heartbeat]}) ` -> ` Promise<{event}> `
89+ ### ` createEvent({type, data, assertionMethod, previousEventHash, [heartbeat], [heartbeatFrequency] }) ` -> ` Promise<{event}> `
9190
9291Creates a signed event of the given type using the provided assertion method key.
9392Use this for ` 'update' ` , ` 'heartbeat' ` , and ` 'deactivate' ` events after the
9493initial create. Always call ` getPreviousEventHash() ` first and pass the result
9594as ` previousEventHash ` so the hash is covered by the operation proof.
9695
97- For ` ' heartbeat' ` events, pass the rotated heartbeat hashes as ` heartbeat `
98- rather than embedding them in a DID document. The hashes are placed directly
99- on the event object and covered by the proof.
96+ ` heartbeat ` hashes and ` heartbeatFrequency ` are event-level fields — they belong
97+ directly on the event object, not inside the DID document. Both are covered by
98+ the operation proof.
10099
101100| Parameter | Type | Description |
102101| -----------| ------| -------------|
103102| ` type ` | string | Event type: ` 'update' ` , ` 'heartbeat' ` , or ` 'deactivate' ` . |
104103| ` data ` | object\| undefined | The DID document for update events; ` undefined ` for heartbeat and deactivate. |
105104| ` assertionMethod ` | KeyPair | The key pair to sign with (from ` assertionMethod ` in the DID document, or the heartbeat key pair). |
106105| ` previousEventHash ` | string | Base58btc SHA3-256 hash of the previous event from ` getPreviousEventHash() ` . |
107- | ` heartbeat ` | string[ ] \| undefined | For heartbeat events: array of new heartbeat hashes to rotate in. |
106+ | ` heartbeat ` | string[ ] \| undefined | Array of new heartbeat hashes to rotate in (required for heartbeat events). |
107+ | ` heartbeatFrequency ` | string\| undefined | ISO 8601 duration to change the required heartbeat interval (e.g. ` 'P1M' ` , ` 'P1D' ` ). |
108108
109109``` js
110110const previousEventHash =
@@ -177,26 +177,6 @@ await witness({
177177
178178---
179179
180- ### ` setHeartbeatFrequency({didDocument, heartbeatFrequency}) ` -> ` {didDocument} `
181-
182- Updates the ` heartbeatFrequency ` field on a DID document and removes the proof.
183- The document must be re-signed with ` createEvent ` before appending an update
184- event.
185-
186- | Parameter | Type | Description |
187- | -----------| ------| -------------|
188- | ` didDocument ` | object | The current DID document. |
189- | ` heartbeatFrequency ` | string | ISO 8601 duration (e.g. ` 'P3M' ` , ` 'P1Y' ` ). |
190-
191- ``` js
192- const {didDocument: updatedDoc } = setHeartbeatFrequency ({
193- didDocument,
194- heartbeatFrequency: ' P3M'
195- });
196- ```
197-
198- ---
199-
200180### ` deriveHeartbeatKeyPair(masterSecret, index) ` -> ` Promise<KeyPair> `
201181
202182Derives an ECDSA P-256 Multikey key pair from a heartbeat master secret and an
@@ -404,18 +384,20 @@ The library implements the `did:cel` DID method, which consists of:
404384- ** Blind witness attestations:** Witness services receive only a SHA3-256 hash
405385 of each event and return ` DataIntegrityProof ` attestations, providing temporal
406386 anchoring and distributed trust without learning DID document contents.
407- - ** Heartbeat keys:** Each DID document stores SHA3-256 hashes of heartbeat
408- ` did:key: ` URIs. A heartbeat operation signs an update with the heartbeat key
409- (derived via ` deriveHeartbeatKeyPair(masterSecret, index) ` ) and must rotate
410- out the used hash, replacing it with the hash of the next derived key. Only
411- the 16-byte master secret is stored; individual keys are derived on demand.
387+ - ** Heartbeat keys:** The initial create event carries a ` heartbeat ` array
388+ (SHA3-256 hashes of heartbeat ` did:key: ` URIs) and a ` heartbeatFrequency `
389+ ISO 8601 duration — both as event-level fields, not inside the DID document.
390+ A heartbeat operation signs an event with the heartbeat key (derived via
391+ ` deriveHeartbeatKeyPair(masterSecret, index) ` ), rotates out the used hash,
392+ and adds the hash of the next derived key on the event itself. Only the
393+ 16-byte master secret is stored; individual keys are derived on demand.
412394- ** Encrypted secret storage:** Private keys encrypted with AES-256-GCM using a
413395 scrypt-derived key and stored in YAML format.
414396
415397## File Structure
416398
417399- ` lib/index.js ` - Package entry point; explicit named exports for all public functions
418- - ` lib/didcel.js ` - DID document operations: ` create ` , ` addVm ` , ` createEvent ` , ` setHeartbeatFrequency ` , ` hashDidKey `
400+ - ` lib/didcel.js ` - DID document operations: ` create ` , ` addVm ` , ` createEvent ` , ` deriveHeartbeatKeyPair ` , ` hashDidKey `
419401- ` lib/cel.js ` - Cryptographic Event Log: ` createCel ` , ` addEvent ` , ` getPreviousEventHash ` , ` witness ` , ` read ` , ` loadFromFile ` , ` saveToFile `
420402- ` lib/secrets.js ` - Encrypted key storage: ` saveSecrets ` , ` loadSecrets `
421403- ` lib/witness.js ` - HTTP client for witness services
0 commit comments