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

orion-v2-lattigo

v6.2.4

Published

TypeScript bindings for Lattigo CKKS via Go WASM

Readme

@orion/lattigo

TypeScript bindings for Lattigo's CKKS operations via Go WASM. Enables browser-side key generation, encryption, and decryption — the secret key never leaves the client.

Prerequisites

The WASM binary must be built before use:

python tools/build_lattigo_wasm.py

This compiles js/lattigo/bridge/ to js/lattigo/wasm/lattigo.wasm and copies wasm_exec.js.

Installation

cd js/lattigo
npm install
npm run build

Usage

Node.js

import {
  loadLattigo,
  CKKSParameters,
  KeyGenerator,
  Encoder,
  Encryptor,
  Decryptor,
} from "@orion/lattigo";

// Load the WASM bridge — required before calling any API
const bridge = await loadLattigo("wasm/lattigo.wasm");

// Create CKKS parameters
const params = CKKSParameters.fromLogn({
  logN: 14,
  logQ: [55, 40, 40, 40, 40, 40, 40, 40],
  logP: [55, 55],
  logDefaultScale: 40,
});

// Key generation
const kg = KeyGenerator.new(params);
const sk = kg.genSecretKey();
const pk = kg.genPublicKey(sk);

// Encode → encrypt → decrypt → decode
const encoder = Encoder.new(params);
const encryptor = Encryptor.new(params, pk);
const decryptor = Decryptor.new(params, sk);

const values = new Array(params.maxSlots()).fill(0.5);
const pt = encoder.encode(values, params.maxLevel(), params.defaultScale());
const ct = encryptor.encryptNew(pt);
const decPt = decryptor.decryptNew(ct);
const output = encoder.decode(decPt, params.maxSlots());

// Release handles when done
ct.close();
pt.close();
decPt.close();
encoder.close();
encryptor.close();
decryptor.close();
kg.close();
sk.close();
pk.close();
params.close();

Browser

<script src="wasm/wasm_exec.js"></script>
<script type="module">
  import { loadLattigo, CKKSParameters } from "./dist/index.js";

  // WASM loads from the URL "wasm/lattigo.wasm" by default in the browser
  const bridge = await loadLattigo();
  const params = CKKSParameters.fromLogn({ logN: 14, ... });
  // ...
</script>

Memory Management

Every class has a .close() method that releases the underlying Go handle. Call it when done with an object.

const sk = kg.genSecretKey();
// ... use sk ...
sk.close(); // explicit cleanup

A FinalizationRegistry is registered as a safety net to catch forgotten .close() calls, but GC timing is not deterministic — prefer explicit cleanup for long-lived sessions.

API

  • loadLattigo(wasmPath?) — loads the WASM bridge. Must be called first.
  • CKKSParameters — CKKS scheme parameters. fromLogn(), fromJSON(), accessors.
  • KeyGenerator — generates secret, public, relinearization, and Galois keys.
  • Encoder — encodes/decodes float64 values to/from plaintexts.
  • Encryptor — encrypts plaintexts to ciphertexts.
  • Decryptor — decrypts ciphertexts to plaintexts.
  • MemEvaluationKeySet — bundles RLK + Galois keys for serialization.
  • Key types: SecretKey, PublicKey, RelinearizationKey, GaloisKey, Ciphertext, Plaintext.

All key and ciphertext types support .marshalBinary() / static unmarshalBinary(bytes) for Lattigo-compatible serialization.

Examples

See js/examples/node/ for full usage examples:

  • roundtrip.ts — keygen, encode, encrypt, decrypt, decode with timing
  • eval-keys.ts — full key generation from a KeyManifest (RLK + Galois keys + bootstrap keys)

Tests

npm test

Tests require the WASM binary to be built first.