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

@kraki/crypto

v0.2.5

Published

Kraki encryption: X25519/HKDF/AES-GCM, Ed25519 and legacy RSA compatibility

Readme

@kraki/crypto

Encryption helpers owned and maintained in the Kraki monorepo.

  • src/v2.ts: synchronous Node X25519/HKDF-SHA256/AES-256-GCM envelope.
  • src/web/ (@kraki/crypto/web): asynchronous Web Crypto implementation.
  • SwiftCrypto/: CryptoKit implementation (module name CoinfraCrypto retained for source compatibility).
  • src/trust.ts: Ed25519 message signatures and replay helpers.
  • src/__tests__/fixtures/: canonical cross-language vectors.

The Web Crypto implementation was imported from corelli18512/coinfra at e23b2f8ef093605186cb910663778e0b711d8bfe (crypto 0.2.0); Swift is the implementation already shipped by Kraki. Kraki is now the source of truth for all three. Historical wire identifiers (including coinfra-crypto/v1 kek) are protocol constants, not repository names: do not rename them when moving code. See ENVELOPE.md for the imported envelope specification. The old external npm package is not required to build or release Kraki.

The legacy RSA APIs below remain available for older clients.

Preview: @kraki/crypto is still evolving with the rest of the protocol and device model.

This package provides the Node.js crypto primitives used by Kraki for multi-recipient message encryption, blob encoding, and challenge-response signing.

Install

npm i @kraki/crypto

What it includes

  • RSA-OAEP 4096-bit key generation
  • AES-256-GCM payload encryption
  • per-recipient wrapped keys for multi-device delivery
  • blob encoding: base64(iv ‖ ciphertext ‖ tag)
  • blob-level encrypt/decrypt helpers
  • compact public-key export/import helpers
  • challenge signing and verification helpers

Blob API

encryptToBlob(plaintext, recipients) → { blob, keys }

Encrypts a plaintext string for one or more recipients. Returns a single base64 blob (iv ‖ ciphertext ‖ tag) and a map of wrapped AES keys, one per recipient device.

decryptFromBlob({ blob, keys }, deviceId, privateKey) → plaintext

Decrypts a blob using the calling device's private key. Looks up the wrapped key by deviceId, unwraps it with RSA-OAEP, and decrypts the blob.

payloadToBlob(payload) → blobPayload

Converts a legacy separated payload (iv, ciphertext, tag, keys) into the consolidated blob format.

blobToPayload(blobPayload) → payload

Converts a blob payload back into separated fields. Useful for interop or debugging.

Blob format

The blob is a single base64 string encoding the concatenation of:

  1. IV — 12 bytes (AES-256-GCM initialization vector)
  2. Ciphertext — variable length
  3. Tag — 16 bytes (GCM authentication tag)

This keeps the wire format compact — one string instead of three separate fields.

Example

import { generateKeyPair, encryptToBlob, decryptFromBlob } from '@kraki/crypto';

const alice = generateKeyPair();

const { blob, keys } = encryptToBlob('hello from kraki', [
  { deviceId: 'alice', publicKey: alice.publicKey },
]);

const plaintext = decryptFromBlob({ blob, keys }, 'alice', alice.privateKey);

This package currently targets Node.js via the built-in crypto module.

Links

  • Main docs: https://github.com/corelli18512/kraki/blob/main/README.md
  • Security model: https://github.com/corelli18512/kraki/blob/main/SECURITY.md