toip.tools

API reference · Browser and Node

@toip-tools/anon-membership

93 public exports.

TypeScriptModule import
import { type Acceptance, acceptMembership, type AcceptPolicy } from "@toip-tools/anon-membership";

Functions

  • acceptMembership

    Decides whether a membership proof is acceptable: the circuit is pinned, the groups are the

  • bundledCrs

    The CRS bundled in artifacts/crs.json, enough points for every compiled circuit.

  • checkRootLog

    Checks a group's root log, oldest first: each document signed by `expectedIssuer`, one group,

  • checkStatement

    Throws if the statement can't be a public input of the circuit.

  • commitmentOf

    H(1, secret, groupId).

  • dayFromIso
  • dayOf

    Days since 1970-01-01 UTC.

  • decodeLeaf
  • decodeMembershipCode

    The secret, or null for a typo or a code made for another group.

  • decodeStatement
  • deriveSecret

    toField(HMAC-SHA256(seed, utf8(info))).

  • encodeLeaf
  • encodeMembershipCode

    Crockford base32 of the 31-byte secret and a 2-byte checksum over (groupId, secret), in groups of 4.

  • encodeStatement
  • enroll

    Member side: sends the commitment for `groupId` and checks the leaf the issuer recorded.

  • epochIndex

    The epoch's index: periods since 1970.

  • epochOf
  • fieldFromBytes

    `toField(SHA-256(bytes))`: agora's f(bytes).

  • fieldFromBytes32

    Reads 32 bytes, big-endian.

  • fieldFromHex

    Reads `fieldToHex`'s form.

  • fieldToBytes

    32 bytes, big-endian.

  • fieldToHex

    "0x" and 64 lowercase hex digits, big-endian.

  • findEquivocation

    Two validly signed, different roots of one group with the same seq or epoch, if `docs` holds any.

  • groupFieldOf

    The group id as the circuit sees it: f(utf8(groupId)), as agora's design writes it.

  • groupIdOf

    "<issuer DID>#<name>".

  • hash

    Agora's name for the same hash.

  • initHashing

    Loads Barretenberg's WebAssembly once, for hashing.

  • isoFromDay
  • leafHash

    H(4, commitment, schemaId, validUntilDay, registeredDay, attrs[0], attrs[1], attrs[2], attrs[3]).

  • loadArtifacts

    The committed artifacts for a depth.

  • memberSecret

    One secret per group, so the same person's commitments in two groups differ.

  • membershipInputs

    Finds the member's leaf in one of the groups and builds the statement and witness to prove.

  • messageOf

    toField(SHA-256(JCS(["anon-membership/v1/message", app, value]))).

  • nodeHash
  • nullifierOf

    H(2, secret, scope, k).

  • parseMembershipProof

    Checks the shape of a proof that arrived from elsewhere.

  • plainLeaf

    A leaf with no attributes that never expires: tipline's case, where the root itself is the revocation.

  • poseidon2

    Poseidon2 over BN254 as Noir's `Poseidon2::hash(inputs, inputs.length)` (noir-lang/poseidon v0.4.0).

  • rootDocHash

    Hex SHA-256 of the JCS of the signed root document.

  • sameStatement

    Equal as public inputs: trailing "any" predicates are the same as missing ones.

  • scopeOf

    toField(SHA-256(JCS(["anon-membership/v1/scope", app, ...parts]))).

  • simpleStatement

    Defaults that make a statement mean "a current member of this group": tipline's case.

  • snapshotMatches
  • toField

    The first 31 bytes of a 32-byte digest, big-endian.

  • treeFromRoot

    Rebuilds the tree from a snapshot and checks it against the signed root: hash, root, length and size.

  • verifyPath

    True if `leaf` at `path.index` with `path.siblings` gives `root`.

  • vkHashOf
  • whyUnsatisfied

    Why a witness can't satisfy a statement, or null.

  • zeroHashes

    Z[0] = 0, Z[i+1] = H(3, Z[i], Z[i]), for i up to `depth`.

Classes

  • GroupIssuer

    Runs one group: enrolls members, removes leavers, and signs one root per epoch in a hash chain.

  • GroupTree

    A fixed-depth, sparse Poseidon2 Merkle tree of leaves.

  • MembershipError

    Thrown when the witness can't satisfy the statement: not a member, expired, an unmet predicate, and so on.

  • MembershipProver
  • MembershipVerifier
  • NullifierBook

    Turns nullifiers into stable labels, "Source A", "Source B", …, per (group, scope), in order of first sight.

Interfaces

Types

Constants

  • CIRCUIT_ID

    The circuit the library proves with.

  • DAY_SECONDS
  • DEPTH

    The compiled circuit's depth.

  • ENROLL

    ourSpec("anon-membership/enroll"): member DID → issuer, request and response.

  • FIELD_MODULUS
  • MAX_LIMIT

    Rate-limit indexes are below this.

  • NEVER_EXPIRES

    The largest day number, for leaves that never expire.

  • PROOF_SYSTEM

    UltraHonk in its zero-knowledge mode, with a Poseidon2 transcript.

  • TAG

    Domain tags, the first input of each hash.

Signatures and source documentation are generated from packages/anon-membership/src/index.ts.