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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@zhoujun_aptos/octopus-ts-sdk

v0.3.0

Published

octopus-ts-sdk

Readme

Octopus TypeScript SDK

This TypeScript SDK provides cryptographic operations for the Aptos crypto oracle, including ElGamal encryption over BLS12-381 curves with AES-256-GCM for symmetric encryption.

Features

  • ElGamal Encryption: Public-key encryption over BLS12-381 elliptic curves
  • AES-256-GCM: Authenticated symmetric encryption for bulk data
  • Hybrid Encryption: Combines asymmetric and symmetric encryption for efficiency
  • TypeScript Support: Full TypeScript support with proper type definitions
  • Serialization: Support for Aptos Move serialization format

Installation

npm install

Building

npm run build

Testing

The project includes comprehensive test coverage for all cryptographic operations:

Running Tests

# Run tests in watch mode
npm test

# Run tests once
npm run test:run

# Run tests with coverage
npm run test:coverage

Test Coverage

The test suite covers:

  1. Key Generation

    • Valid key pair generation
    • Uniqueness of generated keys
    • BLS12-381 curve point validation
  2. Encryption & Decryption

    • Basic encryption/decryption functionality
    • Empty and large plaintext handling
    • Binary data support
    • Unicode text support
    • Wrong key rejection
  3. Serialization

    • Byte array serialization/deserialization
    • Hex encoding/decoding
    • Key integrity preservation
  4. Error Handling

    • Corrupted ciphertext handling
    • Truncated data handling
    • Invalid input validation
  5. Cryptographic Properties

    • Semantic security verification
    • Key privacy validation
    • Multiple encryption support
  6. Performance & Edge Cases

    • Multiple key generation efficiency
    • Large data handling
    • Boundary condition testing

Usage

import { keygen, encrypt, tryDecrypt } from './src/elgamal_bls12381_aes256gcm';

// Generate key pair
const { privateKey, publicKey } = keygen();

// Encrypt data
const plaintext = new TextEncoder().encode('Hello, World!');
const ciphertext = encrypt(publicKey, plaintext);

// Decrypt data
const decrypted = tryDecrypt(privateKey, ciphertext);
console.log(new TextDecoder().decode(decrypted)); // "Hello, World!"

Dependencies

  • @aptos-labs/ts-sdk: Aptos TypeScript SDK for serialization
  • @noble/curves: BLS12-381 elliptic curve implementation
  • @noble/hashes: SHA-256 hash function
  • crypto: Node.js built-in cryptographic functions

Security

This implementation provides:

  • Semantic Security: Same plaintext produces different ciphertexts
  • Key Privacy: Ciphertexts don't reveal the public key
  • Authenticated Encryption: AES-GCM provides both confidentiality and authenticity
  • Post-Quantum Resistance: BLS12-381 curves provide quantum resistance