BenchmarksStack Ranking
APIsPricingDocsWhite PaperTokenBlogAboutSecurity Demo
Log InGet API Key
Tutorial · 5 min read

Testing H33 Authentication:
Unit and Integration Tests

How to write effective tests for your H33 integration.

5 min
Setup
Open
Source
SDK
Ready
Production
Grade

Authentication systems are only as reliable as the tests that guard them. When your stack operates at 1.595 million authentications per second with a full post-quantum pipeline—BFV fully homomorphic encryption, zero-knowledge proof lookups, and Dilithium signature attestation—a single untested edge case can cascade into a production incident that affects millions of users. This guide walks through a layered testing strategy for H33 integrations, from isolated unit tests through full end-to-end verification, so you can ship with confidence.

Why Authentication Testing Demands a Different Mindset

Standard application tests verify that correct inputs produce correct outputs. Authentication testing must go further: you need to prove that incorrect inputs are rejected, that timing characteristics do not leak secrets, and that cryptographic operations remain consistent across environments. H33 compounds this challenge because each API call executes three distinct cryptographic stages—FHE biometric matching, ZKP cache verification, and post-quantum attestation—all within roughly 42 microseconds per authentication. Your tests must validate each stage independently and then confirm they compose correctly.

Key principle: Never test cryptographic correctness by comparing ciphertext bytes. Ciphertexts are randomized by design. Instead, test the semantic property: encrypt, then decrypt, then compare plaintext. H33's BFV scheme uses a fresh error polynomial on every encryption, so identical plaintexts produce different ciphertexts every time.

Unit Tests: Isolating the Client Layer

Unit tests should cover your client-side integration code without making real API calls. The goal is to verify that your application correctly constructs requests, handles responses, and manages error conditions.

Mocking the H33 SDK

Create deterministic mock responses for each endpoint. The critical responses to mock are the enrollment confirmation, the verification result (match or no-match), and the attestation certificate. Here is a minimal example using a mock server:

// test/mocks/h33-mock.ts
import { setupServer } from "msw/node";
import { rest } from "msw";

const server = setupServer(
  rest.post("https://api.h33.ai/v1/verify", (req, res, ctx) => {
    const { template } = req.body;
    if (!template || template.length !== 128) {
      return res(ctx.status(400), ctx.json({
        error: "INVALID_TEMPLATE",
        message: "Template must be 128 dimensions"
      }));
    }
    return res(ctx.json({
      match: true,
      confidence: 0.97,
      attestation: "dilithium-sig-base64...",
      latency_us: 42,
      pipeline: { fhe_us: 34, zkp_us: 0.085, attest_us: 7.6 }
    }));
  })
);

beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
afterAll(() => server.close());

Notice the pipeline field in the mock response. In production, H33 returns per-stage latency breakdowns. Your unit tests should verify that your code correctly parses these fields, even if the exact values differ between environments. The ZKP lookup stage resolves in approximately 0.085 microseconds via an in-process DashMap cache, while the FHE batch operation for 32 users takes around 1,109 microseconds.

What to Assert in Unit Tests

Integration Tests: Sandbox Environment

H33 provides a sandbox environment at sandbox.h33.ai that mirrors the production pipeline but operates on synthetic biometric templates. Integration tests should exercise the real network path, TLS handshake, and response parsing against this sandbox.

Test CategoryWhat It ValidatesExpected Latency
Enrollment round-tripTemplate accepted, stored, retrievable< 200ms (network-bound)
Verification matchKnown-good template returns match=true< 200ms
Verification rejectRandom template returns match=false< 200ms
Attestation chainDilithium signature verifies against H33 public key< 1ms (local verify)
Rate limit behaviorExceeding quota returns HTTP 429 with Retry-After headerImmediate
Invalid API keyGarbage key returns HTTP 401, not HTTP 500Immediate

Verifying the Attestation Certificate

Every H33 response includes a Dilithium signature that attests to the integrity of the result. This is not decorative—it is the mechanism that prevents a man-in-the-middle from flipping a match: false to match: true. Your integration tests must verify this signature against H33's published public key:

import { verifyDilithium } from "@h33/sdk";
import { H33_PUBLIC_KEY } from "./keys";

test("attestation signature is valid", async () => {
  const result = await h33.verify(enrolledUser, freshTemplate);
  const payload = JSON.stringify({
    match: result.match,
    confidence: result.confidence,
    timestamp: result.timestamp,
  });
  const valid = verifyDilithium(H33_PUBLIC_KEY, payload, result.attestation);
  expect(valid).toBe(true);
});
If you skip attestation verification in production, you lose the post-quantum guarantee entirely. The FHE and ZKP stages protect data confidentiality and proof integrity, but it is the Dilithium signature that binds the result to H33's identity. All three stages must be validated end-to-end.

End-to-End and Load Testing

End-to-end tests run through your full application stack: UI interaction, backend proxy, H33 API call, response handling, and session creation. These tests catch integration failures that neither unit nor integration tests reveal—missing CORS headers, cookie misconfiguration, or race conditions in concurrent authentication flows.

Load Testing Against Production Characteristics

H33's production infrastructure sustains 1.595 million authentications per second on a single Graviton4 node. Your bottleneck will almost certainly be on your side, not on H33's. Load tests should focus on three areas:

Performance tip: H33 batches 32 users per BFV ciphertext using SIMD slot packing (4,096 slots divided by 128 biometric dimensions). If you are enrolling users in bulk, use the batch enrollment endpoint to take advantage of this packing—it processes 32 enrollments in the same ~1,109 microseconds that a single enrollment would take.

Security-Focused Test Cases

Beyond functional correctness, dedicate a test suite to adversarial scenarios. These tests validate that your integration does not inadvertently weaken the security properties that H33 provides:

Continuous Integration Pipeline

Structure your CI pipeline in three stages, each gating the next. Unit tests run on every commit, typically completing in under 10 seconds. Integration tests run against the sandbox on every pull request, adding 30–60 seconds. Load tests and security scans run nightly or before release cuts.

# .github/workflows/auth-tests.yml
jobs:
  unit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm test -- --grep "unit"

  integration:
    needs: unit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm test -- --grep "integration"
    env:
      H33_API_KEY: ${{ secrets.H33_SANDBOX_KEY }}
      H33_BASE_URL: https://sandbox.h33.ai

  load:
    needs: integration
    if: github.event_name == 'schedule'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npx k6 run tests/load/h33-auth.js

A well-structured test suite for H33 integration is not overhead—it is the mechanism by which you inherit the security guarantees of a post-quantum authentication pipeline. The FHE encryption, ZKP proof validation, and Dilithium attestation — all computed on encrypted data — are only as strong as the code that invokes and verifies them. Test thoroughly, test adversarially, and test continuously.

Ready to Go Quantum-Secure?

Start protecting your users with post-quantum authentication today. 1,000 free auths, no credit card required.

Get Free API Key →

Build With Post-Quantum Security

Enterprise-grade FHE, ZKP, and post-quantum cryptography. One API call. Sub-millisecond latency.

Get Free API Key → Read the Docs
Free tier · 10,000 API calls/month · No credit card required
Verify It Yourself