npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@midnight-ntwrk/midnight-js-http-client-proof-provider

v4.0.2

Published

Implementation of proof provider based on the Midnight ledger proof server

Readme

HTTP Client Proof Provider

HTTP client for interacting with Midnight proof servers to generate zero-knowledge proofs.

Installation

yarn add @midnight-ntwrk/midnight-js-http-client-proof-provider

Quick Start

import { httpClientProofProvider } from '@midnight-ntwrk/midnight-js-http-client-proof-provider';

const proofProvider = httpClientProofProvider(
  'http://localhost:6300',
  zkConfigProvider
);

const provenTx = await proofProvider.proveTx(unprovenTx);

Configuration

| Option | Required | Default | Description | | ------------------ | -------- | -------- | ---------------------------------------------- | | url | ✓ | - | Proof server URL (http/https only) | | zkConfigProvider | ✓ | - | Provider for ZK configuration artifacts | | timeout | | 300000 | Request timeout in milliseconds (5 minutes) |

Architecture

This package provides two abstraction levels for proof generation:

ProofProvider (httpClientProofProvider) - Transaction-level
    ↓ uses internally
ProvingProvider (httpClientProvingProvider) - Circuit-level
    ↓ HTTP requests
Proof Server (/check, /prove endpoints)

High-Level: Transaction Proving

Use httpClientProofProvider for most use cases. It handles complete transactions by orchestrating individual circuit proofs internally.

import { httpClientProofProvider } from '@midnight-ntwrk/midnight-js-http-client-proof-provider';

const proofProvider = httpClientProofProvider(
  'http://localhost:6300',
  zkConfigProvider
);

const provenTx = await proofProvider.proveTx(unprovenTx);

Low-Level: Circuit Proving

Use httpClientProvingProvider for advanced scenarios requiring fine-grained control over individual circuit proving operations.

import { httpClientProvingProvider } from '@midnight-ntwrk/midnight-js-http-client-proof-provider';

const provingProvider = httpClientProvingProvider(
  'http://localhost:6300',
  zkConfigProvider
);

const checkResult = await provingProvider.check(serializedPreimage, circuitId);
const proof = await provingProvider.prove(serializedPreimage, circuitId);

API

ProofProvider (High-Level)

proveTx(unprovenTx: UnprovenTransaction): Promise<UnboundTransaction>

Proves all circuits in a transaction and returns the proven transaction.

ProvingProvider (Low-Level)

check(serializedPreimage: Uint8Array, keyLocation: string): Promise<(bigint | undefined)[]>

Validates circuit inputs before proof generation.

prove(serializedPreimage: Uint8Array, keyLocation: string, overwriteBindingInput?: bigint): Promise<Uint8Array>

Generates a zero-knowledge proof for a circuit.

URL Configuration

The provider supports complex URL configurations including path prefixes and query parameters.

Path Prefix

const proofProvider = httpClientProofProvider(
  'http://localhost:6300/api/v1',
  zkConfigProvider
);
// Endpoints: /api/v1/check, /api/v1/prove

Query Parameters

const proofProvider = httpClientProofProvider(
  'http://localhost:6300?token=your-api-key',
  zkConfigProvider
);
// Endpoints: /check?token=your-api-key, /prove?token=your-api-key

Combined Path and Query

const proofProvider = httpClientProofProvider(
  'http://localhost:6300/api/v1?token=your-api-key&env=production',
  zkConfigProvider
);
// Endpoints: /api/v1/check?token=your-api-key&env=production

URL Behavior

| Base URL | /check Endpoint | /prove Endpoint | | --------------------------------- | --------------------------------------- | --------------------------------------- | | http://localhost:6300 | /check | /prove | | http://localhost:6300/ | /check | /prove | | http://localhost:6300/api/v1 | /api/v1/check | /api/v1/prove | | http://localhost:6300/api/v1/ | /api/v1/check | /api/v1/prove | | http://localhost:6300?token=abc | /check?token=abc | /prove?token=abc |

Timeout Configuration

const proofProvider = httpClientProofProvider(
  'http://localhost:6300',
  zkConfigProvider,
  { timeout: 60000 } // 60 seconds
);

Retry Behavior

The provider automatically retries failed requests with exponential backoff:

| Attempt | Delay | Retried Status Codes | | ------- | -------- | -------------------- | | 1 | 1 second | 500, 503 | | 2 | 2 seconds| 500, 503 | | 3 | 4 seconds| 500, 503 |

Error Handling

Invalid Protocol

Only http: and https: protocols are supported.

// Throws InvalidProtocolSchemeError
httpClientProofProvider('ws://localhost:6300', zkConfigProvider);

Server Errors

HTTP errors throw with details about the failed request:

Failed Proof Server response: url="http://localhost:6300/prove", code="500", status="Internal Server Error"

Exports

import {
  // High-level: Transaction proving
  httpClientProofProvider,
  DEFAULT_CONFIG,

  // Low-level: Circuit proving
  httpClientProvingProvider,
  DEFAULT_TIMEOUT,
  type ProvingProviderConfig
} from '@midnight-ntwrk/midnight-js-http-client-proof-provider';

Detailed

Server Endpoints

| Endpoint | Method | Description | | -------- | ------ | ---------------------------------- | | /check | POST | Validate circuit inputs | | /prove | POST | Generate zero-knowledge proof |

Default Values

| Constant | Value | Description | | ----------------- | -------- | ------------------------ | | DEFAULT_TIMEOUT | 300000 | 5 minutes in ms |

Request Flow

┌─────────────────────────────────────────────────────────────────┐
│                   httpClientProofProvider                        │
│                                                                  │
│  ┌──────────────────┐                                            │
│  │ proveTx()        │                                            │
│  │ (transaction)    │                                            │
│  └────────┬─────────┘                                            │
│           │                                                      │
│           ▼                                                      │
│  ┌──────────────────────────────────────────────────────┐        │
│  │            httpClientProvingProvider                  │        │
│  │                                                       │        │
│  │  ┌─────────────┐    ┌─────────────┐    ┌──────────┐  │        │
│  │  │ ZKConfig    │───►│ check()     │───►│ /check   │  │        │
│  │  │ Provider    │    │ prove()     │───►│ /prove   │  │        │
│  │  └─────────────┘    └─────────────┘    └──────────┘  │        │
│  │                           │                  │        │        │
│  │                           ▼                  ▼        │        │
│  │                    ┌─────────────────────────────┐    │        │
│  │                    │ Retry Logic (3 attempts)    │    │        │
│  │                    │ Exponential backoff         │    │        │
│  │                    └─────────────────────────────┘    │        │
│  └──────────────────────────────────────────────────────┘        │
└─────────────────────────────────────────────────────────────────┘

Resources

Terms & License

By using this package, you agree to Midnight's Terms and Conditions and Privacy Policy.

Licensed under Apache License 2.0.