These files build the signed, content-addressed blobs the mobile app publishes. Each is adapted from the matching file in frontend/packages/client/src, with two deliberate differences: time is always an argument, and hashing is pure JavaScript. The resulting bytes go to the site through Publishing signed blobs.
The signing convention
Every Seed blob is signed the same way:
Build the object with sig set to 64 zero bytes and signer set to the 34-byte principal.
Encode it as strict DAG-CBOR and sign those bytes with Ed25519.
Replace sig with the 64-byte signature and encode again. Those are the published bytes.
Timestamps are BigInt(wireTimestamp(ms)), so a fractional Exact clock value is floored first (Primitives).
blob.ts
blob.ts holds the content-addressing helpers.
Function | Behaviour |
|---|---|
| CIDv1, codec |
|
|
| Decodes, requires a 34-byte |
signing.ts
signing.ts is internal ("Not exported from the package index").
cborCodec: {code: 0x71, name: 'DAG-CBOR', encode} over the strict encoder.
normalizeBytes(data): copies into an owned, exact-length Uint8Array.
signObject(signer, data): signs strictEncode(data).
signerPublicKey(signer): the principal from either signer shape.
toPublishInput(blobData, extraBlobs?): {blobs: [{data}, ...extras]}. The primary blob carries no cid; extras keep theirs.
signer.ts
signer.ts reconciles two signer shapes that "grew up independently" in the client:
Type | Shape |
|---|---|
|
|
|
|
| either |
toHMSigner and toPrincipalSigner convert between them. In both, the public key is the 34-byte principal. signerFromKeyPair(key) in index.ts adapts a KeyPair or a raw seed to an object satisfying both.
change.ts
change.ts builds document Changes in two steps.
createChangeOps({ops, genesisCid?, deps?, depth?, timestampMs}) returns {unsignedBytes, ts}. createChange(unsignedBytes, signer) fills signer, signs, and returns {bytes, cid, genesis, ts}.
Field | Value |
|---|---|
|
|
|
|
| null when unsigned, then the principal |
| bigint milliseconds |
| null when unsigned, then the signature |
| present only when |
DocumentOperation is one of SetAttributes (attrs: [{key: string[], value}]), MoveBlocks, ReplaceBlock, DeleteBlocks. The app only emits SetAttributes.
createHomeGenesisChange(signer) returns the genesis of an account's home document: {type: "Change", signer, sig, ts: 0} and nothing else. It is deterministic on purpose, so "every device of an account derives the same home genesis". The comment warns that any other document built on it "becomes the home document as far as the daemon is concerned", and records that this happened to sixty documents on 2026-09-15. A non-home document's first content Change is its own genesis.
ref.ts
createVersionRef(input, signer) returns a publish input holding one Ref blob.
Field | Value | Omitted when |
|---|---|---|
|
| never |
| principal, bigint ms, signature | never |
| CID parsed from | never |
| CIDs from | never |
| number | it is 0 |
| principal bytes of | it equals the signer |
| string such as | it is empty |
| CID | not given |
| string such as | empty |
comment.ts
createComment(input, signer) returns the publish input: the Comment blob first, then any attachment blobs.
Field | Value |
|---|---|
|
|
| publishable blocks |
| principal bytes decoded from |
|
|
| CIDs of the commented document version |
| CIDs, only for replies |
| as above |
| only when set |
Content handling, in order:
trimTrailingEmptyBlocks drops trailing empty Paragraph or Heading nodes.
A quote target (quoting: {blockId, range?}, or the deprecated quotingBlockId) wraps the content in an Embed block (childrenType: "Group", view: "Content") whose link is pinned to the exact version with no latest flag. Its id is quoteBlockId, or 8 random characters from a 62-character alphabet drawn with rejection sampling.
blockToPublishable flattens each node: Paragraph, Heading, Math, Code, Image, Video, File, Button, Embed, WebEmbed and Slot are accepted, anything else throws Unsupported block type. An empty Paragraph is dropped unless it has children or a childrenType (a list container).
Annotations are reduced to known fields; Bold, Italic, Underline, Strike, Code, Link, Embed, TextColor, BackgroundColor, TextSize, TextFamily are accepted. validateExclusiveAnnotations throws when two colour, size or family annotations with different values overlap.
undefined values are stripped, because strict DAG-CBOR refuses them.
commentRecordIdFromBlob(bytes) computes the comment's record id: <base58btc signer>/<tsid>, where the tsid is base58btc of 10 bytes: the low 48 bits of ts big-endian, then the first 4 bytes of the blob's SHA-256.
The app sends a single Paragraph; see Discuss: loading and posting.
profile.ts
createProfilePublishBlobs(input, signer) builds a home-document metadata update.
Input | Meaning |
|---|---|
| account id, used as the Ref's |
| one |
| used for the Change and the Ref |
|
|
| optional capability CID for the Ref |
Without previous it creates the home genesis, a Change of depth 1 depending on it, and a Ref with generation 1: three blobs. With previous it keeps the genesis and generation, depends on the previous heads, and uses depth + 1: two blobs. It returns {changeCid, genesis, generation, blobs}. Profile is the caller.
types.ts
types.ts declares HMSigner, HMPublishBlobsInput, HMAnnotation, HMBlockNode and UnpackedHypermediaId, plus hmIdPathToEntityQueryPath and packHmId (builds hm://uid/path?v=...#block[start:end]).
Tests
In crypto.test.ts, "signed CBOR and CID vectors from the real client" has 12 tests: the Change (unsigned and signed bytes), the home Ref, fresh and existing profiles, six comment shapes with their record ids, rejection of bad annotations and blocks, and attachments plus tamper detection. Six more tests check the home genesis for six seeds. All compare against parity vectors.
User stories
The code described here exists to deliver these stories. Each story lists this page in its Trace (traceability).
US-DISC-03 Comment on a document: The signed Comment blob and its record id
US-DISC-04 Reply in a thread: Comment blob with reply parent and thread root versions
US-ID-07 Edit my public profile: The signed changes and ref that make up a profile update
US-APP-09 Know the app only reaches what it must: Comments and profile changes signed on the device
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime