> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zkterm.io/llms.txt
> Use this file to discover all available pages before exploring further.

# zkToolkit API

> API reference for cryptographic primitives

## Hash Functions

### Poseidon Hash

```bash theme={null}
POST /api/zk-toolkit/hash/poseidon
```

**Request:**

```json theme={null}
{
  "input": "hello world"
}
```

**Response:**

```json theme={null}
{
  "success": true,
  "data": {
    "hash": "0x1234567890abcdef..."
  }
}
```

### Pedersen Hash

```bash theme={null}
POST /api/zk-toolkit/hash/pedersen
```

### MiMC Hash

```bash theme={null}
POST /api/zk-toolkit/hash/mimc
```

**Request (with optional key):**

```json theme={null}
{
  "input": "data",
  "key": "optional_key"
}
```

***

## Field Arithmetic

All operations use BN254 prime field.

### Add

```bash theme={null}
POST /api/zk-toolkit/field/add
```

**Request:**

```json theme={null}
{
  "a": "5",
  "b": "7"
}
```

**Response:**

```json theme={null}
{
  "success": true,
  "data": {
    "result": "12"
  }
}
```

### Subtract

```bash theme={null}
POST /api/zk-toolkit/field/sub
```

### Multiply

```bash theme={null}
POST /api/zk-toolkit/field/mul
```

### Divide

```bash theme={null}
POST /api/zk-toolkit/field/div
```

### Inverse

```bash theme={null}
POST /api/zk-toolkit/field/inv
```

**Request:**

```json theme={null}
{
  "a": "5"
}
```

### Power

```bash theme={null}
POST /api/zk-toolkit/field/pow
```

**Request:**

```json theme={null}
{
  "base": "2",
  "exp": "256"
}
```

### Square Root

```bash theme={null}
POST /api/zk-toolkit/field/sqrt
```

### Random Element

```bash theme={null}
GET /api/zk-toolkit/field/random
```

### Get Prime

```bash theme={null}
GET /api/zk-toolkit/field/prime
```

***

## Elliptic Curve (Baby JubJub)

### Base Point

```bash theme={null}
GET /api/zk-toolkit/ec/base
```

**Response:**

```json theme={null}
{
  "success": true,
  "data": {
    "x": "5299619240641551281634865583518297030282874472190772894086521144482721001553",
    "y": "16950150798460657717958625567821834550301663161624707787222815936182638968203"
  }
}
```

### Scalar Multiplication (Base Point)

```bash theme={null}
POST /api/zk-toolkit/ec/mulbase
```

**Request:**

```json theme={null}
{
  "scalar": "12345"
}
```

**Response:**

```json theme={null}
{
  "success": true,
  "data": {
    "x": "123...",
    "y": "456..."
  }
}
```

### Point Addition

```bash theme={null}
POST /api/zk-toolkit/ec/add
```

**Request:**

```json theme={null}
{
  "p1": { "x": "...", "y": "..." },
  "p2": { "x": "...", "y": "..." }
}
```

### Scalar Multiplication

```bash theme={null}
POST /api/zk-toolkit/ec/mul
```

**Request:**

```json theme={null}
{
  "point": { "x": "...", "y": "..." },
  "scalar": "12345"
}
```

### Check Point on Curve

```bash theme={null}
POST /api/zk-toolkit/ec/isoncurve
```

**Request:**

```json theme={null}
{
  "x": "...",
  "y": "..."
}
```

### Curve Parameters

```bash theme={null}
GET /api/zk-toolkit/ec/params
```

***

## Shamir Secret Sharing

### Split Secret

```bash theme={null}
POST /api/zk-toolkit/shamir/split
```

**Request:**

```json theme={null}
{
  "secret": "42",
  "threshold": 3,
  "shares": 5
}
```

**Response:**

```json theme={null}
{
  "success": true,
  "data": {
    "shares": [
      "1:1234567890",
      "2:2345678901",
      "3:3456789012",
      "4:4567890123",
      "5:5678901234"
    ],
    "threshold": 3,
    "total": 5
  }
}
```

### Combine Shares

```bash theme={null}
POST /api/zk-toolkit/shamir/combine
```

**Request:**

```json theme={null}
{
  "shares": [
    "1:1234567890",
    "2:2345678901",
    "3:3456789012"
  ]
}
```

**Response:**

```json theme={null}
{
  "success": true,
  "data": {
    "secret": "42"
  }
}
```

***

## Groth16 Proofs

### Generate Proof

```bash theme={null}
POST /api/zk-toolkit/proof/generate
```

**Request:**

```json theme={null}
{
  "inputs": {
    "a": "5",
    "b": "7"
  }
}
```

**Response:**

```json theme={null}
{
  "success": true,
  "data": {
    "proof": {
      "pi_a": [...],
      "pi_b": [...],
      "pi_c": [...],
      "protocol": "groth16"
    },
    "publicSignals": ["12"]
  }
}
```

### Verify Proof

```bash theme={null}
POST /api/zk-toolkit/proof/verify
```

**Request:**

```json theme={null}
{
  "proof": { ... },
  "publicSignals": ["12"]
}
```

### List Circuits

```bash theme={null}
GET /api/zk-toolkit/proof/circuits
```

***

## Error Codes

| Code             | Description                          |
| ---------------- | ------------------------------------ |
| `INVALID_INPUT`  | Invalid input format                 |
| `FIELD_OVERFLOW` | Value exceeds field prime            |
| `NOT_ON_CURVE`   | Point not on Baby JubJub curve       |
| `PROOF_FAILED`   | Proof generation/verification failed |
| `INVALID_SHARES` | Invalid or insufficient shares       |
