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

@aithos/assets-crypto

v0.1.0-alpha.2

Published

Reference cryptographic primitives for the Aithos assets sub-protocol: AMK generation, X25519-HKDF-AEAD wraps, XChaCha20-Poly1305 byte encryption. See spec/assets/.

Readme

@aithos/assets-crypto

Reference cryptographic primitives for the Aithos assets sub-protocol. Implements AMK (Asset Master Key) generation, X25519-HKDF-AEAD wraps for recipients, XChaCha20-Poly1305 byte encryption with the canonical nonce-prefix on-disk layout, and SHA-256 content-addressing.

Status

Alpha — API surface likely to shift until 0.1.0 stable. Use at your own risk for production.

Install

npm install @aithos/assets-crypto@alpha

Quick start

import {
  generateAMK,
  wrapAMKForRecipient,
  unwrapAMK,
  encryptAssetBytes,
  decryptAssetBytes,
  generateX25519Keypair,
} from "@aithos/assets-crypto";

// 1. Generate keys
const { privateKey, publicKey } = generateX25519Keypair();
const amk = generateAMK();
const assetUrn = "urn:aithos:asset:did:aithos:z6Mkr…:asset_01J…";

// 2. Wrap the AMK for the recipient
const wrap = wrapAMKForRecipient({
  amk,
  recipientPublicKey: publicKey,
  recipientDidUrl: "did:aithos:z6Mkr…#circle-kex",
  assetUrn,
});

// 3. Encrypt the asset bytes
const plaintext = new TextEncoder().encode("My private content");
const { blob, sha256_of_plaintext_hex, size_bytes } = encryptAssetBytes({
  amk,
  assetUrn,
  plaintext,
});

// `blob` is the [nonce(24) | ciphertext+tag] ready to PUT to S3.
// `sha256_of_plaintext_hex` and `size_bytes` go into the asset metadata.

// 4. Later, decrypt
const recoveredAmk = unwrapAMK({
  wrap,
  recipientPrivateKey: privateKey,
  assetUrn,
});

const recovered = decryptAssetBytes({
  amk: recoveredAmk,
  assetUrn,
  blob,
  expectedSha256Hex: sha256_of_plaintext_hex,
});
// recovered === plaintext, byte-for-byte

What's in here

The package is organized around four concerns:

  • amk — AMK generation, wrap, unwrap (spec/assets/02-key-hierarchy.md §2.3).
  • asset — Asset bytes encryption with the nonce-prefix on-disk layout (§2.3.2), public-regime hash verification (§2.6), and helpers.
  • aad — Canonical AAD construction binding ciphertexts to (asset_urn, recipient_did_url).
  • types — Wire-format types (AssetMetadata, AMKEnvelope, WrapEntry, AssetReference) plus base64/hex helpers and the AssetsCryptoError class.

Cryptographic constructions

  • AEAD: XChaCha20-Poly1305 IETF, 24-byte nonce.
  • Key agreement: X25519 (RFC 7748).
  • KDF: HKDF-SHA256 (RFC 5869) with salt "aithos-assets-amk-wrap-v1" and info = recipient DID URL.
  • Content hash: SHA-256.
  • All AADs carry an explicit version marker ("aithos-asset-v1\0", "aithos-assets-amk-v1\0") so cross-version ciphertext substitution fails loudly.

Related packages

| Package | Scope | |---|---| | @aithos/protocol-core | Wire-format primitives, types, canonicalization. | | @aithos/data-crypto | Crypto primitives for the data sub-protocol (CMK/DEK/records). | | @aithos/assets-crypto (this) | Crypto primitives for the assets sub-protocol. | | @aithos/protocol-client | Env-agnostic client: signing, building, API access. |

License

Apache License 2.0. See LICENSE.

The Aithos protocol specification (in the spec/ directory of this repo) is under CC BY 4.0.

Contributing

Issues and pull requests are welcome at github.com/aithos-protocol/aithos-protocol.