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

@phantom/crypto

v1.0.2

Published

Cryptographic utilities for Phantom SDK

Readme

@phantom/crypto

Cryptographic utilities for Phantom SDK, providing Ed25519 key generation, key pair management, and digital signing functionality.

Features

  • Ed25519 Key Pair Generation: Generate cryptographically secure key pairs
  • Key Pair Recovery: Recreate key pairs from existing secret keys
  • Digital Signing: Sign data using Ed25519 with detached signatures
  • Base58 Encoding: All keys are encoded in base58 format for compatibility
  • Cross-platform: Works in both Node.js and browser environments

Installation

npm install @phantom/crypto
# or
yarn add @phantom/crypto

Usage

Generate a New Key Pair

import { generateKeyPair } from "@phantom/crypto";

const keyPair = generateKeyPair();
console.log("Public Key:", keyPair.publicKey);
console.log("Secret Key:", keyPair.secretKey);

Create Key Pair from Existing Secret Key

import { createKeyPairFromSecret } from "@phantom/crypto";

const existingSecretKey = "your-base58-encoded-secret-key";
const keyPair = createKeyPairFromSecret(existingSecretKey);
console.log("Recovered Public Key:", keyPair.publicKey);

Sign Data

import { signWithSecret } from "@phantom/crypto";

const secretKey = "your-base58-encoded-secret-key";
const message = "Hello, world!";

const signature = signWithSecret(secretKey, message);
console.log("Signature:", signature);

API Reference

Types

Keypair

interface Keypair {
  publicKey: string; // Base58-encoded public key
  secretKey: string; // Base58-encoded secret key
}

Functions

generateKeyPair(): Keypair

Generates a new Ed25519 key pair with cryptographically secure random keys.

Returns: A Keypair object with base58-encoded public and secret keys.

createKeyPairFromSecret(b58PrivateKey: string): Keypair

Reconstructs a key pair from an existing base58-encoded secret key.

Parameters:

  • b58PrivateKey: Base58-encoded private key string

Returns: A Keypair object with the corresponding public key derived from the secret key.

signWithSecret(secretKey: string | Uint8Array, data: string | Uint8Array | Buffer): Uint8Array

Signs data using Ed25519 with a secret key, producing a detached signature.

Parameters:

  • secretKey: Base58-encoded secret key string or raw Uint8Array
  • data: Data to sign (accepts string, Uint8Array, or Buffer)

Returns: Raw signature as Uint8Array

Security Notes

  • Always keep secret keys secure and never expose them in client-side code
  • Use cryptographically secure random number generation (provided by TweetNaCl)
  • Ed25519 provides strong security with 128-bit security level
  • Signatures are deterministic but secure against forgery

Dependencies

This package uses:

  • TweetNaCl: Cryptographic library for Ed25519 operations
  • bs58: Base58 encoding/decoding
  • buffer: Buffer polyfill for cross-platform compatibility

License

MIT