Skip to content

@lelantos-org/sdk / primitives / deriveSubscriptionToken

Function: deriveSubscriptionToken() ​

ts
function deriveSubscriptionToken(
   P, 
   ivk, 
   epoch?
): bigint;

Defined in: @lelantos-org/sdk/dist/crypto/derive.d.ts:36

Off-circuit fmd-webserver subscription capability token. Derived rather than stored, so losing local state does not lose the subscription.

The input is ivk, not dk: any detection delegate can recover dk, since the γ scalars a wallet POSTs are x_i = dk + h_i with public h_i, so a dk-derived token would be computable by the server it authenticates against. ivk is secret and dk = Poseidon(TAG_DK, ivk) is one-way.

epoch makes the token rotatable. It is not secret but cannot be recovered from the server: a read-only subscription lookup would be an existence oracle for tokens, and POST /v1/subscriptions creates on miss, so probing for the current epoch re-attaches to a rotated-away token or recreates a deleted one. At the default epoch = 0 the token is a function of ivk alone. After the first rotation the caller must persist the epoch: losing a non-zero epoch requires a full re-backfill and strands the previous subscription.

epoch is a Field: persist it as a plain number and pass BigInt(n), since JSON.stringify throws on bigint.

Parameters ​

ParameterType
PPoseidon
ivkbigint
epoch?bigint

Returns ​

bigint