Skip to content

Confidential KV

Confidential KV is a key-value store that only the principals a bucket grants can read: API keys, apps in the same organization, and people. Use it for configuration, feature flags, secrets your backend needs, an app’s own records, or each user’s private settings. It is the package com.calimero.confidential-kv.

  • Calimero cannot read values or push new code. The store declares upgrades = "owner": only an owner or admin of the store’s organization upgrades it, with a passkey. It is also pinned to its lineage, so it moves only to newer releases of com.calimero.confidential-kv signed by Calimero’s key, never to another package or an older release.
  • The store answers no call without an account behind it. Calimero, as operator, can stop or delete a store, but reads one only as a person or key the store grants.
  • The owner does not read everything. The store’s owner and admins read its ordinary buckets, but not the values in a servicesOnly bucket, and no one, the owner included, reads another person’s keys in a private bucket.
  • Every access change is on record. Granting and revoking are passkey steps, and every grant is in the audit log.

This holds within the cluster’s rules: on a shared cluster Calimero approves which node images run every tenant’s code; on a dedicated cluster, by default, the app’s publisher or the store’s owner does. See the security model.

Term What it is
Bucket A named set of keys with its own grants, type and limits. A new store has a bucket called default.
Principal Who a grant is for: account:<id>, key:<api key id>, app:<app id>, team:<id> or role:<guest|member|admin|owner>.
Grant One right for one principal on one bucket: read, write or admin. They are independent: write does not imply read.
Preset setAccess sets a principal’s rights in one step: view (read), edit (read and write), manage (all three) or none.
Store admins The owner, plus accounts the owner adds. They hold every right on every bucket without grants, and create buckets.
Entry A key and its value, with a version (the key’s own count of writes) and a revision (the bucket’s, never repeated). Keys can have a TTL.

A few rules matter in practice:

  • An API key acts only through grants to its own key:<id>. A person’s grants, the owner’s included, never pass to their keys.
  • Only people change access. Creating buckets, granting, revoking and setAccess need a passkey, and admin goes only to accounts, teams and roles.
  • Compare-and-set. setIf, and delete with expectedRevision, write only if the entry is still at the revision you read ("0" for “absent”).
  • A change feed. changesSince pages through a bucket’s writes by revision.
Type Use it for Who reads values
Shared (no flags) Data the store’s owner and admins may read, shared with the people, keys and apps you grant Store admins and grantees
passkeyWrites The same, where every write must be a person’s passkey-confirmed act; apps and keys only read Store admins and grantees
servicesOnly Data only your backend touches, through API keys and apps Only keys and apps granted on it; people manage access but read no values
private Each person’s own data: every account has its own keyspace Each person, their own keys only; no key, app or admin reads them

Admins of a servicesOnly bucket can still grant a key they create, in the open: the grant shows in grants and in the audit log. Admins of a private bucket see entry counts and sizes per account, never a key or a value.

  1. In the console, open KV stores under Services and press New KV store. Pick the cluster and who it is for: your own use, or one of your apps’ organizations. Confirm with your passkey; the store belongs to your account.
  2. On the store’s Access tab, create buckets and grant people, teams and roles.
  3. On the Connect tab, choose who is calling: a server or script (an API key scoped to the store’s data methods and granted on a bucket), a Calimero app, or a web or mobile app whose visitors sign in with their own passkeys. It writes the code with your store’s values.

From a server or script, with the typed client on mero-js:

Terminal window
npm install @calimero-network/mero-js @calimero-network/confidential-kv
import { Calimero } from '@calimero-network/mero-js';
import { kv } from '@calimero-network/confidential-kv';
// Calimero.fromEnv() reads CALIMERO_CLUSTER, CALIMERO_API_KEY and CALIMERO_MIN_RELEASE; kv() reads CALIMERO_KV_STORE.
const store = kv(await Calimero.fromEnv());
await store.set({ bucket: 'default', key: 'flags/beta', value: 'on' });
const entry = await store.get({ bucket: 'default', key: 'flags/beta' }); // { value, version, ... } or null

kv(calimero, { store }) binds another store. kv(calimero, { minVersion: '0.3.0', pinned: true }) refuses to talk to a store whose release is older than minVersion, or, with pinned, one not pinned to its lineage.

From another Calimero app, declare the store once in Cargo.toml and call it through the typed client the build generates:

[package.metadata.calimero.uses]
kv = { package = "com.calimero.confidential-kv", range = ">=0.2, <0.4", mode = "attach" }
let kv = uses::kv()?; // `NotLinked` until linked
let revision = kv.set("notes", "note/1", &json, None).await?; // typed args and result

With mode = "attach", the app’s owner links a store they already run. With mode = "create", the cluster creates a store with each instance of your app, and that instance can read and write default at once. Both apps must be in the same organization; on an attached store, the store’s admin grants app:<your app id> on the buckets it uses. See Build on other apps.

Limit Value
Key 512 bytes
Value 256 KiB, or the bucket’s lower limit
Batch (setMany) 100 entries and 768 KiB of keys and values
Page (list) 1,000
Change feed (changesSince) The last 10,000 writes per bucket; on a private bucket, the caller’s last 1,000
Private bucket, per account (defaults) 1,000 entries and 1 MiB; 10,000 accounts per bucket

Expired keys are swept every minute. A store needs nodes on merod 1.0.0-rc.39 or later.

A store is billed as any app instance: its calls, views, compute and state on a shared cluster, or within the flat fee of a dedicated cluster. See Products → Pricing.