> For the complete documentation index, see [llms.txt](https://cifer.gitbook.io/cifer-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cifer.gitbook.io/cifer-docs/documentation/cifer-sdk/getting-started/web2-quickstart.md).

# Web2 quickstart

{% stepper %}
{% step %}

## Initialize the SDK and client

```typescript
import { createCiferSdk, web2 } from 'cifer-sdk';

const sdk = await createCiferSdk({
  blackboxUrl: 'https://blackbox.cifersecurity.com:3010',
});

const client = web2.createClient({
  blackboxUrl: sdk.blackboxUrl,
  readClient: sdk.readClient,
});
```

{% endstep %}

{% step %}

## Provide an Ed25519 signer

```bash
npm install @noble/ed25519
```

```typescript
import * as ed from '@noble/ed25519';

const privateKey = ed.utils.randomPrivateKey();
const publicKey = await ed.getPublicKeyAsync(privateKey);

const ed25519Signer = {
  sign: (message: Uint8Array) => ed.signAsync(message, privateKey),
  getPublicKey: () => publicKey,
};
```

Store the private key securely and persist it according to your application's account-recovery model.
{% endstep %}

{% step %}

## Register and verify the account

```typescript
const reg = await web2.auth.register({
  email: 'user@example.com',
  password: 'use-a-strong-password',
  blackboxUrl: sdk.blackboxUrl,
});

await web2.auth.verifyEmail({
  email: 'user@example.com',
  otp: '123456',
  blackboxUrl: sdk.blackboxUrl,
});

await web2.auth.registerKey({
  principalId: reg.principalId,
  password: 'use-a-strong-password',
  ed25519Signer,
  blackboxUrl: sdk.blackboxUrl,
});
```

{% endstep %}

{% step %}

## Create a managed session

```typescript
await client.createManagedSession({
  principalId: reg.principalId,
  ed25519Signer,
});
```

{% endstep %}

{% step %}

## Create a secret and encrypt

```typescript
const secret = await client.createSecret();

const encrypted = await client.payload.encryptPayload({
  secretId: secret.secretId,
  plaintext: 'Protected without a wallet',
});

const decrypted = await client.payload.decryptPayload({
  secretId: secret.secretId,
  encryptedMessage: encrypted.encryptedMessage,
  cifer: encrypted.cifer,
});
```

{% endstep %}
{% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cifer.gitbook.io/cifer-docs/documentation/cifer-sdk/getting-started/web2-quickstart.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
