Skip to main content

Upload File

Upload an encrypted file to IPFS via Pinata with Groth16 ZK proof.
POST /api/storage/upload
Content-Type: multipart/form-data
Form Data:
  • file: File to upload (max 100MB)
  • proof: Groth16 proof JSON
  • publicSignals: Public signals array
  • commitment: Password commitment hash
  • checksum: SHA-256 file checksum
Response:
{
  "success": true,
  "id": "file_uuid",
  "cid": "QmXyz123abc456def789...",
  "filename": "document.pdf",
  "size": 1234567,
  "checksum": "sha256:abc123..."
}

List Files

Get list of uploaded files for current user.
GET /api/storage/list
Response:
{
  "success": true,
  "files": [
    {
      "id": "file_uuid",
      "cid": "QmXyz123...",
      "filename": "document.pdf",
      "size": 1234567,
      "createdAt": "2025-12-01T10:00:00Z",
      "checksum": "sha256:abc123..."
    }
  ]
}

Download File

Download a file from IPFS.
GET /api/storage/download/:cid
Response: Binary file data with headers:
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="document.pdf"

Delete File

Unpin a file from IPFS (removes from Pinata).
DELETE /api/storage/:id
Response:
{
  "success": true,
  "deleted": true
}

Generate a shareable link for a file.
POST /api/storage/share
Request:
{
  "fileId": "file_uuid",
  "expiresIn": 48
}
Response:
{
  "success": true,
  "shareToken": "abc123token",
  "shareUrl": "https://zkterm.io/share/abc123token",
  "expiresAt": "2025-12-03T10:00:00Z"
}

Access Shared File

Access a file via share link.
GET /api/storage/shared/:token
Response:
{
  "success": true,
  "file": {
    "cid": "QmXyz123...",
    "filename": "document.pdf",
    "size": 1234567
  }
}

Verify ZK Proof

Verify Groth16 proof for a file.
POST /api/storage/verify
Request:
{
  "proof": {
    "pi_a": [...],
    "pi_b": [...],
    "pi_c": [...]
  },
  "publicSignals": ["commitment_hash"],
  "commitment": "expected_commitment"
}
Response:
{
  "success": true,
  "valid": true
}

Error Codes

CodeDescription
FILE_TOO_LARGEFile exceeds max size (100MB)
INVALID_PROOFZK proof verification failed
CID_NOT_FOUNDFile not found on IPFS
CHECKSUM_MISMATCHFile integrity check failed
SHARE_EXPIREDShare link has expired
PINATA_ERRORPinata API error