Kotlin
Este conteúdo não está disponível em sua língua ainda.
Every declaration the capsule_sdk namespace exports, as uniffi 0.32.2 spells it in uniffi/capsule_sdk/capsule_sdk.kt.
These are Kotlin declarations; calling them from Java is untested. The page follows Dokka’s layout without being rendered by it (Developer Documentation — Why Not Dokka).
Functions
Section titled “Functions”fun
syncedHistorySources
Section titled “syncedHistorySources”@Throws(FfiException::class) fun syncedHistorySources(manifestCbor: kotlin.ByteArray, history: List<kotlin.ByteArray>): FfiHistorySourcesTypes: FfiException, FfiHistorySources
Name what adopting an asset from its history fetches: the live metadata blob and the
original, read off the asset’s latest record manifest_cbor (a feed entry’s) and history,
the records before it that FfiSession::fetch_provenance_history returned.
An album page — the one a writer member’s device reads — serves a delete with no metadata
blob and no blob, so a device that first sees the asset there has only its records. The live
metadata blob is the newest record that binds one, and the delete commits to the original;
the server serves both to the asset’s readers until its retention window closes. Fetch them
with FfiSession::fetch_metadata_blob and FfiSession::fetch_blob_to_path, set the
entry’s metadata_blob to the first, and hand the second to
FfiWorkspace::open_synced_history: the asset is held in this device’s trash and its
trash-restore can be signed. An entry that names its metadata blob (the owner’s own feed)
agrees with this answer.
Pure and offline. Nothing is trusted for being named: the adoption binds the metadata blob and the original to the records, and refuses what does not.
Errors
Section titled “Errors”FfiError::Sync when a record does not decode or none binds a metadata blob.
fun
syncedRetentionClosed
Section titled “syncedRetentionClosed”@Throws(FfiException::class) fun syncedRetentionClosed(manifestCbor: kotlin.ByteArray, changedAt: kotlin.String): kotlin.BooleanTypes: FfiException
Whether a tombstone’s retention window had closed at changed_at (RFC 3339, a feed
entry’s own): manifest_cbor is a delete record and changed_at is at or after the
retention_until signed into it.
A device that first sees an asset at an album page’s tombstone reads this before it calls
FfiSession::fetch_provenance_history: once the window has closed the server refuses the
asset’s records and bytes to its readers, so there is nothing left to adopt, and passing the
entry loses nothing. A record that is not a delete, or a delete whose window is absent or
unreadable, answers false.
Pure and offline.
Errors
Section titled “Errors”FfiError::InvalidArgument when changed_at is not an RFC 3339 instant;
FfiError::Sync when manifest_cbor does not decode.
fun
embeddedPreview
Section titled “embeddedPreview”@Throws(FfiException::class) fun embeddedPreview(originalPath: kotlin.String, ext: kotlin.String): FfiEmbeddedPreview?Types: FfiException, FfiEmbeddedPreview
Read the embedded preview of the original at original_path, whose extension (without the
dot) is ext.
None when the original is not a RAW, carries no preview, or carries one that does not read
within the decode budget: each leaves the rung to the next source, so none is an error. The
reason is logged.
This reads the whole original into memory, because the extraction’s IFD bounds walk and its
stated-length guard run over the full file before the RAW reader does. Call it once per asset
and keep the FfiEmbeddedPreview it returns, rather than once per render.
Errors
Section titled “Errors”FfiError::Workspace when the file cannot be read.
fun
renderStep
Section titled “renderStep”fun renderStep(request: FfiRenderRequest, shown: FfiRendition?, local: FfiLocalHoldings, fetchable: List<FfiRepresentation>): FfiRenderStepOne step of the render ladder (crate::fetch::render_step): what to show now and what to
obtain next. shown is what the surface shows, None when it shows nothing yet or is falling
back below what it showed; fetchable is what the server lists for the asset.
fun
evaluateAlerts
Section titled “evaluateAlerts”@Throws(FfiException::class) fun evaluateAlerts(input: FfiNotifyInput, now: kotlin.String): List<FfiAlert>Types: FfiException, FfiNotifyInput, FfiAlert
Every alert that is true at now, in delivery order.
Pure and offline: no network call, no library open, no clock read — now is the caller’s, so
the same input always gives the same answer and an app can drive it from a test clock.
Errors
Section titled “Errors”FfiError::InvalidArgument if now or any instant in input is not RFC 3339, or if
suppressed_until names something that is not an alert class.
fun
nextAlertDeadline
Section titled “nextAlertDeadline”@Throws(FfiException::class) fun nextAlertDeadline(input: FfiNotifyInput, now: kotlin.String): kotlin.String?Types: FfiException, FfiNotifyInput
The earliest instant in pre_arm_deadlines (RFC 3339), or None when there is nothing to
arm.
For a host that can hold only one timer. An app that schedules per class wants
pre_arm_deadlines: the minimum discards the later class’s alarm, and on a device the app
never runs on again that alert is simply lost.
Errors
Section titled “Errors”As evaluate_alerts.
fun
preArmDeadlines
Section titled “preArmDeadlines”@Throws(FfiException::class) fun preArmDeadlines(input: FfiNotifyInput, now: kotlin.String): List<FfiClassDeadline>Types: FfiException, FfiNotifyInput, FfiClassDeadline
The instant to arm a local notification for, per class — the call an app schedules its
UNCalendarNotificationTrigger / AlarmManager alarms from.
Reconcile your timers against the result: a class present here should hold exactly one alarm at the returned instant, and a class absent from it should hold none. Recompute after any state change; that is the whole of the arm / re-arm / cancel rule on the client side.
Only the two classes whose deadline a device can compute alone ever appear. The other three depend on server state and surface at next app launch — a real gap the design accepts.
Errors
Section titled “Errors”As evaluate_alerts.
fun
p256HardwareDekRoundTrip
Section titled “p256HardwareDekRoundTrip”@Throws(FfiException::class) fun p256HardwareDekRoundTrip(hardware: FfiHardwareKeyAgreement, keyAlias: kotlin.String, mlSeed: kotlin.ByteArray): kotlin.BooleanTypes: FfiException, FfiHardwareKeyAgreement
Smoke the hardware-bound P-256 device encryption key across the FFI seam:
enroll a key-agreement key in hardware under key_alias, publish the hybrid public key,
encapsulate a fresh shared secret to it in software (the sender side), then
decapsulate through the element’s ECDH. Returns true iff the two secrets match —
proving the element’s ECDH composes into the hybrid KEM without the private scalar leaving
hardware. ml_seed (32 bytes) is the software-sealed ML-KEM-768 half.
The DEK is not yet wired into workspace creation, so this focused round-trip is the
composition’s on-device check — the DEK analogue of
FfiWorkspace::create_with_p256_hardware_signer. Every step is one capsule-core call.
Classes
Section titled “Classes”class
FfiCapsuleClient
Section titled “FfiCapsuleClient”open class FfiCapsuleClient: Disposable, AutoCloseable, FfiCapsuleClientInterfaceThe unauthenticated entry point over the SDK’s auth + upload endpoints. Turns
credentials into an FfiSession handle; the protocol pin and endpoints are
captured once here and reused by every session this client mints.
Constructors
-
constructor(authBaseUrl: kotlin.String, uploadBaseUrl: kotlin.String, protocolVersion: kotlin.String, cohortHash: kotlin.String?)
Build a client.
auth_base_urlis the auth endpoint root (e.g.https://api.example.com/auth).upload_base_urlis the upload endpoint root (POSTtarget; chunk/HEAD hang under{upload_base_url}/{id}).protocol_versionis the pinned protocol date (YYYY-MM-DD).cohort_hashis the optional advisory device-cohort digest;Nonesends nothing (the server behaves identically).
Functions
-
suspend fun login(email: kotlin.String, password: kotlin.String): FfiLoginOutcome
Types:
FfiLoginOutcomeAuthenticate with email + password, returning an authenticated session handle.
-
suspend fun register(email: kotlin.String, password: kotlin.String): FfiSession
Types:
FfiSessionCreate an account and return an authenticated session handle (the server issues tokens on registration). An address and a password, and nothing else: the server takes nothing else. A display name is a fact about a person, and the profile surface that would hold one is owed rather than assumed.
-
suspend fun verifySecondFactor(mfaToken: kotlin.String, totpCode: kotlin.String): FfiSession
Types:
FfiSessionComplete a sign-in with the code an authenticator app is showing.
mfa_tokenis whatFfiLoginOutcome::SecondFactorRequiredcarried. It is good once and for five minutes.
class
FfiSession
Section titled “FfiSession”open class FfiSession: Disposable, AutoCloseable, FfiSessionInterfaceAn authenticated session handle. Owns the SDK token store internally (auto
pre-flight refresh, single-flight, 401-retry-once); no token ever crosses
the FFI boundary. Every flow rides this handle.
Functions
-
suspend fun escrowGet(apiBaseUrl: kotlin.String): kotlin.ByteArray
Fetch this account’s escrow blob (
GET /v1/auth/escrow) as opaque canonical CBOR — the bytesFfiWorkspace::verify_escrow_blobchecks and a recovery flow unwraps.No escrow enrolled yet is
FfiError::Escrowcarryingerror.escrow.not_stored— the code that separates “set up a recovery key” from “we could not read the one you have”. A refused credential isFfiError::Auth. -
suspend fun escrowPut(apiBaseUrl: kotlin.String, blob: kotlin.ByteArray): FfiEscrowStored
Types:
FfiEscrowStoredStore or replace this account’s master-key escrow blob (
PUT /v1/auth/escrow).blobis the opaque canonical CBORFfiWorkspace::escrow_blobminted — the master key itself never crosses this boundary in either direction.Single active escrow: the server replaces any prior blob in the same transaction, so the secret a rotation retired unwraps nothing.
api_base_urlis the API root the session authenticates against (the per-call endpoint convention this surface already uses forsync_pull). A URL operation paths cannot hang off isFfiError::InvalidArgument; a refused credential isFfiError::Auth, so a caller re-authenticates rather than retrying; everything else isFfiError::Escrowwith the server’serror.escrow.*code when it sent one.The answer says what the store did:
FfiEscrowStored::replacedseparates “recovery set up” from “recovery key replaced” (the previous secret has stopped working). -
suspend fun fetchBlobToPath(blobBaseUrl: kotlin.String, hash: kotlin.String, size: kotlin.ULong, path: kotlin.String)
Fetch the blob at content address
hash(sizebytes, as the sync feed’sFfiBlobRefdeclares) into the file atpath, created or truncated.The blob streams to disk in bounded
Rangewindows, so memory is bounded by one window whatever the blob’s size, and its content address is checked as it lands. On any error the file is removed: a path this returnsOkfor holds exactly the verified ciphertext. A session that cannot authorize the fetch isFfiError::Auth, so the app signs in again; every other failure isFfiError::Fetch.blob_base_urlis the root the blob route hangs off ({blob_base_url}/blob/{hash}), the server’s/v1root. -
suspend fun fetchDeviceDirectory(apiBaseUrl: kotlin.String, userId: kotlin.String, pinnedUserIk: kotlin.ByteArray): kotlin.ByteArray
Fetch a user’s signed device directory, verified under
pinned_user_ik(the bytesFfiWorkspace::user_ik_publicreturns) before it is handed back. A document that does not verify is an error, never a return value. -
suspend fun fetchMetadataBlob(blobBaseUrl: kotlin.String, hash: kotlin.String): kotlin.ByteArray
Fetch the metadata blob at content address
hash, which a sync feed entry names by address only (itsmetadata_blob): the feed lists no size for it, so it is read in boundedRangewindows until the server’s answer ends, and returned whole once it hashes tohash. This is the bytesFfiSyncHead::metadata_blobcarries intoFfiWorkspace::open_synced_originalorFfiWorkspace::open_synced_history.A sealed sidecar is a few KiB; a blob that grows past
MAX_METADATA_BLOB_BYTESis refused rather than buffered without bound. On adeletein trash the server serves the asset’s live metadata blob to its readers until the retention window closes, so an asset first seen at its delete can be adopted and restored; where the entry names no metadata blob (an album page’s tombstone),synced_history_sourcesnames its address.blob_base_urlis as forfetch_blob_to_path. Ahashthat is not a lowercase hex SHA-256 isFfiError::InvalidArgumentand reaches no network; a session that cannot authorize the fetch isFfiError::Auth; a blob the server refuses, that does not hash to its address, or that runs past the bound isFfiError::Fetch. -
suspend fun fetchProvenanceHistory(blobBaseUrl: kotlin.String, manifestCbor: kotlin.ByteArray): List<kotlin.ByteArray>
Fetch the earlier provenance records of the asset whose latest record is
manifest_cbor(a feed entry’s): each record the one after it names byprior_provenance_hash, back to the asset’screate, from the blob route the server serves an asset’s superseded records on. Returned oldest first, each the exact bytes the server holds, checked against its content address; empty for acreate.For an asset this workspace does not hold, first seen past its create — an entry
FfiWorkspace::apply_sync_entry_from_filequarantines asRejected.ForgedChainwhen the app’s catalog holds no head for it, or applies without adopting (FfiAssetFacts::adoptedfalse) when it does — hand the records toFfiWorkspace::open_synced_history, which verifies them in order and holds the asset from its create. Nothing is verified here: the walk only follows links.An asset first seen at its
deleteis fetched the same way while it is in trash: the server serves a trashed asset’s records, and its live metadata blob and original, to its readers until the retention window closes, so the adopted asset can be restored. An album page’s tombstone names neither blob;synced_history_sourcesnames both from these records.blob_base_urlis as forfetch_blob_to_path. A record the server refuses (a deleted asset’s past its retention window, a purged asset’s, or one the caller may not read) or that does not hash to its address isFfiError::Fetch; a session that cannot authorize the fetch isFfiError::Auth; a record that does not decode, or a chain longer thanMAX_HISTORY_RECORDS, isFfiError::Sync. -
suspend fun isAuthenticated(): kotlin.Boolean
Whether the session currently holds tokens (
falseafter logout). -
suspend fun logout()
Revoke the session server-side and clear the local store (idempotent).
-
suspend fun publishDeviceDirectory(apiBaseUrl: kotlin.String, directoryCbor: kotlin.ByteArray, userIk: kotlin.ByteArray): kotlin.ULong
Publish this device’s signed device directory, returning the
directory_versionthe server now stores.directory_cboris the opaque documentFfiWorkspace::signed_device_directoryproduced; it travels verbatim, because re-encoding it would detach it from the signature it carries.user_ikis the account’s user identity public key the document is signed under — the bytesFfiWorkspace::user_ik_publicreturns — which the server anchors on first publish and verifies every publish against.Publish when the document changes (a device enrolled or revoked). The version must advance — republishing an unchanged document answers the version-conflict code.
-
suspend fun pushAsset(workspace: FfiWorkspace, assetId: kotlin.String): FfiPushReport
Types:
FfiWorkspace,FfiPushReportPush one sealed asset of
workspace— every blob of its bundle, in ladder order (provenance and metadata, then derivative manifests and derivatives, then the original) — drivingcapsule_sdk::push::push_bundleinside the SDK.The original never crosses the boundary: its ciphertext is re-derived from the plaintext on disk one upload chunk window at a time, so memory is bounded by the transfer window whatever the original’s size. The workspace lock is held only while the bundle is built, never across the network.
Every blob the reported path admits is driven (
set_path); the tiers it holds back are counted inFfiPushReport::deferredand wait for the next push. A blob the server already holds answersduplicate_bloband comes backFfiUploadOutcome::AlreadyStored, so pushing twice is safe. The album must already be provisioned on the server.A create the server refused is re-sealed and retried once (issue #822). When the album’s epoch moved past the one the asset was sealed under, the server refuses its create for good; if this device holds a newer epoch, the asset is re-sealed at it (
Workspace::reseal_create) and pushed again, once. A second refusal fails the push. When this device holds no newer epoch the push fails withFfiError::Uploadcarrying the server’s code and a detail saying there is no newer epoch to re-seal at, and the asset stays local. That detail names no missing key: the refusal may have had nothing to do with the epoch (a revoked device, withdrawn write access), or another device rotated the album and its key has not reached this one yet.To push several assets, use
push_assets: one call here is one bundle on the server’s lane, so the lane never holds more than one session open. -
suspend fun pushAssets(workspace: FfiWorkspace, assetIds: List<kotlin.String>): List<FfiPushAssetResult>
Types:
FfiWorkspace,FfiPushAssetResultPush several sealed assets of
workspacein one call, returning oneFfiPushAssetResultper id, in the order ofasset_ids.Every asset is pushed exactly as
push_assetpushes one — its original streamed in bounded windows, the tiers the reported path holds back counted inFfiPushReport::deferred, and a create the server refused re-sealed and retried once — but the assets share one run of the server’s lane: up to W of them have their sessions open at once, every range any of them sends reserves against one device-wide byte budget, and their retries spend from one lane budget. Callingpush_assetconcurrently instead gives each call its own budget, so the budgets add up rather than being shared.The ids are pushed in batches of a bounded size, so a list of any length holds only one batch’s bundles in memory at a time. One asset’s failure is its own (
FfiPushAssetResult::Failed, carrying the errorpush_assetwould have returned for it): the others still push, and the call itself never fails. An id repeated inasset_idspushes once, at its first occurrence; each later occurrence isFfiPushAssetResult::FailedwithFfiError::InvalidArgument.The adverse-link detector hears each batch’s outcomes when that batch’s run ends, so a link that degrades mid-batch re-plans the push from the next batch on.
-
fun setPath(snapshot: FfiPathSnapshot): kotlin.ULong
Types:
FfiPathSnapshotReport the path as the app’s OS listeners see it now, and return its path generation.
Call it whenever a listener fires. The generation advances only when reachability, the interface or the cost changes; it then drops this session’s pooled connections, forgets the resets and stalls seen on the old path, and cancels — within one scheduling tick — any push work the new path forbids, which re-plans and resumes. Power, thermal and background-deadline changes re-plan without a new generation.
-
suspend fun syncPull(apiBaseUrl: kotlin.String, cursor: kotlin.ByteArray, pageSize: kotlin.UInt): FfiSyncPage
Types:
FfiSyncPagePull one page of the key-free sync feed after
cursorfromapi_base_url(http[s]://host:port). Pass an emptycursorfor the first page; persist and pass backnext_cursorto advance. The bearer rides theAuthorizationheader (auto-refreshed); it never crosses the FFI boundary.The parameter is the API base URL now, not a gRPC endpoint: the feed is
GET /v1/syncon the same origin as every other call. -
fun transferEvents(): FfiTransferSubscription
Types:
FfiTransferSubscriptionSubscribe to the step-by-step progress of every upload, push and fetch this session drives from now on, each event stamped with the milliseconds since this call on a monotonic clock.
Progress is advisory: a transfer never waits on its observer, so a subscriber that falls behind reads
FfiTransferFeedItem::Laggedwith the count it missed. The subscription ends once this session is dropped. -
suspend fun upload(request: FfiUploadRequest, data: kotlin.ByteArray): FfiUploadOutcome
Types:
FfiUploadRequest,FfiUploadOutcomeUpload a full ciphertext blob (
data) underrequest, driving the adaptive, resumable protocol with the code-driven recovery matrix.datacrosses the boundary whole, so this is for blobs an app already holds in memory. To push a sealed asset, original included, usepush_asset, which never holds the original whole. -
suspend fun uploadStatus(sessionId: kotlin.String): FfiUploadStatus?
Types:
FfiUploadStatusQuery an upload session’s progress (
HEAD /upload/{id}).Nonemeans the session is gone (discarded/expired/never-existent). -
suspend fun applyLifecycleOp(apiBaseUrl: kotlin.String, workspace: FfiWorkspace, record: kotlin.ByteArray, serverHead: kotlin.ByteArray?): FfiLifecycleOpOutcome
Types:
FfiWorkspace,FfiLifecycleOpOutcomeApply one signed lifecycle op
record— adeleteor atrash-restore, as the opaque canonical CBORFfiWorkspace::provenance_head,FfiPurgeOutcome::reissue_recordandFfiWorkspace::purged_recordcarry — to its album’s ops surface onapi_base_url(http[s]://host:port, the rootsync_pulltakes).The record must be one
workspaceholds: its device signature verifies under the workspace’s device directory, and it is a record of the workspace’s chain for its asset (live, trashed, or kept by a purge). The server cannot verify signatures, so a record that is not this workspace’s own is refused here rather than becoming the asset’s chain head there.server_headis the sync feed’s evidence for the asset: themanifest_cborof the latest entry listing it (empty for an entry that carries none), orNonewhen the feed does not list it. WithNonenothing is sent and the answer isFfiLifecycleOpOutcome::NotIndexed: the server never sees a lifecycle op for an asset it has not indexed.Idempotent: a record the server already applied answers
Appliedwithreplayedset. A refusal, or a server that could not be reached, isFfiLifecycleOpOutcome::Failed; a session the server did not accept isFfiError::Auth.Errors
Section titled “Errors”FfiError::InvalidArgumentfor bytes that are not a lifecycle op record (over the bound, not canonical, not adeleteortrash-restore, not signed by a device of the workspace’s directory, or not on the workspace’s chain for its asset) or anapi_base_urlthat is not an http(s) URL, before anything is sent;FfiError::Authfor a refused session. -
suspend fun deliverLifecycleAtHash(apiBaseUrl: kotlin.String, workspace: FfiWorkspace, assetId: kotlin.String, serverHeadHash: kotlin.ByteArray?, latestChangedAt: kotlin.String?): FfiLifecycleOpOutcome
Types:
FfiWorkspace,FfiLifecycleOpOutcomeDeliver the held lifecycle records of an asset
workspacestill holds, live or in the trash: every record of its chain after the head the server holds, in chain order, each once the one before it was applied. That is adeleteortrash-restoresigned while the server had not indexed the asset, or whose send failed, together with any it chains onto that the server never saw. The rule is the CLI’s and a purge’s (plan_delivery).server_head_hashis the feed’s evidence for the asset, asdeliver_purge_at_hashtakes it:None, an asset the feed does not list, sends nothing and answersFfiLifecycleOpOutcome::NotIndexed.latest_changed_atis the latestchanged_at(RFC 3339) the caller’s feed drain saw, on the server’s clock, orNonewhen it saw none. It floors this device’s clock (judging_clock), and a stretch in which atrash-restoreundoes adeletewhose window had closed by that clock is withheld and answersFfiLifecycleOpOutcome::RestoreTooLate: sent, the server would apply the delete and refuse the restore.Everything is read from the workspace’s chain, so a delivery that failed or was held is retried by calling this again, also after the workspace was reopened. The workspace lock is held only while the chain is read, never across the network, and every record of the stretch is judged as
apply_lifecycle_opjudges a foreign one before any is sent. A server level with the chain is sent its head alone, which it answers as a replay; a caller that compares the listed head withFfiWorkspace::provenance_headfirst sends nothing for it. The answer is the last record’sApplied, or the first record that was not applied, whoseFailedstops the stretch.Errors
Section titled “Errors”FfiError::TrashwithFfiTrashRefusal::NotFoundfor an asset this workspace does not hold (a purged one goes throughdeliver_purge_at_hash);FfiError::InvalidArgumentfor a malformedasset_idorapi_base_url, aserver_head_hashthat is neither empty nor 32 bytes, or alatest_changed_atthat is not an RFC 3339 timestamp, before anything is sent;FfiError::Workspacefor a chain whose records do not verify under the workspace’s device directory;FfiError::Authfor a refused session. -
suspend fun deliverPurge(apiBaseUrl: kotlin.String, workspace: FfiWorkspace, assetId: kotlin.String, serverHead: kotlin.ByteArray?): FfiLifecycleOpOutcome
Types:
FfiWorkspace,FfiLifecycleOpOutcomeDeliver a purged asset’s
deleteto its album’s ops surface: every record of the chain the purge kept after the head the server holds, in chain order, each once the one before it was applied. After an early purge that is the shorter-retention re-issue (FfiPurgeOutcome::reissue_record) together with anydeleteit chains onto that the server never saw.Everything is read from the workspace’s kept chain, so a delivery that failed or was held is retried by calling this again, also after the workspace was reopened (
FfiWorkspace::purged_asset_idslists what to walk). The workspace lock is held only while the chain is read, never across the network. Every record of the stretch is judged asapply_lifecycle_opjudges a foreign one before any is sent, so a kept chain whose records no longer verify sends nothing.server_headis asapply_lifecycle_optakes it:Nonesends nothing and answersFfiLifecycleOpOutcome::NotIndexed. The answer is the last record’sApplied— the purge reached the server — or the first record that was not applied, whoseFailedstops the stretch.The held rules are a live asset’s (
deliver_lifecycle_at_hash), judged by this device’s clock: a kept chain whose stretch holds atrash-restoreundoing adeletethe server never saw, whose window has closed, is withheld and answersFfiLifecycleOpOutcome::RestoreTooLate.Errors
Section titled “Errors”FfiError::TrashwithFfiTrashRefusal::NotFoundfor an asset this workspace has not purged;FfiError::InvalidArgumentfor a malformedasset_idorapi_base_url;FfiError::Workspacefor a kept chain whose records do not verify under the workspace’s device directory;FfiError::Authfor a refused session. -
suspend fun deliverPurgeAtHash(apiBaseUrl: kotlin.String, workspace: FfiWorkspace, assetId: kotlin.String, serverHeadHash: kotlin.ByteArray?): FfiLifecycleOpOutcome
Types:
FfiWorkspace,FfiLifecycleOpOutcomedeliver_purgewith the head the feed lists given by its record hash rather than its bytes: the SHA-256 of the latest entry’smanifest_cbor, which is the head record’s hash, so a caller keeps 32 bytes per listed asset instead of the record.Someof an empty vector is an entry that carries no record, andNonean asset the feed does not list, exactly asdeliver_purgereads itsserver_head.Errors
Section titled “Errors”As
deliver_purge, andFfiError::InvalidArgumentfor aserver_head_hashthat is neither empty nor 32 bytes, before anything is sent.
class
FfiTransferSubscription
Section titled “FfiTransferSubscription”open class FfiTransferSubscription: Disposable, AutoCloseable, FfiTransferSubscriptionInterfaceA live subscription to a session’s transfer events: every step published after it opened.
Obtained from FfiSession::transfer_events.
Pull with next until it answers None, which it does once the session that
publishes the events is gone.
Functions
-
suspend fun next(): FfiTransferFeedItem?
Types:
FfiTransferFeedItemThe next event, or how many were missed since the last pull;
Noneonce the session publishing them is gone, and from then on.Waits for an event when none is pending. Concurrent pulls take turns: each event is delivered to exactly one of them.
class
FfiWorkspace
Section titled “FfiWorkspace”open class FfiWorkspace: Disposable, AutoCloseable, FfiWorkspaceInterfaceA Capsule workspace, callable from Swift/Kotlin: the durable library at a filesystem root plus everything an app does with it.
Workspace mutates through &mut self while uniffi objects expose only &self; the
Mutex supplies the interior mutability and serializes concurrent foreign calls.
Functions
-
@Throws(FfiException::class) fun create(root: kotlin.String, passphrase: kotlin.ByteArray, tier: FfiDeviceTier, client: FfiClientBuild): FfiWorkspace
Types:
FfiException,FfiDeviceTier,FfiClientBuildEnroll: create a brand-new library at
root, guarded bypassphraseat the Argon2id cost fortier. Mints the account, the device key, and the signed device directory, and seeds the durable album keystore.clientis the app’s own build identity: every manifest this workspace authors then reportsclient_id/semver+commitrather than the barecapsule-coredefault. -
@Throws(FfiException::class) fun createWithHardwareSigner(root: kotlin.String, passphrase: kotlin.ByteArray, tier: FfiDeviceTier, hardware: FfiHardwareSigner, keyAlias: kotlin.String, mlSeed: kotlin.ByteArray, client: FfiClientBuild): FfiWorkspace
Enroll with a hardware-bound Ed25519 device key: as
create, but the classical half of the device signing key is produced byhardwareunderkey_aliasover Ed25519 (a 32-byte public key, 64-byte signatures). The post-quantum ML-DSA-65 half is the software-sealedml_seed(32 bytes).No shipping secure element holds Ed25519 keys, so this is the software/TPM reference composition; phones use
create_with_p256_hardware_signer. It is the same core call (HardwareBackedSigner::enroll) reached through this namespace’sFfiHardwareSignerseam. -
@Throws(FfiException::class) fun createWithP256HardwareSigner(root: kotlin.String, passphrase: kotlin.ByteArray, tier: FfiDeviceTier, hardware: FfiHardwareSigner, keyAlias: kotlin.String, mlSeed: kotlin.ByteArray, client: FfiClientBuild): FfiWorkspace
Enroll with a hardware-bound device key: as
create, but the classical half of the device signing key is produced byhardware(a native Secure Enclave / StrongBox / TPM element) underkey_alias, over ECDSA-P256 — the composition shipping secure elements actually provide, none of which do Ed25519. The post-quantum ML-DSA-65 half is the software-sealedml_seed(32 bytes).The published device key carries the P-256 tag and
verify_assetdispatches on it. The library records the binding (the alias,ml_seedsealed under the account master key, and the published key), so every later launch reopens it withopen_with_p256_hardware_signeron the same key; plainopenrefuses such a library. An element that refuses enrollment fails this call before anything is written underroot. -
@Throws(FfiException::class) fun open(root: kotlin.String, passphrase: kotlin.ByteArray, tier: FfiDeviceTier, client: FfiClientBuild): FfiWorkspace
Types:
FfiException,FfiDeviceTier,FfiClientBuildOpen the existing library at
rootunderpassphrase, restoring its album keys and authorities, every managed asset, and theadd_idcounter from disk. This is what makes an app relaunch resume rather than re-enroll. -
@Throws(FfiException::class) fun openWithP256HardwareSigner(root: kotlin.String, passphrase: kotlin.ByteArray, tier: FfiDeviceTier, hardware: FfiHardwareSigner, keyAlias: kotlin.String, client: FfiClientBuild): FfiWorkspace
Open the existing library at
rootasopendoes, re-attachinghardware, the element that holds this device’s P-256 signing key. Required for a library made bycreate_with_p256_hardware_signer: the element is asked for the key under the alias the library recorded, never to make a new one, and the rebuilt key must be the one this device published. An element that lost the key or is unavailable fails the open withFfiError::Workspacerather than letting the library sign with another key.The library’s record decides, not the caller: a library created with the software key opens on it and
hardwareis not used.key_aliasis used only whenrootholds a laid-out library with no account yet, whose fresh account is then enrolled under it. -
fun assetsByCull(flag: FfiCullFlag): List<kotlin.String>
Types:
FfiCullFlagThe managed, non-trashed assets currently carrying
flag, sorted.Neutralincludes the never-flagged ones. -
fun cullFlag(assetId: kotlin.String): FfiCullFlag
Types:
FfiCullFlagThe asset’s current flag:
Neutralwhen it was never flagged, and for an asset this workspace does not hold. -
fun flagStack(stackId: kotlin.String, flag: FfiCullFlag): List<kotlin.String>
Types:
FfiCullFlagFlag every non-trashed member of a stack, one
metadata-updateeach — flagging a collapsed stack flags its members, since a stack stores no flag of its own. Returns the members flagged, sorted; empty for a stack with no members. -
fun rejectSweep(retainDays: kotlin.UInt): List<kotlin.String>
The reject sweep: move every rejected, not-yet-trashed asset to the trash with a retention window of
retain_daysdays, and return the swept ids, sorted. Each is a signeddelete, restorable from the trash until its window closes. A refusal partway isFfiError::Trash; the assets swept before it stay in the trash, and a retried sweep moves the rest. -
fun setCull(assetId: kotlin.String, flag: FfiCullFlag)
Types:
FfiCullFlagFlag one asset.
Neutralclears a prior flag. Signs onemetadata-update, stamped with this device and now, so concurrent flags from two devices converge under LWW. -
fun stackCullState(stackId: kotlin.String): FfiStackCullState?
Types:
FfiStackCullStateA stack’s cull state, derived from its members on this read.
Nonefor a stack with no non-trashed members. -
fun stackMemberships(): List<FfiStackMember>
Types:
FfiStackMemberEvery managed, non-trashed asset that belongs to a stack, with its stack, whether it is the cover and its member index, sorted by asset id. An asset in no stack is absent, so a cull pass reads it as a lone asset; a trashed member is absent too, matching the members
flag_stackwrites. -
fun purgedAssetIds(): List<kotlin.String>
Every asset this workspace has purged (UUID strings), whose kept chain
purged_recordreads: the list a relaunch walks to deliver the purges whose delivery failed or was held, withFfiSession::deliver_purge. A purge the server already applied answers as a replay, so walking it again is safe. -
fun addLabel(target: FfiLabelTarget, label: kotlin.String): List<kotlin.String>
Types:
FfiLabelTargetAdd
labeltotargetand return its labels afterwards. -
fun addRegion(assetId: kotlin.String, shape: FfiRegionShape, labels: List<kotlin.String>): FfiRegion
Types:
FfiRegionShape,FfiRegionMark a region of
asset_idwith its firstlabels, and return it.Every label is checked before the region is written, so a refused label leaves no unlabelled region behind; then the shape, then the asset. A refusal writes nothing.
-
fun albums(): List<FfiAlbum>
Types:
FfiAlbumEvery album this workspace holds key material for, in the one album order every app shows as is: the album with the most recent visible, untrashed asset first, an empty album by its creation time, ties by ascending id (
Workspace::albums). -
fun applyHeldSyncEntry(entry: FfiSyncHead): FfiSyncApplyOutcome
Types:
FfiSyncHead,FfiSyncApplyOutcomeapply_sync_entry_from_filefor an entry of an asset this workspace holds, with no original fetched: the original is the one the held chain’s head commits to, which this workspace verified when it adopted or imported it.This is how a
deleteon an album page — which names no metadata blob and no blob — is applied to an asset held here: the delete binds no metadata blob and commits to the original the asset already has, so the same chokepoint and adoption as the apply verb verify it against the entry’slocal_chain_head, and the asset moves to this device’s trash. A record committing to another original than the held one is quarantined asRejected.CiphertextHashMismatch, and one that binds a metadata blob the entry does not carry is refused by the binding check: neither is adopted.Errors
Section titled “Errors”FfiError::InvalidArgumentfor a malformedalbum_idorlocal_chain_head;FfiError::Workspacewhen the record names an asset this workspace does not hold, or the workspace itself fails. A record that does not decode is a quarantined verdict, as the apply verb answers one. -
fun applySyncEntry(entry: FfiSyncEntry): FfiSyncApplyOutcome
Types:
FfiSyncEntry,FfiSyncApplyOutcomeSync-apply: verify one remote feed entry through the
verify_assetchokepoint, bind and decrypt its metadata blob, and return either the facts to upsert or a named quarantine/hold verdict.Never silently drops and never silently accepts: a refused entry is a
FfiSyncApplyOutcome::Quarantinedthe app must surface, not an error that aborts the page. Errors are reserved for a failure of this workspace itself.An applied record that chains onto an asset this workspace holds is adopted: appended to the asset’s chain with the metadata it binds, written and indexed, and the facts say so (
FfiAssetFacts::adopted). Acreateis adopted only byopen_synced_original, which has its original. -
fun applySyncEntryFromFile(entry: FfiSyncHead, ciphertextPath: kotlin.String): FfiSyncApplyOutcome
Types:
FfiSyncHead,FfiSyncApplyOutcomeapply_sync_entryfor an entry whose original ciphertext is the file atciphertext_path— the oneFfiSession::fetch_blob_to_pathwrote — read in memory bounded by one STREAM chunk whatever the original’s size.The same chokepoint and verdicts: the file is hashed, and that digest is what the content-integrity step checks against the manifest’s content address, so a file that is not the committed ciphertext is quarantined as
Rejected.CiphertextHashMismatch, asapply_sync_entryquarantines those bytes. The ciphertext file is only read.An applied record is adopted as
apply_sync_entryadopts one: adelete,trash-restoreor edit of an asset this workspace holds is appended to its chain, written undermedia/and indexed, and the facts say so (FfiAssetFacts::adopted).A malformed
album_idorlocal_chain_headis refused before the file is opened, so a bad argument never costs a read of the original. The file is hashed before the workspace is locked, so other verbs are not held up while a large original is read. -
fun assetIds(): List<kotlin.String>
Every managed asset id (UUID strings).
-
fun createAlbum(name: kotlin.String): kotlin.String
Create an album (minting AMK_v1, its write-tier and admin keys, and an attested authority, then persisting the keystore). Returns the album id.
-
fun defaultAlbumId(): kotlin.String
The default album’s id, derived deterministically from the account master key — so every device of this account computes the same value with nothing to synchronize.
-
fun deleteAsset(assetId: kotlin.String, retainDays: kotlin.UInt): FfiTrashEntry
Types:
FfiTrashEntryMove an asset to the trash: sign a
deletewhose retention window isretain_daysdays from now, and return its trash entry. An asset already in the trash keeps the window it was deleted with and signs nothing, so a retried delete never extends it. -
fun deleteRegion(assetId: kotlin.String, regionId: kotlin.String)
Delete a region. Final: a concurrent or later edit of it on another device does not bring it back once the two merge, and its id is never live again.
-
fun deviceId(): kotlin.String
This device’s id (UUID string) — the
created_by_deviceof every manifest it authors, and the id to report as the session’sdevice_id. -
fun ensureAlbum(albumId: kotlin.String, name: kotlin.String): kotlin.String
Resolve
album_idto the album this workspace already holds, or create it undername. This is the verb first-run wiring wants for the default album: it is idempotent across relaunches, wherecreate_albumwould refuse. -
fun escrowBlob(recoverySecret: kotlin.ByteArray, tier: FfiDeviceTier): kotlin.ByteArray
Types:
FfiDeviceTierMint the master-key escrow blob under
recovery_secret, as opaque canonical CBOR — the bytesFfiSession::escrow_putstores.The master key never crosses this boundary: it is wrapped inside
capsule-coreand only the wrapped blob comes out.recovery_secretis the ≥128-bit secret shown to the user exactly once at first-device enrollment. -
fun expiredTrash(drain: FfiFeedDrain?): List<FfiTrashEntry>
Types:
FfiFeedDrain,FfiTrashEntryThe trash entries whose signed retention window has closed: the retention sweep’s input, each one ready for
purge_asset.A deadline is judged only after a sync drained the feed to its head, so a restore on a later page lands first: pass that drain as
drain, itsserver_headscovering the whole feed asFfiFeedDrain::server_headsrequires. The deadline is judged by the drain’s latest serverchanged_atalone, never by this device’s clock, and an asset whosedeletethe server has not indexed (a held delete) never expires. With no drain (None: the sync failed, or this device has no server), or a drain that saw no entry, nothing has expired, and the trash keeps every asset until the user empties it.Errors
Section titled “Errors”FfiError::InvalidArgumentfor alatest_changed_atthat is not RFC 3339. -
fun labels(target: FfiLabelTarget): List<kotlin.String>
Types:
FfiLabelTargetThe labels
targetcarries, sorted. An unknown target isFfiError::LabelwithFfiLabelRefusal::NotFound. -
fun openSyncedHistory(entry: FfiSyncHead, history: List<kotlin.ByteArray>, ciphertextPath: kotlin.String, destinationPath: kotlin.String): FfiOpenedOriginal
Types:
FfiSyncHead,FfiOpenedOriginalopen_synced_originalfor an asset this workspace does not hold and first sees past its create, withhistorythe records before the entry’s, oldest first from the create — whatFfiSession::fetch_provenance_historyreturns for the entry’smanifest_cbor.The entry is applied against the last record of
history, whatever itslocal_chain_headsays, and its original opened fromciphertext_pathasopen_synced_originalopens one. Then every record ofhistoryis verified through the chokepoint in order from the create, the sidecar is opened from the entry’smetadata_blob(the asset’s live one, which the server’s metadata role names: a superseded metadata blob is collected), and the asset is adopted, held from its create with the opened original as its library copy. The facts say whether it was (FfiAssetFacts::adopted); a held asset’sdelete,trash-restoreor edit then works on this device as on one it imported.An entry that names no metadata blob or original — a
deleteon an album page, the surface a writer member’s device reads — is opened the same way once they are fetched:synced_history_sourcesnames both from the entry andhistory, the fetched metadata blob goes in the entry’smetadata_blob, and the fetched original isciphertext_path. Left empty, themetadata_blobbinds to nothing and the entry is refused.A history that does not verify, or a live metadata blob that does not bind, is
FfiOpenedOriginal::Refusedwith the verdict that refused it, anddestination_pathis untouched: the original is placed there only once the asset it belongs to verifies from its create. An emptyhistoryisopen_synced_original, and so is an entry of an asset this workspace already holds: its history is not read, so none of its records can refuse the entry, and the entry is applied against its ownlocal_chain_head.Errors
Section titled “Errors”As
open_synced_original; an adoption whose write failed leaves nothing atdestination_path. -
fun openSyncedOriginal(entry: FfiSyncHead, ciphertextPath: kotlin.String, destinationPath: kotlin.String): FfiOpenedOriginal
Types:
FfiSyncHead,FfiOpenedOriginalOpen a synced original from the ciphertext file at
ciphertext_pathto its plaintext atdestination_path, in memory bounded by a few STREAM chunks whatever its size.The entry goes through the chokepoint as
apply_sync_entry_from_filewould take it, then the file is hashed while it is decrypted: it opens only if it is the ciphertext the manifest commits to, every chunk authenticates, and the plaintext hashes to the signed sidecar’s digest. The plaintext is written to a hidden staging file beside the destination and renamed into place only once all of that holds, sodestination_pathis untouched by any other verdict and never holds a partial or unverified original. An existing file there is replaced only by a verified one.An opened entry is then adopted: a
createof an asset this workspace does not hold makes it held, with its chain, sidecar and sealed metadata written undermedia/, the opened original copied there as its own library copy, and its row and user tags indexed; a later record of a held asset is appended asapply_sync_entry_from_fileappends one. The facts say whether it was (FfiAssetFacts::adopted).destination_pathstill holds the plaintext either way, for the caller to keep or remove.The workspace stays locked while the original decrypts and is adopted.
Errors
Section titled “Errors”FfiError::Workspacewhen a file cannot be read or written, or the workspace itself fails (an adoption whose write failed included, after the original was placed atdestination_path);FfiError::InvalidArgumentfor a malformed entry or a destination with no file name. A refused entry is a verdict, never an error. -
fun provenanceHead(assetId: kotlin.String): kotlin.ByteArray
The asset’s head provenance record as opaque canonical CBOR — the exact bytes the
provenanceblob carries, the feed serves back asmanifest_cbor, and a receiving device runs throughapply_sync_entry.The record wraps the head signed manifest with its chain position. That wrapper is not optional: the server’s chain head is the SHA-256 of these bytes while a client’s next
prior_provenance_hashis the record’s own hash, so the bare manifest is the one encoding under which no lifecycle op can ever chain. Canonical CBOR is deterministic, so the manifest inside is byte-identical to its own signed bytes — nothing is re-authored and the two signatures still verify over exactly what they covered.Use
signed_manifestwhen the manifest is what is wanted. -
fun purgeAsset(assetId: kotlin.String): FfiPurgeOutcome
Types:
FfiPurgeOutcomePermanently delete a trashed asset: its original, every derivative and local cache entry, its sidecar and its index row. The provenance chain is kept as the record of the deletion. Before
retention_untila signed shorter-retentiondeleteis appended first and handed back inFfiPurgeOutcome::reissue_recordto send to the server. -
fun purgedRecord(assetId: kotlin.String): kotlin.ByteArray?
The signed
deletethat ended a purged asset, the head of its kept provenance chain, as the opaque canonical CBOR recordFfiPurgeOutcome::reissue_recordcarries. After an early purge it is that same re-issue, so a delivery to the album’s ops surface that failed can be resent from here, also after a reopen (FfiSession::apply_lifecycle_op, orFfiSession::deliver_purgefor the whole stretch).Nonefor an asset this workspace has not purged. -
fun readPlaintext(assetId: kotlin.String): kotlin.ByteArray
The plaintext bytes of a managed asset (what a gallery renders for a locally-held original).
-
fun regions(assetId: kotlin.String): List<FfiRegion>
Types:
FfiRegionThe asset’s live regions, oldest first.
-
fun removeLabel(target: FfiLabelTarget, label: kotlin.String): List<kotlin.String>
Types:
FfiLabelTargetRemove
labelfromtarget(every add of it this device has observed) and return its labels afterwards. A label the target does not carry writes nothing and answers the unchanged list. -
fun restoreAsset(assetId: kotlin.String)
Restore an asset from the trash: sign a
trash-restore. Refused withFfiTrashRefusal::RetentionElapsed(and theerror.upload.retention_elapsedcode) at or after the signedretention_until, and withFfiTrashRefusal::NotInTrashfor an asset that is not in the trash. -
fun sealAsset(albumId: kotlin.String, fileName: kotlin.String, bytes: kotlin.ByteArray): kotlin.String
Seal + import: take bytes the app already holds (a PhotoKit / MediaStore export), derive the file key, STREAM-encrypt, author and sign the create manifest, seal the signed sidecar into its metadata blob, append the provenance chain, and self-verify through the
verify_assetchokepoint. Returns the asset id.file_nameis consulted for its extension and nothing else. One call, one core call: the whole sealing order iscapsule-core’s. -
fun signedDeviceDirectory(): kotlin.ByteArray
This workspace’s signed device directory as opaque canonical CBOR — the bytes
FfiSession::publish_device_directorysends. Until this is published, every asset this device signs is an unknown device to every other device, so first-device enrollment publishes before it uploads. -
fun signedManifest(assetId: kotlin.String): kotlin.ByteArray
The asset’s head signed manifest as opaque canonical CBOR.
This is a serialization of an already-signed structure, not a re-authoring: the two signatures the manifest carries are covered by these bytes, which is why they travel verbatim and are never re-modeled on any wire.
Not what the sync feed carries — that is
provenance_head, the record that wraps this manifest with its chain position. Handing these bytes toapply_sync_entryis refused as malformed. -
fun trash(): List<FfiTrashEntry>
Types:
FfiTrashEntryEvery asset in the trash with its signed retention window, most recently deleted first.
This is the retention data, not the Recently Deleted view: a surface that shows the trash still opens it behind the SR1 fresh-local-auth gate, as
Catalog::query_trashdoes. -
fun uploadBlobs(assetId: kotlin.String): List<FfiUploadBlob>
Types:
FfiUploadBlobEverything needed to push one sealed asset, in ladder order: for each blob, the
POST /uploadbody (manifest envelope projected per the server’s invariant-15 rule) and the bytes. Feed each straight toFfiSession::upload.The index tier (
T0) is two blobs — the provenance record then the sealed metadata blob — because the server publishes an asset to other devices only once it holds both roles. Push all of them: an app that stopped after the metadata blob would upload an asset no device, its own included, could ever see.The original’s ciphertext is re-derived from the manifest’s recorded nonce prefix and gated on the manifest’s own content address, so what reaches the network is what the signed manifest vouches for.
Every blob comes back whole, the original included. To push without holding the original in memory, use
FfiSession::push_asset.Building the bundle records the original’s upload source guard; once every blob is materialised nothing re-derives the original from this bundle again, so the guard is released before the blobs are returned. A later call re-verifies the plaintext against the signed content address and records it afresh.
-
fun userId(): kotlin.String
The account owner’s user id (UUID string).
-
fun userIkPublic(): kotlin.ByteArray
This account’s user identity public key — the pin a fetched device directory is verified against.
-
fun verifyAsset(assetId: kotlin.String): FfiVerifyOutcome
Types:
FfiVerifyOutcomeRun the
verify_assetchokepoint over a managed asset, regenerating its ciphertext deterministically. This is the same single chokepoint sync-apply routes through — it is exposed here so an app can re-check its own library (an integrity sweep), never as a second verification path. -
fun verifyEscrowBlob(blob: kotlin.ByteArray, recoverySecret: kotlin.ByteArray): kotlin.Boolean
Local, network-free check that
recovery_secretstill opensblobto this device’s master key — the recovery verification cadence’s predicate.blobis the canonical CBORFfiSession::escrow_getreturns.A
falseis not necessarily a wrong secret: the cached blob may be stale after a rotation on another device, so refresh it and re-check once before telling the user anything.
Interfaces
Section titled “Interfaces”interface
FfiHardwareKeyAgreement
Section titled “FfiHardwareKeyAgreement”public interface FfiHardwareKeyAgreementThe per-platform key-agreement element (Secure Enclave P256.KeyAgreement, StrongBox
ECDH, TPM 2.0 ECDH), implemented by native Swift/Kotlin over the uniffi foreign-trait
boundary — the ECDH analogue of FfiHardwareSigner, and this namespace’s declaration of
capsule-core’s HardwareKeyAgreement contract.
It backs the hardware-bound classical half of the device encryption key:
the element holds a static P-256 private key and performs the ECDH, so the scalar never
leaves hardware, while Rust drives the software-sealed ML-KEM-768 half and the hybrid
combiner. Failures reuse FfiHardwareSignerError, exactly as core’s trait reuses its
signer error.
Functions
-
fun enroll(keyAlias: kotlin.String): kotlin.ByteArray
Generate (or bind to) the hardware P-256 key-agreement keypair for
key_alias, returning its public key as uncompressed SEC1 (0x04‖x‖y, 65 bytes). Idempotent per alias. -
fun publicKey(keyAlias: kotlin.String): kotlin.ByteArray
The uncompressed-SEC1 P-256 public key for an already-enrolled
key_alias. -
fun keyAgreement(keyAlias: kotlin.String, peerPublic: kotlin.ByteArray): kotlin.ByteArray
ECDH against
peer_public(the sender’s ephemeral P-256 public key, uncompressed SEC1) with the hardware key forkey_alias, returning the raw 32-byte shared secret (the big-endian x-coordinate, before any KDF). -
fun assertNonExportable(keyAlias: kotlin.String)
Non-exportability assertion: a conforming element MUST refuse to reveal the private bytes, returning
FfiHardwareSignerError::Exportableif they can be read.
interface
FfiHardwareSigner
Section titled “FfiHardwareSigner”public interface FfiHardwareSignerThe per-platform secure element (Secure Enclave, StrongBox, TPM), implemented by native Swift/Kotlin over the uniffi foreign-trait boundary.
The byte shapes are fixed by the constructor the element is handed to, not by the trait:
FfiWorkspace::create_with_p256_hardware_signerandFfiWorkspace::open_with_p256_hardware_signer— the P-256 shape shipping elements actually provide:enroll/classical_public_keyreturn a SEC1 public key andsign_classicala DER-encoded ECDSA signature overSHA-256(msg).FfiWorkspace::create_with_hardware_signer— the Ed25519 shape: a 32-byte public key and a 64-byte signature overmsg. No shipping secure element holds Ed25519 keys, so this is the software/TPM reference path.
Either way Rust composes the classical half with a software-sealed ML-DSA-65 half into the published hybrid device key.
Functions
-
fun enroll(keyAlias: kotlin.String): kotlin.ByteArray
Generate (or bind to) the hardware keypair for
key_alias, returning its public key in the constructor’s shape: a SEC1 P-256 key forFfiWorkspace::create_with_p256_hardware_signer, a 32-byte Ed25519 key forFfiWorkspace::create_with_hardware_signer. Idempotent per alias. -
fun classicalPublicKey(keyAlias: kotlin.String): kotlin.ByteArray
The public key for an already-enrolled
key_alias, in the same constructor-dependent shapeenrollreturns (SEC1 P-256, or 32-byte Ed25519). -
fun signClassical(keyAlias: kotlin.String, msg: kotlin.ByteArray): kotlin.ByteArray
Sign
msgwith the hardware key forkey_alias, in the constructor’s shape: a DER-encoded ECDSA signature overSHA-256(msg)forFfiWorkspace::create_with_p256_hardware_signer, a 64-byte Ed25519 signature overmsgforFfiWorkspace::create_with_hardware_signer. -
fun assertNonExportable(keyAlias: kotlin.String)
Non-exportability assertion: a conforming element MUST refuse to reveal the private bytes, returning
FfiHardwareSignerError::Exportableif they can be read.
Data classes
Section titled “Data classes”data class
FfiAlbum
Section titled “FfiAlbum”data class FfiAlbumOne album this workspace holds key material for.
Properties
data class
FfiAlert
Section titled “FfiAlert”data class FfiAlertOne alert that is true at an instant.
Never a localized string: class selects the app’s own notification.* catalog key and
params are interpolated into it, so a server can neither supply nor influence the words a
user reads.
Properties
-
var class: FfiAlertClass
Types:
FfiAlertClassWhich alert this is.
-
var severity: FfiAlertSeverity
Types:
FfiAlertSeverityHow prominently to present it.
-
var deadline: kotlin.String?
The instant whose passing made this alert true (RFC 3339), for the two pre-armable classes;
Nonefor the three whose condition is server-held. -
var params: Map<kotlin.String, kotlin.String>
Catalog parameters —
count,days_behind,grace, and the pairrecovery_check_duealways carries:snooze_budget(available/spent) andrecovery(check/rewrap).
data class
FfiAssetFacts
Section titled “FfiAssetFacts”data class FfiAssetFactsThe verified facts one applied entry contributes, flattened for a catalog upsert.
Properties
-
var assetId: kotlin.String
The asset id (UUID string).
-
var albumId: kotlin.String
The album id (UUID string).
-
var amkVersion: kotlin.UInt
The AMK epoch the asset is sealed under.
-
var ciphertextHash: kotlin.String
The original’s ciphertext content address (lowercase hex).
-
var plaintextSize: kotlin.ULong
The original’s plaintext length in bytes.
-
var action: kotlin.String
The head manifest’s lifecycle action (
create,metadata-update,delete, …). -
var timestamp: kotlin.String
RFC3339 authoring timestamp of the head manifest.
-
var createdByDevice: kotlin.String
The device that authored it (UUID string), resolved in the signed device directory.
-
var provenanceHead: kotlin.ByteArray
The 32-byte provenance head this entry establishes — persist it and pass it back as
FfiSyncEntry::local_chain_headnext time. -
var metadata: FfiAssetMetadata?
Types:
FfiAssetMetadataThe decrypted, signature-checked metadata.
Noneexactly when the action mints no metadata blob — adeletetombstone or atrash-restore. Those are fully-verified entries that simply carry no metadata, so an app applies the lifecycle change and leaves the row’s metadata as it stands. -
var adopted: kotlin.Boolean = false
Whether this workspace now holds the asset at this entry’s record: it adopted the entry, writing the asset’s chain, sidecar, sealed metadata and original under
media/and its index row and user tags into the library catalog, so the trash verbs and tag edits work on it. Whentruethe catalog already describes the asset and an app writes nothing of its own for it; whenfalse(an asset first seen past its create, a fork, or a verb that applies without adopting) the facts are the app’s to upsert. An asset first seen past its create is adopted from its earlier records:FfiSession::fetch_provenance_history, thenFfiWorkspace::open_synced_history.
data class
FfiAssetMetadata
Section titled “FfiAssetMetadata”data class FfiAssetMetadataThe decrypted sidecar’s facts, flattened for a catalog upsert.
Properties
-
var sidecarSchema: kotlin.UShort
Sidecar schema version.
-
var contentType: kotlin.String
The original’s MIME type.
-
var captureTimestamp: kotlin.String
RFC3339 capture time the asset is dated by: the user’s correction when one is recorded, else the as-imported value.
-
var width: kotlin.UInt?
Pixel width, when the sidecar records dimensions.
-
var height: kotlin.UInt?
Pixel height, when the sidecar records dimensions.
-
var lqipChromahash: kotlin.ByteArray?
LQIP chromahash bytes — renderable the instant metadata syncs, at zero extra request.
-
var lqipDominantColor: kotlin.ByteArray?
LQIP dominant colour, as three RGB bytes.
-
var caption: kotlin.String?
The caption LWW register’s current value, if any.
-
var tags: List<kotlin.String>
The user-tag OR-set’s current members, sorted.
-
var rating: kotlin.UByte?
The rating LWW register’s current value, if any.
-
var hidden: kotlin.Boolean
Whether the asset is hidden from default views.
data class
FfiBlobManifest
Section titled “FfiBlobManifest”data class FfiBlobManifestFFI mirror of BlobManifest — an asset’s blobs by role.
Properties
-
var original: FfiBlobRef?
Types:
FfiBlobRefThe original ciphertext blob, when this entry carries one.
-
var derivatives: List<FfiBlobRef>
Types:
FfiBlobRefDerivative / metadata / provenance blobs.
data class
FfiBlobRef
Section titled “FfiBlobRef”data class FfiBlobRefFFI mirror of BlobRef — a blob’s content address and role.
Properties
-
var ciphertextHash: kotlin.String
Ciphertext content address (lowercase hex).
-
var role: kotlin.String
original | metadata | derivative | provenance. -
var size: kotlin.ULong
Ciphertext size in bytes.
data class
FfiClassDeadline
Section titled “FfiClassDeadline”data class FfiClassDeadlineOne class and the instant its local notification should be armed for.
A class absent from pre_arm_deadlines’s result has no timer to hold: cancel whatever it
has.
Properties
-
var class: FfiAlertClass
Types:
FfiAlertClassThe class whose timer this is — also the
notification.*catalog key the app renders when it fires. -
var deadline: kotlin.String
When to fire it (RFC 3339).
data class
FfiClientBuild
Section titled “FfiClientBuild”data class FfiClientBuildA foreign client’s self-reported build identity: its product id and own semver.
The git commit + dirty flag come from the core this app links, together composing the
client_id/semver+commit client_version every manifest carries — so a defect in a shipped
app build is traceable across the assets it produced.
Properties
data class
FfiEmbeddedPreview
Section titled “FfiEmbeddedPreview”data class FfiEmbeddedPreviewA RAW original’s embedded JPEG, as embedded_preview reads it.
Properties
-
var jpeg: kotlin.ByteArray
The JPEG exactly as the RAW file carries it.
-
var width: kotlin.UInt
Upright width in pixels, once
orientationis applied. -
var height: kotlin.UInt
Upright height in pixels.
-
var orientation: kotlin.UShort
The EXIF orientation (1..=8) to apply to
jpeg’s stored pixels, in place of any tag the JPEG itself carries.
data class
FfiEscrowStored
Section titled “FfiEscrowStored”data class FfiEscrowStoredFFI mirror of EscrowStored — what FfiSession::escrow_put did.
Properties
-
var storedAt: kotlin.String
When the server accepted the blob, RFC 3339, on the server’s clock.
-
var replaced: kotlin.Boolean
Whether this displaced an earlier escrow:
falseis a first enrollment (recovery set up),truea replacement (the previous recovery secret has stopped working).
data class
FfiFeedDrain
Section titled “FfiFeedDrain”data class FfiFeedDrainA sync that drained the feed to its head, the evidence FfiWorkspace::expired_trash
needs before it judges a retention deadline.
Properties
-
var latestChangedAt: kotlin.String?
The latest server
changed_atthe drain saw (RFC 3339), orNonefor a drain that saw no entry. Deadlines are judged at it alone, never by this device’s clock, so withNonenothing has expired. -
var serverHeads: Map<kotlin.String, kotlin.ByteArray>
Every asset the server’s feed lists, keyed by its id as the feed names it, with the
manifest_cborof its latest entry (empty for an entry that carries no record). An asset whose latestdeleteis not that head or before it is a held delete, which never expires. Ids that are not UUIDs name no asset of this workspace and are ignored.The map must cover the whole feed: a drain from the feed’s start (no cursor), or the heads this app kept, entry by entry, across every cursored drain since one. A drain resumed from a cursor lists only the assets that changed after it, so passing it alone leaves out every asset whose
deletean earlier sync indexed: each is judged held and never expires, and the trash grows until the user empties it. That loses nothing, but the sweep stops working.
data class
FfiFeedEntry
Section titled “FfiFeedEntry”data class FfiFeedEntryFFI mirror of FeedEntry — one decoded sync feed entry. Ids/manifest/metadata
cross as opaque bytes.
Properties
-
var albumId: kotlin.ByteArray
The album this entry belongs to.
-
var syncSeq: kotlin.ULong
Per-album, strictly-increasing anti-rewind high-water mark.
-
var protocolVersion: kotlin.String
The album protocol pin (
YYYY-MM-DD). -
var kind: FfiChangeKind
Types:
FfiChangeKindWhat changed.
-
var assetId: kotlin.ByteArray
The asset id.
-
var manifestCbor: kotlin.ByteArray
The signed
AssetManifestas opaque canonical CBOR. -
var metadataBlob: kotlin.ByteArray
The encrypted metadata blob’s content address, as UTF-8 bytes. On a delete in trash, the asset’s live metadata blob, which a restore needs; empty for a purged delete.
-
var blobs: FfiBlobManifest
Types:
FfiBlobManifestContent addresses of the asset’s blobs by role. On a delete in trash, only its original; none for a purged delete.
-
var originalHeld: kotlin.Boolean
Whether the original blob is finalized server-side.
-
var changedAt: kotlin.String
When the change happened, RFC 3339, on the server’s clock.
data class
FfiHistorySources
Section titled “FfiHistorySources”data class FfiHistorySourcesFFI mirror of HistorySources: the blobs adopting an asset
from its fetched history needs beyond its records.
Properties
-
var metadataBlobHash: kotlin.String
The asset’s live metadata blob’s content address (lowercase hex), for
FfiSession::fetch_metadata_blob; its bytes are theFfiSyncHead::metadata_blobFfiWorkspace::open_synced_historytakes. -
var original: FfiBlobRef
Types:
FfiBlobRefThe original the head commits to, role
original, sized forFfiSession::fetch_blob_to_path; that file is theciphertext_pathFfiWorkspace::open_synced_historytakes.
data class
FfiLocalHoldings
Section titled “FfiLocalHoldings”data class FfiLocalHoldingsWhat this device holds for the asset. Flat, like FfiNotifyInput: an embedded preview
is present when both of its dimensions are.
Properties
-
var held: List<FfiRepresentation>
Types:
FfiRepresentationThe encoded tiers and the original held locally; the LQIP is implied.
-
var embeddedPreviewWidth: kotlin.UInt?
The embedded preview’s upright width, from
embedded_preview. -
var embeddedPreviewHeight: kotlin.UInt?
The embedded preview’s upright height.
data class
FfiManifestEnvelope
Section titled “FfiManifestEnvelope”data class FfiManifestEnvelopeFFI mirror of ManifestEnvelope — the server-visible envelope fields the
import pipeline builds and signs; opaque to this layer, carried verbatim.
Properties
-
var cryptoSuiteId: kotlin.UShort
Crypto suite the blob is sealed under.
-
var protocolVersion: kotlin.String
Protocol date (
YYYY-MM-DD). -
var albumId: kotlin.String?
Optional album this blob belongs to.
-
var fileId: kotlin.String
The asset id this blob belongs to (UUIDv7).
-
var amkVersion: kotlin.UInt
AMK epoch the blob is sealed under.
-
var ciphertextHash: kotlin.String
Ciphertext content hash, lowercase hex.
-
var plaintextSize: kotlin.ULong
Plaintext size in bytes.
-
var chunkSize: kotlin.UInt
STREAM plaintext chunk size.
-
var keyMode: kotlin.String
derived | wrapped. -
var metadataBlobHash: kotlin.String?
Hash of the bundle’s metadata blob, when known.
-
var derivativeRole: kotlin.String?
A derivative blob’s role (
thumbnail | preview | embedding);Nonefor every other blob. -
var derivativeFormat: kotlin.String?
A derivative blob’s format, e.g.
image/jxl; set exactly whenderivative_roleis. -
var createdByUser: kotlin.String
The authoring user.
-
var createdByDevice: kotlin.String
The authoring device.
-
var clientVersion: kotlin.String
The exact client build.
-
var timestamp: kotlin.String
RFC 3339 authoring timestamp.
-
var action: kotlin.String
Lifecycle action (
createfor a fresh bundle). -
var priorProvenanceHash: kotlin.String?
Prior provenance hash, for append-only chains.
-
var retentionUntil: kotlin.String?
Optional retention floor.
data class
FfiNotifyInput
Section titled “FfiNotifyInput”data class FfiNotifyInputThe device-held state the predicate decides from, flattened for the bindings.
Counts and instants only — no album id, no title, no asset id. An all-default value (every
Option None, every count 0, an empty map) is the “just installed, learned nothing”
input, and yields no alerts and no deadline.
Properties
-
var lastCompletedSync: kotlin.String? = null
When the last completed sync finished (RFC 3339).
Noneon a device that has never completed one — which raises nosync_stale, because the alert is about a stale sync and not a missing one. WhenNone,unsynced_changesis ignored. -
var unsyncedChanges: kotlin.ULong = 0uL
Changes still waiting to reach the server, including originals still pending under a staged upload policy.
-
var recoveryNextDue: kotlin.String? = null
When the next recovery-verification prompt becomes due (RFC 3339). Project it from the scheduler with
RecoveryCadence::notify_factsrather than computing it here.Nonebefore recovery is set up, which ignores the other threerecovery_*fields. -
var recoverySnoozedUntil: kotlin.String? = null
When an active snooze on the recovery prompt expires (RFC 3339), if one is active. A snooze ending before
recovery_next_duedoes not make the check due earlier. This is the canonical place to snooze the recovery check — notsuppressed_until, which is for the other five classes. -
var recoverySnoozeBudgetSpent: kotlin.Boolean = false
Whether the consecutive-snooze budget is spent — the class has degraded to a persistent, non-blocking badge: still reported, no longer pre-armed.
-
var recoveryRewrapDue: kotlin.Boolean = false
Whether the scheduler has escalated to the guided re-wrap (repeated failures, or the user declaring the secret lost). Surfaces as the alert’s
recoveryparameter, so the app routes into the re-wrap flow instead of rendering a routine verification prompt. -
var quotaState: FfiQuotaAdvisory? = null
Types:
FfiQuotaAdvisoryThe state from the last
GET /v1/quota.Nonebefore the first one. -
var quarantinePending: kotlin.ULong = 0uL
How many items sit on the client’s quarantine surfaces awaiting a human. Excludes pending drops — they have their own class, so counting them here raises both.
-
var dropsPending: kotlin.ULong = 0uL
How many guest drops are awaiting review and adoption.
-
var suppressedUntil: Map<kotlin.String, kotlin.String> = mapOf()
Per-class snooze: class wire name (
sync_stale, …) to the RFC 3339 instant the snooze runs until, exclusive. A class snoozed pastnowreports nothing, and its alarm is deferred to the snooze end rather than cancelled — a class snoozed after it fired must fire again when the snooze expires. Usedisabledto turn a class off; do not encode that as a far-future instant here. An unrecognized class name is anFfiError::InvalidArgument.This map is for the other five classes. Recovery snoozing belongs in
recovery_snoozed_until, which the cadence scheduler owns together with the budget that bounds it. An entry here forrecovery_check_dueis honoured as a fallback (the later of the two wins) but is not the canonical channel. -
var disabled: List<kotlin.String> = listOf()
Per-class disable: the wire names of the classes the user turned off. They report nothing and hold no alarm, at any instant. Disabling suppresses the warning and never the behavior. An unrecognized class name is an
FfiError::InvalidArgument.
data class
FfiPathSnapshot
Section titled “FfiPathSnapshot”data class FfiPathSnapshotOne sample of the path as the app’s OS listeners report it.
Flat, like FfiNotifyInput: background_deadline_ms present
means the app runs in a background task the OS ends that many milliseconds from now; absent
means the foreground.
Properties
-
var cost: FfiPathCost
Types:
FfiPathCostWhat the path costs.
-
var reachable: kotlin.Boolean
Whether the OS reports a usable path.
-
var interface: FfiPathInterface
Types:
FfiPathInterfaceThe interface the path runs over.
-
var power: FfiPowerState
Types:
FfiPowerStateThe device’s power source.
-
var thermal: FfiThermalState
Types:
FfiThermalStateThe device’s thermal state.
-
var backgroundDeadlineMs: kotlin.ULong?
Milliseconds before the OS ends the background task the app runs in;
Nonein the foreground.
data class
FfiPurgeOutcome
Section titled “FfiPurgeOutcome”data class FfiPurgeOutcomeWhat a FfiWorkspace::purge_asset did.
Properties
-
var assetId: kotlin.String
The purged asset (UUID string).
-
var reissueRecord: kotlin.ByteArray?
The signed shorter-retention
deletean early purge appended, as the opaque canonical CBOR provenance recordFfiWorkspace::provenance_headwould have returned. It goes to the album’s ops surface so the server may purge too, throughFfiSession::deliver_purge, which sends it with anydeleteit chains onto that the server never saw; when that delivery fails,FfiWorkspace::purged_recordhands the same record back from the kept chain.Nonewhen the window had closed.
data class
FfiPushReport
Section titled “FfiPushReport”data class FfiPushReportWhat FfiSession::push_asset did — FFI mirror of AssetPushReport.
Properties
-
var assetId: kotlin.String
The asset id (UUID string).
-
var pushed: List<FfiPushedBlob>
Types:
FfiPushedBlobEvery blob whose session was opened, in ladder order.
-
var bytes: kotlin.ULong
Total bytes handed to the upload client, the original included.
-
var deferred: kotlin.UInt
Blobs the reported path held back (
FfiSession::set_path): push the asset again once the path allows them. Zero when the whole ladder ran.
data class
FfiPushedBlob
Section titled “FfiPushedBlob”data class FfiPushedBlobHow one blob of a pushed asset resolved — FFI mirror of PushedBlob.
Properties
-
var tier: kotlin.String
The ladder tier the blob occupies (
index/preview/original), the vocabularyFfiUploadBlob::tieruses. -
var hash: kotlin.String
The blob’s content address (lowercase hex).
-
var outcome: FfiUploadOutcome
Types:
FfiUploadOutcomeWhether it transferred or merged onto a blob the server already held.
data class
FfiRegion
Section titled “FfiRegion”data class FfiRegionOne live region of an asset and its labels.
Properties
-
var regionId: kotlin.String
The region id (UUIDv7, minted fresh per create, never reused).
-
var shape: FfiRegionShape
Types:
FfiRegionShapeThe outline.
-
var labels: List<kotlin.String>
The region’s labels, sorted.
data class
FfiRenderRequest
Section titled “FfiRenderRequest”data class FfiRenderRequestA surface’s request: its intent and its size in device pixels when the view opened.
Properties
-
var intent: FfiRepresentation
Types:
FfiRepresentationThe rung the surface’s intent needs:
Thumbnailfor the grid,Previewfor the single-asset view,Originalfor a full-fidelity view. -
var surfaceWidth: kotlin.UInt
The surface’s width when the view opened. A view that grows keeps passing this.
-
var surfaceHeight: kotlin.UInt
The surface’s height when the view opened.
data class
FfiRenderStep
Section titled “FfiRenderStep”data class FfiRenderStepThe answer to one render_step.
Properties
-
var show: FfiRendition
Types:
FfiRenditionWhat to show now.
-
var changed: kotlin.Boolean
Whether
showdiffers from theshownpassed in. -
var next: FfiNextStep?
Types:
FfiNextStepWhat to obtain next, or
Nonewhen the intent is met or nothing can raise it.
data class
FfiRendition
Section titled “FfiRendition”data class FfiRenditionWhat a surface shows: a rung and its source. The caller keeps the last one and passes it
back as shown.
Properties
-
var rung: FfiRepresentation
Types:
FfiRepresentationThe rung shown.
-
var source: FfiRungSource
Types:
FfiRungSourceWhat fills it.
data class
FfiStackMember
Section titled “FfiStackMember”data class FfiStackMemberWhere one live asset sits in its stack, read from its signed stack_membership register.
Properties
-
var assetId: kotlin.String
The asset (UUID string).
-
var stackId: kotlin.String
The stack it belongs to (UUID string).
-
var isCover: kotlin.Boolean
Whether it is the stack’s cover: its
primarymember, the “best photo”. -
var memberIndex: kotlin.UInt?
Its position within the stack (burst sequence, chapter index), when one was recorded.
data class
FfiStampedTransferEvent
Section titled “FfiStampedTransferEvent”data class FfiStampedTransferEventA transfer event and when it arrived: milliseconds since the subscription opened, on a monotonic clock.
Properties
-
var atMs: kotlin.ULong
Milliseconds since the subscription opened.
-
var event: FfiTransferEvent
Types:
FfiTransferEventThe event.
data class
FfiSyncEntry
Section titled “FfiSyncEntry”data class FfiSyncEntryOne remote feed entry to apply, as a sync feed delivers it.
album_id and the two id-bearing fields carry the feed’s own 16-byte UUID form (the
bytes album_id of capsule.sync.v1.SyncEntry), so an entry from
FfiSession::sync_pull is passed through unchanged.
Properties
-
var albumId: kotlin.ByteArray
The album the feed claims this entry belongs to — 16 raw UUID bytes. Cross-checked against the manifest by the chokepoint itself, never trusted on its own.
-
var manifestCbor: kotlin.ByteArray
The signed
AssetManifestas opaque canonical CBOR, carried verbatim. -
var metadataBlob: kotlin.ByteArray
The sealed metadata blob the manifest commits to.
-
var originalCiphertext: kotlin.ByteArray
The asset’s original ciphertext. Required: the chokepoint’s content-integrity step hashes it against the manifest’s declared content address, and there is no variant of that check which skips it — so fetch the original blob before applying.
It crosses whole, so this record costs the original’s full size in memory. An original of any size is received with
FfiSession::fetch_blob_to_path, and applied and opened from that file with anFfiSyncHeadthroughFfiWorkspace::apply_sync_entry_from_fileandFfiWorkspace::open_synced_original, in bounded memory. -
var localChainHead: kotlin.ByteArray?
The 32-byte provenance head your catalog already holds for this asset, or
Noneif it has never seen it. This is what decides replay and fork; feed backFfiAssetFacts::provenance_headafter a successful apply.
data class
FfiSyncHead
Section titled “FfiSyncHead”data class FfiSyncHeadOne remote feed entry whose original is on disk rather than in hand: an
FfiSyncEntry without its original_ciphertext, which
FfiWorkspace::apply_sync_entry_from_file and FfiWorkspace::open_synced_original read
from the file FfiSession::fetch_blob_to_path
produced, in memory bounded by one STREAM chunk whatever the original’s size.
Properties
-
var albumId: kotlin.ByteArray
-
var manifestCbor: kotlin.ByteArray
-
var metadataBlob: kotlin.ByteArray
-
var localChainHead: kotlin.ByteArray?
data class
FfiSyncPage
Section titled “FfiSyncPage”data class FfiSyncPageFFI mirror of SyncPage — a decoded page plus the opaque cursor for the next
pull (the client persists next_cursor and passes it back to advance).
Properties
-
var entries: List<FfiFeedEntry>
Types:
FfiFeedEntryThe changes in this page, in strictly-increasing per-album
sync_seqorder. -
var nextCursor: kotlin.ByteArray
The opaque cursor to pass to the next
FfiSession::sync_pull. -
var hasMore: kotlin.Boolean
Whether the server holds changes beyond this page.
data class
FfiTrashEntry
Section titled “FfiTrashEntry”data class FfiTrashEntryOne asset in the trash, as its latest signed delete record describes it.
Properties
-
var assetId: kotlin.String
The trashed asset (UUID string).
-
var deletedAt: kotlin.String
When the
deletewas signed (RFC 3339, UTC). -
var retentionUntil: kotlin.String?
The signed retention floor (RFC 3339, UTC): a restore is refused at or after it.
Nonefor adeletethat carries no readable window, which never expires. -
var restorable: kotlin.Boolean
Whether a restore is accepted now, by this device’s clock. Computed by the workspace so no app re-implements the window; the server judges the same floor by its own clock.
data class
FfiUploadBlob
Section titled “FfiUploadBlob”data class FfiUploadBlobOne transferable blob of a sealed asset, paired with the POST /upload body that declares
it. Hand request and bytes straight to
FfiSession::upload — this record exists so an app never
has to assemble a manifest envelope itself.
The blobs come back in ladder order: the metadata blob (T0 — the index tier that makes the asset visible), then derivatives (T1), then the original (T2).
bytes holds each blob whole, the original included, so an original costs
its full size in memory here. FfiSession::push_asset
pushes the same blobs with the original streamed, and is the path for an original of any
size.
Properties
-
var tier: kotlin.String
The ladder tier this blob occupies (
index/preview/original). -
var hash: kotlin.String
The blob’s content address (lowercase hex) — the value the server dedups on.
-
var request: FfiUploadRequest
Types:
FfiUploadRequestThe
POST /uploadbody for this blob, with the manifest envelope already projected. -
var bytes: kotlin.ByteArray
The bytes to transfer.
data class
FfiUploadRequest
Section titled “FfiUploadRequest”data class FfiUploadRequestFFI mirror of CreateUploadRequest — the POST /upload body.
Properties
-
var size: kotlin.ULong
Ciphertext size in bytes.
-
var hash: kotlin.String
Ciphertext content hash, lowercase hex.
-
var contentType: kotlin.String
MIME type (closed enum per protocol version).
-
var cryptoSuiteId: kotlin.UShort
Crypto suite the blob is sealed under.
-
var protocolVersion: kotlin.String
Protocol date (
YYYY-MM-DD) this client speaks. -
var blobRole: FfiBlobRole
Types:
FfiBlobRoleThis blob’s role in its bundle.
-
var manifestEnvelope: FfiManifestEnvelope
Types:
FfiManifestEnvelopeThe unencrypted manifest fields the server validates.
-
var albumId: kotlin.String?
Optional album to add the asset to.
-
var ownerId: kotlin.String?
Optional owner id (defaults to the authenticated uploader).
-
var intentId: kotlin.String?
Album-upgrade intent id (album upgrade ceremony only).
data class
FfiUploadStatus
Section titled “FfiUploadStatus”data class FfiUploadStatusFFI mirror of HeadInfo — the HEAD /upload/{id} resumption/status primitive.
Properties
Enums and sealed classes
Section titled “Enums and sealed classes”enum
FfiAlertClass
Section titled “FfiAlertClass”enum class FfiAlertClassEvery alert class, flattened for the bindings. A closed enum on both sides of the boundary.
Entries
-
SYNC_STALE,
Two weeks without a completed sync while changes remain un-synced.
-
RECOVERY_CHECK_DUE,
A recovery-secret verification check is due.
-
QUOTA_SOFT,
Storage crossed the soft limit and is below the hard limit.
-
QUOTA_GRACE_EXPIRING,
Storage is over the hard limit — the grace window is counting, or has closed.
-
QUARANTINE_PENDING,
Items are sitting on a quarantine surface awaiting a human.
-
DROP_PENDING;
Guest drops are awaiting review and adoption.
enum
FfiAlertSeverity
Section titled “FfiAlertSeverity”enum class FfiAlertSeverityHow prominently a client presents an alert. Neither variant gates anything — no alert blocks sync, unlock, upload, or any critical flow.
Entries
enum
FfiBlobRole
Section titled “FfiBlobRole”enum class FfiBlobRoleFFI mirror of BlobRole (snake_case on the wire, closed enum).
Entries
-
ORIGINAL,
The source asset.
-
DERIVATIVE,
A client-generated thumbnail/preview.
-
METADATA,
The CBOR metadata document.
-
PROVENANCE,
Append-only provenance.
-
BACKUP,
A library backup artifact.
-
DERIVATIVE_MANIFEST;
A derivative tier’s signed manifest.
enum
FfiChangeKind
Section titled “FfiChangeKind”enum class FfiChangeKindFFI mirror of ChangeKind.
Entries
enum
FfiCullFlag
Section titled “FfiCullFlag”enum class FfiCullFlagThe trinary culling flag, mirrored from core’s CullFlag. Neutral is the never-flagged
state and what an unwritten register reads as.
Entries
enum
FfiDeviceTier
Section titled “FfiDeviceTier”enum class FfiDeviceTierDevice hardware tier, selecting the Argon2id cost at wrap time. Mirrors core’s DeviceTier
in this namespace (see the module docs on why it is not shared).
Entries
sealed
FfiException
Section titled “FfiException”sealed class FfiException: kotlin.Exception()Every failure the FFI flows can surface, flattened by originating layer. Each
variant carries the stable error.* catalog code (when one applies — clients
localize it) and the English detail (stays English), mirroring the
SDK’s { error, code } contract so foreign apps switch on the code, never a
bare HTTP status.
Inheritors
-
class Auth
An authentication flow (login/register/refresh/logout) failed.
-
class Upload
An upload flow (create/transfer/status) failed.
-
class Sync
A sync flow (pull/reconcile) failed.
-
class Workspace
A local workspace operation failed — opening the library, sealing an asset, reading a managed asset. This is the workspace failing, never an entry being refused: a refused sync entry is a
FfiSyncApplyOutcome::Quarantinedverdict, not an error. -
class Label
A label or region edit was refused before anything was written: its target does not exist, the label rule refused the label, or the shape broke the normalized-coordinate contract.
refusalsays which, so an editor shows the reason rather than parsingdetail. -
class Trash
A trash verb (delete, restore, purge) was refused before anything was written: the asset is unknown, not in the trash, or past its signed retention window.
refusalsays which. -
class Escrow
A master-key escrow flow (store/fetch) failed.
-
class Directory
A device-directory flow (publish/fetch) failed.
-
class Fetch
A blob fetch (
FfiSession::fetch_blob_to_path) failed: the blob is gone, still awaiting its original, refused, did not hash to its content address, or could not be written locally. Nothing is left at the destination path. -
class InvalidArgument
A foreign argument was structurally invalid (e.g. an un-parseable URL) before any network call.
sealed
FfiHardwareSignerException
Section titled “FfiHardwareSignerException”sealed class FfiHardwareSignerException: kotlin.Exception()Failure surfaced by a foreign FfiHardwareSigner. Mirrors capsule-core’s
HardwareSignerError variant for variant — it is the same contract, declared in the
capsule_sdk namespace because core’s own type carries no uniffi derive.
The error is thrown by foreign code — it is the declared error of the
FfiHardwareSigner and FfiHardwareKeyAgreement foreign traits — so Rust must lift
it, and uniffi lifts only a non-flat error. Every variant therefore carries a named
detail field (the element’s own English diagnostic), which also gives the Kotlin
exceptions and Swift cases the same (detail) shape. Core’s error keeps detail only on
Backend; for the other variants it is logged at the seam and dropped.
Inheritors
-
class AuthCancelled
The user cancelled the biometric / the element refused authentication.
-
class Unavailable
No secure element is available on this device.
-
class NotFound
No key exists for the requested alias.
-
class Exportable
The private key was readable — non-exportability is violated (a failure).
-
class Backend
Any other backend error.
sealed
FfiLabelRefusal
Section titled “FfiLabelRefusal”sealed class FfiLabelRefusalWhy a label or region edit was refused (FfiError::Label). Nothing was written.
Inheritors
-
object NotFound : FfiLabelRefusal()
The asset, region, stack or album does not exist, or no longer does.
-
object LabelEmpty : FfiLabelRefusal()
The label is empty once trimmed.
-
data class LabelTooLong
The normalized label is this many UTF-8 bytes, past the 256-byte bound.
-
object RegionOutOfRange : FfiLabelRefusal()
A coordinate is not a finite number in
[0, 1]. -
object RegionEmpty : FfiLabelRefusal()
A radius, width or height is zero.
-
object RegionPastEdge : FfiLabelRefusal()
The shape extends past an edge of the image.
sealed
FfiLabelTarget
Section titled “FfiLabelTarget”sealed class FfiLabelTargetWhat a label attaches to beyond the asset itself, whose own labels are its user tags. The label rule is the same at every level.
Inheritors
sealed
FfiLifecycleOpOutcome
Section titled “FfiLifecycleOpOutcome”sealed class FfiLifecycleOpOutcomeWhat became of one lifecycle op.
Inheritors
-
data class Applied
The server applied the op, or had applied it already (
replayed). -
object NotIndexed : FfiLifecycleOpOutcome()
Nothing was sent: the feed does not list the asset, so its create is not indexed on the server, and the server never sees a
deletefor an asset it has not indexed. The record stays on the asset’s chain; deliver it once a sync lists the asset. -
data class RestoreTooLate
Nothing was sent: a
trash-restorein the stretch undoes adeletethe server has not seen, and that delete’s window closed atretention_until. Sent, the server would apply the delete, refuse the restore and purge an asset the user restored in time. Withheld for good: the server keeps the asset live at the head it holds, the workspace keeps every record, and nothing after the pair can be sent either, since the chain is hash-linked. A later delivery judges it the same way, so it never needs retrying. -
data class Failed
The server refused the op, or could not be reached.
permanentsays whether sending the same bytes again can only be refused again.
sealed
FfiLoginOutcome
Section titled “FfiLoginOutcome”sealed class FfiLoginOutcome: DisposableWhat a password login answered with, across the FFI.
An enum rather than an optional session handle: “signed in” and “needs a code” are different
states an app renders differently, and a null handle beside a mfaToken string would let a
caller read one while acting on the other.
Inheritors
-
data class Session
The account has no second factor, and this is its session.
-
data class SecondFactorRequired
The password verified and a code is still needed.
sealed
FfiNextStep
Section titled “FfiNextStep”sealed class FfiNextStepHow to obtain the next rung.
Inheritors
sealed
FfiOpenedOriginal
Section titled “FfiOpenedOriginal”sealed class FfiOpenedOriginalHow FfiWorkspace::open_synced_original resolved. Only Opened leaves anything at the
destination path.
Inheritors
-
data class Opened
Verified end to end and decrypted: the destination now holds the original’s plaintext, which hashes to the signed sidecar’s digest.
-
data class Refused
The entry did not apply, exactly as
apply_sync_entrywould say: held pending or quarantined. A ciphertext file that is not the original the manifest commits to is quarantined asRejected.CiphertextHashMismatch. -
data class Undecryptable
The entry applied, but its file key could not be recovered or its ciphertext failed authentication under it.
-
data class DigestMismatch
The ciphertext opened, but the plaintext does not hash to the signed sidecar’s digest.
enum
FfiPathCost
Section titled “FfiPathCost”enum class FfiPathCostFFI mirror of PathCost.
Entries
-
UNMETERED,
Bulk transfer is acceptable.
-
METERED,
The link is byte-counted (iOS
isExpensive, Android withoutNOT_METERED). -
CONSTRAINED;
The OS data saver is on (iOS Low Data Mode, Android Data Saver).
enum
FfiPathInterface
Section titled “FfiPathInterface”enum class FfiPathInterfaceFFI mirror of PathInterface.
Entries
enum
FfiPowerState
Section titled “FfiPowerState”enum class FfiPowerStateFFI mirror of PowerState.
Entries
sealed
FfiPushAssetResult
Section titled “FfiPushAssetResult”sealed class FfiPushAssetResultHow one asset of an FfiSession::push_assets call ended.
Inheritors
-
data class Pushed
The asset’s admitted ladder ran: what
FfiSession::push_assetwould have returned. -
data class Failed
The asset did not push: the error
FfiSession::push_assetwould have failed with. It stays local, and pushing it again is safe.
enum
FfiQuotaAdvisory
Section titled “FfiQuotaAdvisory”enum class FfiQuotaAdvisoryThe quota state, as GET /v1/quota reports it.
Entries
-
OK,
Below the soft limit. All uploads succeed normally.
-
SOFT_WARNING,
At or above the soft limit and below the hard limit. Uploads succeed; the client warns.
-
HARD_EXCEEDED,
At or above the hard limit. New uploads are rejected; the grace window is counting.
-
GRACE_EXPIRED,
Over the hard limit for longer than the grace window; metadata-growth writes are refused too.
-
SUSPENDED;
An admin or billing action rather than a threshold. Raises no quota alert.
sealed
FfiRegionShape
Section titled “FfiRegionShape”sealed class FfiRegionShapeA region’s outline, in coordinates normalized to [0, 1] over the original’s display
orientation. Mirrors capsule_core::sidecar::RegionShape, single precision included, so a
shape that validates on one side validates on the other.
Inheritors
enum
FfiRepresentation
Section titled “FfiRepresentation”enum class FfiRepresentationA rung of the ladder, cheapest first.
Entries
sealed
FfiRetryReason
Section titled “FfiRetryReason”sealed class FfiRetryReasonWhy an upload chunk is sent again. Mirrors RetryReason variant for variant.
Inheritors
-
data class TransportReset
The connection reset or the request was lost; the same chunk is re-sent after the wait.
-
data class OffsetRealign
The server named a different offset; the transfer continues from it.
-
object SessionLost : FfiRetryReason()
The session was gone; a new one is created and the transfer continues from the offset it reports.
-
data class ServerWait
The server asked the client to wait; afterwards the transfer resumes from the offset
HEADreports.
enum
FfiRungSource
Section titled “FfiRungSource”enum class FfiRungSourceWhere a shown rung’s pixels come from.
Entries
-
LQIP,
The LQIP (
render_lqip), which paints the dominant colour where it does not decode. -
EMBEDDED,
The original’s embedded preview (
embedded_preview). -
ENCODED,
The rung’s encoded tier.
-
ORIGINAL;
The original, decoded.
enum
FfiStackCullState
Section titled “FfiStackCullState”enum class FfiStackCullStateA stack’s derived cull state, by the doc’s precedence all-rejected → any-pick → else mixed.
Entries
-
ALL_REJECTED,
Every member is rejected: the whole stack is a sweep candidate.
-
ANY_PICK,
At least one member is picked.
-
MIXED;
Neither: undecided, or rejects mixed with neutrals.
sealed
FfiSyncApplyOutcome
Section titled “FfiSyncApplyOutcome”sealed class FfiSyncApplyOutcomeHow applying one remote entry resolved — the three verdicts the client validation duties permit. There is no “ignored” case: a failure is always a named quarantine or a hold.
Inheritors
-
data class Applied
Verified end to end; upsert the facts.
-
data class Pending
Authorization is intact but the epoch’s AMK has not arrived locally yet. Hold and retry — never quarantine.
-
data class Quarantined
Refused.
reasonis a stable, switchable code;detailis English developer text.
enum
FfiThermalState
Section titled “FfiThermalState”enum class FfiThermalStateFFI mirror of ThermalState.
Entries
sealed
FfiTransferEvent
Section titled “FfiTransferEvent”sealed class FfiTransferEventOne step of an upload, a custody check or a ranged fetch. Mirrors TransferEvent
variant for variant and field for field; blob is the content address (lowercase hex) and
offsets and lengths are bytes of ciphertext.
Inheritors
-
data class SessionCreated
POST /uploadopened a session;resume_offsetis non-zero when the server returned an existing session for the same blob. -
data class SessionResumed
An existing session resumed from the offset
HEADreported. -
data class ChunkSent
A chunk left the client.
-
data class ChunkAcked
The server acknowledged a chunk;
acked_offsetis its new received-byte count. -
data class ChunkRetried
A chunk will be sent again, or the transfer moves to another offset or session.
-
data class ChecksumRejected
The server refused a chunk whose body did not match its checksum; it is re-sent.
-
data class Finalize
Every declared byte reached the server; it is finalizing the blob.
-
data class Merged
The server already held the blob: resolved as a merge, nothing sent.
-
data class Verify
POST /storage/verifyanswered for an asset. -
data class Receipt
A custody receipt for one blob verified under the pinned attestation keys.
-
data class RangeRequested
A ranged request left the client;
max_lenis the bounded window, orNonefor the open-ended remainder. -
data class RangeReceived
Bytes of a ranged request landed.
-
data class FetchRetried
A ranged request brought nothing; the fetch backs off and resumes from the same offset.
-
data class FetchVerified
The fetched bytes hashed to the requested content address.
-
data class IntegrityRejected
The fetched bytes did not hash to the requested content address and were discarded.
sealed
FfiTransferFeedItem
Section titled “FfiTransferFeedItem”sealed class FfiTransferFeedItemWhat one pull of a subscription yields.
Inheritors
enum
FfiTrashRefusal
Section titled “FfiTrashRefusal”enum class FfiTrashRefusalWhy a trash verb was refused (FfiError::Trash). Nothing was written.
Entries
-
NOT_FOUND,
The workspace holds no such asset.
-
NOT_IN_TRASH,
The asset is not in the trash: a restore has nothing to undo, and a purge never skips the trash.
-
RETENTION_ELAPSED;
The signed retention window has closed, so the asset can no longer be restored. It stays in the trash until it is purged.
sealed
FfiUploadOutcome
Section titled “FfiUploadOutcome”sealed class FfiUploadOutcomeFFI mirror of UploadOutcome — how a full upload resolved.
Inheritors
-
data class Completed
Every declared byte transferred; the server has begun finalization.
-
data class AlreadyStored
The blob was already stored server-side (the
duplicate_blob→ merge path).
sealed
FfiVerifyOutcome
Section titled “FfiVerifyOutcome”sealed class FfiVerifyOutcomeThe verification verdict, flattened for FFI (reasons as stable reason-code strings).
Inheritors
-
object Accept : FfiVerifyOutcome()
The asset verified and may enter the trusted set.
-
data class TerminalReject
The asset is permanently rejected (quarantined);
reasonis the reason code. -
data class Pending
The asset is recoverable-pending (held + retried);
reasonis the reason code.
Platform adapters
Section titled “Platform adapters”Hand-written in capsule-core-kotlin/src/main/kotlin/com/justin13888/capsule/hardware, not generated: the classes an app constructs and passes where the declarations above take a platform key store.
class
SoftwareP256Signer
Section titled “SoftwareP256Signer”class SoftwareP256Signer(seed: ByteArray) : FfiHardwareSignerTypes: FfiHardwareSigner
Software P-256 FfiHardwareSigner —the no-secure-element reference the real StrongBox
replaces, and the always-runnable path for the P-256 hybrid composition (a JVM/CI host has no
StrongBox). It mirrors StrongBoxSigner’s wire contract exactly — a 65-byte uncompressed
SEC1 (0x04‖x‖y) public key and a DER-encoded ECDSA signature over SHA-256(msg) — so it
plugs into FfiWorkspace.createWithP256HardwareSigner end to end, and mirrors the
Swift SoftwareP256Signer.
The P-256 scalar is derived deterministically (HKDF-SHA256, per keyAlias, reduced mod n) from a
32-byte seed the caller seals. It offers no hardware non-exportability, which assertNonExportable
reports truthfully by throwing FfiHardwareSignerException.Exportable. BouncyCastle is used so the
derivation and DER encoding are identical on the JVM (unit tests) and on Android.
Constructors
-
constructor(seed: ByteArray)
Functions
-
override fun enroll(keyAlias: String): ByteArray
Generate (or bind to) the hardware keypair for
key_alias, returning its public key in the constructor’s shape: a SEC1 P-256 key forFfiWorkspace::create_with_p256_hardware_signer, a 32-byte Ed25519 key forFfiWorkspace::create_with_hardware_signer. Idempotent per alias.From
FfiHardwareSigner.enroll. -
override fun classicalPublicKey(keyAlias: String): ByteArray
The public key for an already-enrolled
key_alias, in the same constructor-dependent shapeenrollreturns (SEC1 P-256, or 32-byte Ed25519). -
override fun signClassical(keyAlias: String, msg: ByteArray): ByteArray
Sign
msgwith the hardware key forkey_alias, in the constructor’s shape: a DER-encoded ECDSA signature overSHA-256(msg)forFfiWorkspace::create_with_p256_hardware_signer, a 64-byte Ed25519 signature overmsgforFfiWorkspace::create_with_hardware_signer. -
override fun assertNonExportable(keyAlias: String)
Non-exportability assertion: a conforming element MUST refuse to reveal the private bytes, returning
FfiHardwareSignerError::Exportableif they can be read.
class
SoftwareSigner
Section titled “SoftwareSigner”class SoftwareSigner(seed: ByteArray) : FfiHardwareSignerTypes: FfiHardwareSigner
Software FfiHardwareSigner —the no-secure-element fallback, mirroring the Rust and Swift
SoftwareSigner. The classical Ed25519 key lives in process memory, derived deterministically
(HKDF-SHA512, per keyAlias) from a 32-byte seed the caller is responsible for sealing.
Because it produces a genuine 32-byte Ed25519 public key and 64-byte signature, this backend
plugs directly into FfiWorkspace.createWithHardwareSigner — it is the one the JVM smoke
test drives end to end. It offers no hardware non-exportability, which assertNonExportable
reports truthfully by throwing FfiHardwareSignerException.Exportable.
The derivation matches the Rust/Swift references (salt = keyAlias, info =
capsule/software-signer/ed25519/v1), so the same seed yields the same device key in every
language. BouncyCastle is used so deterministic-from-seed Ed25519 works identically on the JVM
(unit tests) and on Android without relying on a particular JCA provider’s Ed25519 support.
Constructors
-
constructor(seed: ByteArray)
Functions
-
override fun enroll(keyAlias: String): ByteArray
Generate (or bind to) the hardware keypair for
key_alias, returning its public key in the constructor’s shape: a SEC1 P-256 key forFfiWorkspace::create_with_p256_hardware_signer, a 32-byte Ed25519 key forFfiWorkspace::create_with_hardware_signer. Idempotent per alias.From
FfiHardwareSigner.enroll. -
override fun classicalPublicKey(keyAlias: String): ByteArray
The public key for an already-enrolled
key_alias, in the same constructor-dependent shapeenrollreturns (SEC1 P-256, or 32-byte Ed25519). -
override fun signClassical(keyAlias: String, msg: ByteArray): ByteArray
Sign
msgwith the hardware key forkey_alias, in the constructor’s shape: a DER-encoded ECDSA signature overSHA-256(msg)forFfiWorkspace::create_with_p256_hardware_signer, a 64-byte Ed25519 signature overmsgforFfiWorkspace::create_with_hardware_signer. -
override fun assertNonExportable(keyAlias: String)
Non-exportability assertion: a conforming element MUST refuse to reveal the private bytes, returning
FfiHardwareSignerError::Exportableif they can be read.
class
StrongBoxSigner
Section titled “StrongBoxSigner”class StrongBoxSigner(strongBoxBacked: Boolean = true) : FfiHardwareSignerTypes: FfiHardwareSigner
Android StrongBox–backed FfiHardwareSigner.The private key is generated inside the
AndroidKeyStore — StrongBox (a dedicated secure element) when strongBoxBacked is true, else
the TEE — and never leaves it.
Algorithm (the same one Secure Enclave and the TPM reference produce)
Section titled “Algorithm (the same one Secure Enclave and the TPM reference produce)”The AndroidKeyStore exposes ECDSA over NIST P-256, not Ed25519, so this returns P-256
material: a 65-byte uncompressed SEC1 (0x04‖x‖y) public key — the same encoding Secure
Enclave’s x9.63 representation uses, which P256HybridSigningKey normalizes on the Rust side —
and an ASN.1/DER ECDSA signature over msg that p256::ecdsa verifies verbatim. It therefore
plugs into the P-256 createWithP256HardwareSigner path end to end; the Ed25519
SoftwareSigner drives the separate createWithHardwareSigner path.
Requires API 23+ (StrongBox: API 28+ on devices that ship a secure element).
Constructors
-
constructor(strongBoxBacked: Boolean = true)
Functions
-
override fun enroll(keyAlias: String): ByteArray
Generate (or bind to) the hardware keypair for
key_alias, returning its public key in the constructor’s shape: a SEC1 P-256 key forFfiWorkspace::create_with_p256_hardware_signer, a 32-byte Ed25519 key forFfiWorkspace::create_with_hardware_signer. Idempotent per alias.From
FfiHardwareSigner.enroll. -
override fun classicalPublicKey(keyAlias: String): ByteArray
The public key for an already-enrolled
key_alias, in the same constructor-dependent shapeenrollreturns (SEC1 P-256, or 32-byte Ed25519). -
override fun signClassical(keyAlias: String, msg: ByteArray): ByteArray
Sign
msgwith the hardware key forkey_alias, in the constructor’s shape: a DER-encoded ECDSA signature overSHA-256(msg)forFfiWorkspace::create_with_p256_hardware_signer, a 64-byte Ed25519 signature overmsgforFfiWorkspace::create_with_hardware_signer. -
override fun assertNonExportable(keyAlias: String)
Non-exportability assertion: a conforming element MUST refuse to reveal the private bytes, returning
FfiHardwareSignerError::Exportableif they can be read.