Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@bcts/crypto

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bcts/crypto

Blockchain Commons Cryptographic Utilities for TypeScript

latest
Source
npmnpm
Version
1.0.0-beta.0
Version published
Maintainers
1
Created
Source

Blockchain Commons Crypto Interfaces for TypeScript

Disclaimer: This package is under active development and APIs may change.

Introduction

@bcts/crypto exposes a uniform API for the cryptographic primitives used in higher-level Blockchain Commons projects such as Gordian Envelope.

Features

  • Hash Functions: SHA-256, SHA-512, HMAC, PBKDF2, HKDF, CRC32
  • Symmetric Encryption: ChaCha20-Poly1305 AEAD
  • Public Key Cryptography:
    • X25519 (key agreement)
    • ECDSA (secp256k1 signing/verification)
    • Schnorr signatures (BIP-340)
    • Ed25519 (signing/verification)
  • Key Derivation: Scrypt, Argon2id
  • Memory Security: Best-effort memory zeroing utilities

Security Considerations

Memory Zeroing (memzero)

⚠️ IMPORTANT SECURITY LIMITATION

The memzero() function provides best-effort memory clearing in JavaScript/TypeScript, but cannot guarantee that sensitive data is fully erased from memory.

Why this limitation exists:

  • JavaScript/TypeScript lacks volatile memory writes (unlike the Rust reference implementation which uses std::ptr::write_volatile())
  • JavaScript engines and JIT compilers may optimize away zeroing operations
  • The garbage collector may have made copies of sensitive data
  • Swapped pages or memory dumps may contain copies

What memzero() does:

  • ✅ Overwrites memory with zeros to reduce exposure time
  • ✅ Makes a verification check to prevent some optimizations
  • ❌ Cannot guarantee complete erasure from physical memory

Best practices for sensitive operations:

  • Use Web Crypto API when possible: For truly sensitive cryptographic operations, use crypto.subtle with non-extractable keys
  • Minimize exposure time: Call memzero() immediately after sensitive operations
  • Understand the limitations: This is defense-in-depth, not a security guarantee
  • Consider your threat model: Evaluate if JavaScript is appropriate for your security requirements

Example:

import { memzero } from '@bcts/crypto';

const sensitiveKey = new Uint8Array(32);
// ... use the key ...

// Clear from memory (best effort)
memzero(sensitiveKey);

For more details, see the implementation comments.

Rust Reference Implementation

This TypeScript implementation is based on bc-crypto-rust v0.14.0 (commit).

Keywords

crypto

FAQs

Package last updated on 27 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts