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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nillion/blindfold

v0.1.0

Published

Library for working with encrypted data within NilDB queries and replies.

Readme

blindfold-ts

npm ci coveralls

Library for working with encrypted data within nilDB queries and replies.

Description and Purpose

This library provides cryptographic operations that are compatible with nilDB nodes and clusters, allowing developers to leverage certain privacy-enhancing technologies (PETs) when storing, operating upon, and retrieving data while working with nilDB. The table below summarizes the functionalities available in blindfold.

| Cluster | Operation | Implementation Details | Supported Types | |----------------|-----------|-------------------------------------------------------------------|---------------------------------------------------| | single node | store | XSalsa20 stream cipher and Poly1305 MAC | 32-bit signed integer; UTF-8 string (<4097 bytes) | | single node | match | deterministic salted hashing via SHA-512 | 32-bit signed integer; UTF-8 string (<4097 bytes) | | single node | sum | non-deterministic Paillier with 2048-bit primes | 32-bit signed integer | | multiple nodes | store | XOR-based secret sharing | 32-bit signed integer; UTF-8 string (<4097 bytes) | | multiple nodes | match | deterministic salted hashing via SHA-512 | 32-bit signed integer; UTF-8 string (<4097 bytes) | | multiple nodes | sum | additive secret sharing (no threshold; prime modulus 2^32 + 15) | 32-bit signed integer | | multiple nodes | sum | Shamir's secret sharing (with threshold; prime modulus 2^32 + 15) | 32-bit signed integer |

The library supports two categories of keys:

  1. SecretKey: Keys in this category support operations within a single node or across multiple nodes. These contain cryptographic material for encryption, decryption, and other operations. Notably, a SecretKey instance includes blinding masks that a client need not share with the cluster. By using SecretKey instances a client can retain exclusive access to its data even if all servers in a cluster collude.

  2. ClusterKey: Keys in this category represent cluster configurations but do not contain cryptographic material. These can be used only when working with multiple-node clusters. Unlike SecretKey instances, ClusterKey instances do not incorporate blinding masks. This means each node in a cluster has access to a raw secret share of the encrypted data and, therefore, the data is only protected if the nodes in the cluster do not collude.

Threshold secret sharing is supported when encrypting in a summation-compatible way for multiple-node clusters. A threshold specifies the minimum number of nodes required to reconstruct the original data. Shamir's secret sharing is employed when encrypting with a threshold value, ensuring that encrypted data can only be decrypted if the required number of shares is available.

Package Installation and Usage

The package can be installed using pnpm:

pnpm install

The library can be imported in the usual way:

import { blindfold } from "@nillion/blindfold";

Example: Generating Keys

The example below generates a SecretKey instance for a single-node cluster:

const cluster = {"nodes": [{}]};
const secretKey = await blindfold.SecretKey.generate(cluster, {"store": true});

The example below generates a SecretKey instance for a multiple-node (i.e., three-node) cluster with a two-share decryption threshold:

const cluster = {"nodes": [{}, {}, {}]};
const secretKey = await blindfold.SecretKey.generate(cluster, {"sum": true}, 2);

Example: Encrypting and Decrypting Data

The below example encrypts and decrypts a string:

const secretKey = await blindfold.SecretKey.generate({"nodes": [{}]}, {"store": true});
const plaintext = "abc";
const ciphertext = await blindfold.encrypt(secretKey, plaintext);
const decrypted = await blindfold.decrypt(secretKey, ciphertext);
console.log(plaintext, decrypted); // Should output `abc abc`.

The below example encrypts and decrypts an integer:

const secretKey = await blindfold.SecretKey.generate({"nodes": [{}, {}, {}]}, {"sum": true}, 2);
const plaintext = BigInt(123);
const ciphertext = await blindfold.encrypt(secretKey, plaintext);
const decrypted = await blindfold.decrypt(secretKey, ciphertext);
console.log(plaintext, decrypted); // Should output `123n 123n`.

Testing and Conventions

All unit tests are executed and their coverage measured with vitest:

pnpm test

Style conventions are enforced using biomejs:

pnpm lint

Types are checked with:

pnpm typecheck

The distribution files are checked with:

pnpm exportscheck

Contributions

In order to contribute, open an issue or submit a pull request on the GitHub. To enforce conventions, git hooks are provided and can be setup with:

pnpm install-hooks

Versioning

The version number format for this library and the changes to the library associated with version number increments conform with Semantic Versioning 2.0.0.