Skip to content

Implementation of a secure Bloom filter cascade with padding.

License

Notifications You must be signed in to change notification settings

jfelixh/crset-cascade

Repository files navigation

CRSet Cascade

This project implements a padded Bloom filter cascade based on sha256. It provides utility functions to construct, reconstruct, and verify the presence of elements within the padded Bloom filter cascade. It is intended as a library for the CRSet revocation mechanism for Verifiable Credentials. Instead of using this library directly, consider using the respective higher-level ones for issuers and verifiers:

Usage

This package can be installed directly from the repository:

npm install github:jfelixh/crset-cascade

Then, in your project, import the necessary functions and use them as follows:

import { CRSetCascade, random256BitHexString } from "crset-cascade";

// Elements have to be of uniform generation and must use this method to generate them
const element: string = random256BitHexString();

// Construct a CRSet cascade
const validElements: Set<string> = new Set([element, "...", "..."]); // Set of valid elements
const invalidElements: Set<string> = new Set(["...", "...", "..."]); // Set of invalid elements
const rHat: number = x; // Total targeted size x, where rHat >= |validElements| and rHat >= 2*|invalidElements|
const cascade = CRSetCascade.fromSets(
  validElements,
  invalidElements,
  rHat,
);

// Check if an element is in the CRSet cascade
const result = cascade.has(element); // true if the element is in the CRSet cascade, false otherwise

// Serialize and deserialize the CRSet cascade
const filterHexString = cascade.toDataHexString(); // Hexadecimal string representing the CRSet cascade
const [filter, salt] = CRSetCascade.fromDataHexString(filterHexString); // Reconstruct the CRSet cascade from the hexadecimal string

// Get information about the CRSet cascade
const depth = cascade.getDepth(); // number of layers in the CRSet cascade
const layers = cascade.getLayers(); // array of Bloom filters
const salt = cascade.getSalt(); // salt used to construct the CRSet cascade

Testing

To verify that this implementation works as expected, run the following command in the root directory:

npm test

Acknowledgments

We thank the Ethereum Foundation for funding this work with an Ethereum Academic Grant under reference number FY24-1545.

Links and References

About

Implementation of a secure Bloom filter cascade with padding.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •