Skip to content

@filoz/keysmith

InterfaceDescription
ClaimOne link: what its bearer may read, and how much further they may delegate.
ClaimChainA chain, root first, with the fields every link inherits from the root.
ClaimSignerAnything that signs EIP-712 typed data: a viem account or wallet client.
GrantA node key wrapped to one recipient. Safe to store or send anywhere.
GrantDescriptorEncryption grant metadata. Exactly these fields are authenticated, so a grant cannot be relabelled; anything else carried alongside a grant is informational and unauthenticated.
KeyspaceKeysWhat keyspaceKeys() hands back. The signature it came from is never exposed.
KeyspaceKeysOptions-
KeyspaceRefIdentifies the keyspace a key belongs to.
PieceLabelsThe labels a provider read from a piece’s FEE envelope.
ReadRequestA request for one piece, from whichever provider holds it, signed by the chain’s final bearer.
TypedDataSignerAnything that can sign EIP-712 typed data: a viem Account, a WalletClient, or a session key. Keysmith itself never sees a private key.
VerifiedClaimThe final claim of a verified chain.
WriteTargetWhat writeTarget() hands a delegate: everything needed to write one piece.
Type AliasDescription
GrantNodeWhat a grant may unlock: the whole keyspace, one scope within it, or one piece, named by its salt.
HoldingWhich node the caller holds when deriving a piece key: the keyspace, a scope by its path, or one piece by its salt.
KeyspaceKeyMessageThe message an owner signs to start the derivation tree
PieceMetadataFEE envelope entries to enable key derivation/recovery
VariableDescription
COMMITMENT_KEYThe FWSS data-set metadata key the commitment is written to.
DOMAINSparse EIP-712 message block to be signed by the root wallet. Note: Deliberately carries neither chainId nor verifyingContract as out primary concern is long-term access to the stored pieces, no matter what chain or contract they were initially associated with.
KEYSPACE_ID_KEYThe FWSS data-set metadata key naming the keyspace, so the chain alone can list them.
KEYSPACE_KEY_TYPESParameters of the typed data signature that roots a keyspace
MAX_CHAIN_LENGTH-
MAX_REQUEST_LIFETIME-
READ_GRANT_TYPESEIP-712 types for every link and for a request. The domain is Keysmith’s DOMAIN. A link’s signature covers the fields it inherits from the root, so a link cannot be moved under a root that differs in any of them. Links name their parent by its bearer’s address, not by hash, so a parent can be re-issued without invalidating the links beneath it.
READ_REQUEST_TYPES-
FunctionDescription
commitmentA non-secret commitment to the keyspace key, for FWSS data-set metadata: v1.<32 hex digits>, where v1 is the format of the value.
decodeDelivery-
decodeGrantRead a grant delivered as bytes, without opening it: to see what it names before unwrapping, or to pass to holdingOf.
decodePresentation-
delegateClaimDelegate: the chain’s final bearer signs a narrower link for bearer. Takes the key the bearer holds for its own link, checks it against that link’s commitment, and derives the child’s key from it, so an honest delegate cannot commit to a wrong key. Hands the child key back to wrap. A piece link needs the piece’s labels, to check the parent’s node reaches it.
encodeDeliveryA delivery: sent once to a new bearer, never to a provider. Carries the v1 grant that wraps the key. The grant must name the chain’s final node, owner and keyspace; that the wrapped key matches the link’s commitment is checked by openDelivery, which holds the private key to unwrap it.
encodeGrantPack the grant to deliver or store it
encodePresentationA presentation: sent to a provider with each gated request, as Authorization: FOC-Grant <base64url>.
grantDescriptorThe descriptor naming what a grant unlocks, ready for wrapTo().
holdingOfWhich node a grant carries, ready to pass to keyForEnvelope.
keyCommitmentOfA key’s commitment as the 16 bytes a claim carries.
keyForEnvelopeDerive a piece’s key from whichever node the caller holds.
keyResolverA FEE key resolver for pieces this node reaches: pass it to fee.decrypt(), which calls it with the envelope’s metadata before decrypting a byte.
keyspaceIdCanonical form of a keyspace identifier: 16 bytes of hex, lowercase, prefixed with 0x.
keyspaceKeyMessage-
keyspaceKeysSign for one keyspace and derive its key.
lowSrsCanonicalize signature:r‖s with s normalised to the low half, and v dropped.
matchesCommitmentVerifies that kk is the key you expect: the right root wallet and the right keyspace. Check this before using any key received in a grant.
newKeyspaceA fresh keyspace identifier: 16 random bytes. Must be unique to a wallet, so that a grant for one keyspace cannot be relabelled as another.
newSaltA fresh per-piece salt. Public: it only has to travel with the piece.
openDeliveryOpen a delivery as its final bearer: verify the chain, unwrap the key, and check it against the commitment in its claim, which the owner (or the delegate above) signed. The keyspace commitment comes back too, for a bearer that writes the keyspace’s first datasets.
pieceKeyThe key for one piece. Never reused: FEE requires a fresh key per object.
pieceMetadataPiece FEE envelope metadata entries.
pieceNodeThe grant node for one piece, from its envelope metadata: piece:<salt>.
publicKeyOfThe public key a sender wraps to, for the holder of a secp256k1 private key.
reachesWhether node reaches the piece these labels describe.
rootClaimThe root of a chain, signed by the owner’s wallet: one EIP-712 prompt. Derives the bearer’s node key from the keyspace key, so the root cannot commit to a wrong one, and hands it back to wrap for the bearer. When the bearer is a session key, set expires to the session key’s expiry.
scopeKeyThe key for an access scope. Scopes form a tree, and a scope’s key is derived from its parent’s, so holding a scope also opens every scope beneath it.
scopeNameCanonicalize scope name in the form it is derived from: Unicode NFC, non-empty, no leading or trailing whitespace, and no / (which would indicate a path). Case is significant.
scopePathCanonicalize scope path: canonical names joined by /, top scope first.
signRequestSign a request for one piece, as the chain’s final bearer. Any provider holding it may serve it.
unwrapWithOpen a grant with the recipient’s private key: the grant as delivered, in bytes, or as decoded by decodeGrant.
verifyChainCheck a chain with nothing but the chain: the root signed by the owner and unexpired, every later link signed by the previous bearer and no wider than it. Pass piece when a link names a piece.
verifyPresentationWhat a gating provider checks on a request, with only the header and the piece’s labels: the chain, the request’s piece, lifetime and signer, and that the final node reaches the piece. A piece without foc/own is not gated.
wrapToWrap a node key — a keyspace key, a scope key, or one piece’s key — to a recipient.
writeTargetEverything a delegate needs to write a piece, taken from the grant that delegated it: the keyspace to record, the scope to label it with, and the key to derive its piece key from.