Packages
@qubic.org/crypto
KangarooTwelve hashing, SchnorrQ signatures, FourQ key derivation, and identity encoding.
Introduction
Algorithms
| Algorithm | Role |
|---|---|
| KangarooTwelve (K12) | Hashing — used for transaction hashes, identity derivation, and message digests |
| FourQ | Elliptic curve — Qubic's choice of curve for key pairs; faster than Curve25519 at equivalent security |
| SchnorrQ | Signature scheme — Schnorr variant over FourQ; used to sign transactions |
Key concepts
- A seed is a 55-char lowercase string that represents a private key. It is the master secret — never expose it.
- A public key is the 32-byte FourQ point derived from the seed via
publicKeyFromSeed. - An identity is the 60-char uppercase human-readable encoding of the public key, derived via
identityFromSeedorpublicKeyToIdentity.
@qubic.org/wallet wraps all of this into a higher-level API. Use @qubic.org/crypto directly only when you need raw bytes — e.g., for building custom transaction formats or integrating with hardware wallets.
Installation
bun add @qubic.org/cryptonpm install @qubic.org/cryptopnpm add @qubic.org/cryptoAPI reference
| Page | What's covered |
|---|---|
| Key derivation | publicKeyFromSeed, identityFromSeed, identityToPublicKey, publicKeyToIdentity |
| Hashing | K12 — KangarooTwelve variable-output hash |
| Signing | sign, verify — SchnorrQ transaction signing |
All exports
import {
// Key derivation
publicKeyFromSeed,
identityFromSeed,
identityToPublicKey,
publicKeyToIdentity,
// Hashing
K12,
// Signing
sign,
verify,
} from "@qubic.org/crypto"Examples
Derive a key pair from a seed
import { publicKeyFromSeed, identityFromSeed } from "@qubic.org/crypto"
import { toSeed } from "@qubic.org/types"
const seed = toSeed("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
const publicKey = publicKeyFromSeed(seed) // Uint8Array (32 bytes)
const identity = identityFromSeed(seed) // Identity ("BPFJANADBBEOEHGEAGBPJCH...")Hash arbitrary data
import { K12 } from "@qubic.org/crypto"
const data = new TextEncoder().encode("hello qubic")
const hash = K12(data, 32) // Uint8Array (32 bytes)Sign a transaction digest
import { sign, verify } from "@qubic.org/crypto"
import { toSeed } from "@qubic.org/types"
const seed = toSeed("aaaa...") // 55-char seed
const digest = new Uint8Array(32) // transaction digest bytes
const signature = await sign(seed, digest) // Uint8Array (64 bytes)
const valid = await verify(publicKey, digest, signature) // booleanConvert between identity and public key
import { identityToPublicKey, publicKeyToIdentity } from "@qubic.org/crypto"
import { toIdentity } from "@qubic.org/types"
const identity = toIdentity("CFBMEMZOIDEXQAUXYYSZIURADQLAPWPMNJXQSNVQZAHYVOPYUKKJBJUCTVJL")
const publicKey = identityToPublicKey(identity) // Uint8Array (32 bytes)
const recovered = publicKeyToIdentity(publicKey) // Identity — same as input