> For the complete documentation index, see [llms.txt](https://hinkal-team.gitbook.io/hinkal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hinkal-team.gitbook.io/hinkal/hinkal-waas/generating-keypair.md).

# Generating Keypair

Every user in Hinkal WaaS is identified by an Ed25519 public key. You generate the keypair yourself client-side — the private key never leaves your system.

## Install dependency

```bash
npm install tweetnacl
```

## Generate a new keypair

```js
const nacl = require("tweetnacl");

const keypair = nacl.sign.keyPair();

const publicKeyHex  = Buffer.from(keypair.publicKey).toString("hex");
const privateKeyHex = Buffer.from(keypair.secretKey.slice(0, 32)).toString("hex");

console.log("Public key (register this with Hinkal):", publicKeyHex);
console.log("Private key seed (store this securely):", privateKeyHex);
```

The `publicKeyHex` is what you register when creating a user. The `privateKeyHex` is the 32-byte seed — store it securely and never share it.

## Restore a keypair from a saved seed

```js
const nacl = require("tweetnacl");

function keypairFromSeedHex(seedHex) {
  const seed = Buffer.from(seedHex, "hex");
  return nacl.sign.keyPair.fromSeed(seed);
}

const keypair = keypairFromSeedHex(process.env.PRIVATE_KEY_SEED_HEX);
```
