MCPcopy Index your code
hub / github.com/blyssprivacy/sdk

github.com/blyssprivacy/sdk @0.1.9

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.1.9 ↗ · + Follow
982 symbols 3,036 edges 121 files 178 documented · 18% updated 2y ago0.1.9 · 2023-04-24★ 3507 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

blyss

Open-source SDK for accessing data privately using homomorphic encryption.

Docs   |   Website   |   Contact

The Blyss SDK is released under the MIT license. Blyss SDK on NPM Chat on Signal Blyss Twitter Blyss GitHub stars

The Blyss SDK lets you use homomorphic encryption to retrieve information privately. With it, you can build new kinds of privacy-preserving services, like private password breach checking, private nameserver resolution, and even private Wikipedia.

You can get an API key by signing up, or run a server locally. Detailed documentation is at docs.blyss.dev.

Warning The SDK has not yet been security reviewed, and the public Blyss service is still in beta. Contact us for access to a production-ready service.

Quick start (cloud)

You can quickly try using the SDK with our managed service without downloading anything.

  1. Get an API key by signing up here.
  2. Open this StackBlitz and enter your API key where it says <YOUR API KEY HERE>.
  3. Try adding users to the service using the "Add a user" button. As you add more users, the service will privately intersect each new users's contacts and the already existing users. Every user's list of contacts stays completely private using homomorphic encryption: it never leaves their device unencrypted.

We also have a simpler example using vanilla JS.

Quick start (local)

You can also use the Blyss SDK completely locally.

  1. Clone this repo with git clone git@github.com:blyssprivacy/sdk.git.
  2. Run the server by entering lib/server and running cargo run --release. The server will run on localhost:8008 by default.
  3. Run the client by entering examples/node-local and running npx ts-node main.ts. This will perform some writes and then a private read to your bucket.

Installing as a package

To use the Blyss SDK in an existing TypeScript project, install it with npm install @blyss/sdk. Then, import the client with import { Client } from '@blyss/sdk';. If you're using SDK in Node, and prefer not to use ESM, you can instead import it as const blyss = require('@blyss/sdk/node').

Examples

The examples/ directory has several examples of how to use the Blyss SDK. Running the examples requires an API key.

Browser

The browser example shows how to quickly start using the Blyss SDK from vanilla JavaScript. The blyss-bundle.min.js build output is a single-file JS bundle that binds the library to window.blyss. Including this is a fast way to get started, especially if you prefer to use vanilla JS.

  1. Edit examples/browser-simple/main.js to use your API key.
  2. Run a local HTTP server (we suggest serve) in the repo root.
  3. Go to http://localhost:3000/examples/browser-simple/ in a browser.

React

The React example shows how to use the Blyss SDK in modern client-side JS. It also implements a more complicated application: private contact intersection.

  1. Enter examples/react-complex, and run npm install.
  2. Edit src/App.tsx to use your API key.
  3. Run npm run start.

Node

The Node.js example shows how to use the Blyss SDK in server-side JS. Node 18+ is required.

  1. Enter examples/node, and run npm install.
  2. Edit main.ts to use your API key.
  3. Run ts-node main.ts.

Python

  1. Enter examples/python.
  2. Run pip install blyss.
  3. Run python main.py.

Documentation

All documentation is available at docs.blyss.dev. You can generate the docs by running npm start in docs/.

Contributing

Please feel free to open issues and pull requests! For bugs, try to provide as much context as possible. We are also always open to documentation contributions.

Building from source

JavaScript / Node

  1. Install Node with nvm, Rust with rustup, and wasm-pack.
  2. Run npm install.
  3. Run npm run build.

This will build the complete SDK, including the core Rust libraries in lib/spiral-rs and lib/doublepir

Python

Requires python 3.8+. 1. Run pip install . in python.

Repository Map

The Blyss SDK is structured as:

  1. lib/,
  2. lib/server/, a Rust project containing the open-source Blyss server.
  3. lib/spiral-rs/, a Rust crate containing the core cryptographic implementation of the Spiral PIR scheme.
  4. lib/doublepir/, a Rust crate containing the core cryptographic implementation of the DoublePIR scheme.
  5. js/, the TypeScript code that implements the user-facing Blyss SDK.
  6. js/bridge/, a Rust "bridge" crate that exposes key functionality from spiral-rs and doublepir to the TypeScript code.
  7. python/, the Python version of the SDK.
  8. python/src/lib.rs, another Rust "bridge" crate that exposes key functionality from spiral-rs to the Python code.

License

MIT (see LICENSE.md)

Extension points exported contracts — how you extend this code

Serialize (Interface)
(no doc) [4 implementers]
lib/doublepir/src/serializer/serializer.rs
PolyMatrix (Interface)
(no doc) [2 implementers]
lib/spiral-rs/src/poly.rs
BucketParameters (Interface)
(no doc)
js/bucket/bucket_service.ts
Log (Interface)
(no doc)
examples/valentines/src/util.tsx
User (Interface)
(no doc)
examples/react-complex/src/App.tsx
Deserialize (Interface)
(no doc) [3 implementers]
lib/doublepir/src/serializer/serializer.rs
NoiseEstimator (Interface)
(no doc) [1 implementers]
lib/spiral-rs/src/noise_estimate.rs
ApiConfig (Interface)
(no doc)
js/bucket/bucket_service.ts

Core symbols most depended-on inside this repo

zero
called by 150
js/compression/pako.js
len
called by 70
lib/server/src/db/aligned_memory.rs
ntt
called by 45
lib/spiral-rs/src/poly.rs
map
called by 39
lib/doublepir/src/matrix/indexing.rs
len
called by 37
lib/spiral-rs/src/aligned_memory.rs
get_poly_mut
called by 35
lib/spiral-rs/src/poly.rs
put_byte
called by 31
js/compression/pako.js
init
called by 31
lib/doublepir/src/doublepir/doublepir.rs

Shape

Function 558
Method 357
Class 49
Interface 16
Enum 2

Languages

Rust65%
TypeScript25%
Python10%

Modules by API surface

js/compression/pako.js92 symbols
lib/spiral-rs/src/poly.rs64 symbols
lib/spiral-rs/src/client.rs55 symbols
lib/spiral-rs/src/arith.rs43 symbols
js/bucket/bucket.ts31 symbols
python/blyss/api.py30 symbols
lib/spiral-rs/src/server.rs27 symbols
js/client/api.ts26 symbols
python/blyss/bucket.py24 symbols
lib/spiral-rs/src/util.rs24 symbols
lib/spiral-rs/src/params.rs23 symbols
lib/doublepir/src/doublepir/client.rs21 symbols

For agents

$ claude mcp add sdk \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact