# anon-membership/enroll

https://toip.tools/spec/anon-membership/enroll/0.1

A member's wallet, from the member's own DID, sends a group's issuer a commitment to its secret for that group, optionally with a credential. The issuer's admit() decides whether that DID may join; if so, the issuer appends the commitment as a leaf in the group's tree. It answers with the leaf's index, the first epoch whose root will hold it, and the leaf, which the wallet checks.

- **Sent**: member's wallet → group issuer
- **Kind**: Request and response. The response's type is `https://toip.tools/spec/anon-membership/enroll/0.1#response`.
- **Envelope**: Signed by the issuer, addressed to one recipient, timestamped, and encrypted in a TSP Direct message. The signature and recipient binding prevent its use as a bearer token.
- **Defined in**: [`packages/anon-membership/src/issuer.ts:12`](https://github.com/yourbuddyconner/toip-tools/blob/main/packages/anon-membership/src/issuer.ts#L12) as `ENROLL`
- **Handled in**: [`packages/anon-membership/src/issuer.ts`](https://github.com/yourbuddyconner/toip-tools/blob/main/packages/anon-membership/src/issuer.ts)
- **Design**: [7.1 Message types](https://github.com/yourbuddyconner/toip-tools/blob/main/projects/tipline/docs/design.md#71-message-types) in `projects/tipline/docs/design.md`

## Payload

packages/anon-membership/src/issuer.ts:14:

```ts
export interface EnrollRequest {
  group: string;
  commitment: string;
  /** Anything the issuer's admit() needs to decide and to fill the leaf's attributes, such as a credential. */
  credential?: unknown;
  /** The member asks to replace a leaf they already have, with a new commitment (a rotation). admit() decides. (Additive.) */
  replace?: boolean;
}
```

## Response payload

packages/anon-membership/src/issuer.ts:31:

```ts
export interface EnrollResponse {
  group: string;
  index: number;
  /** The first epoch whose root will hold the leaf. */
  firstEpoch: string;
  leaf: LeafJson;
}
```

### Types it uses

packages/anon-membership/src/issuer.ts:23:

```ts
export interface LeafJson {
  commitment: string;
  schemaId: string;
  validUntilDay: number;
  registeredDay: number;
  attrs: string[];
}
```

## Notes

Refusals: unknownGroup, badRequest (the commitment isn't a field element) and notAdmitted. The design's table leaves out the optional credential and the leaf in the response.

## Document envelope

Every Trust Task uses this envelope. Replace `payload` with the structure shown above.

Shape of a document of this type:

```json
{
  "id": "urn:uuid:…",
  "type": "https://toip.tools/spec/anon-membership/enroll/0.1",
  "issuer": "did:key:… (the sender)",
  "recipient": "did:key:… (the receiver)",
  "issuedAt": "2026-11-06T18:00:00.000Z",
  "payload": { … },
  "proof": {
    "type": "DataIntegrityProof",
    "cryptosuite": "eddsa-jcs-2022",
    "verificationMethod": "did:key:…#…",
    "proofPurpose": "assertionMethod",
    "proofValue": "z…"
  }
}
```

---

This is the Markdown version of https://toip.tools/spec/anon-membership/enroll/0.1/. An index of the documentation for AI assistants is at https://toip.tools/llms.txt.
