Session messenger & Session.js keypairs utilities. https://www.npmjs.com/package/@session.js/keypair
Find a file
Nikolai Konovalov 54be566ed6
feat: Merge PR #1 from li0ard/purejs
Migrating to `@noble/curves`
2025-06-25 03:14:43 +06:00
src refactor: Remove unnecessary Uint8Array constructors 2025-06-19 21:32:06 +06:00
tests test: add tests 2025-06-19 21:23:49 +06:00
.gitignore Initial commit 2024-06-20 20:45:14 +04:00
bun.lockb refactor: migrate to @noble/curves 2025-06-19 21:24:27 +06:00
package.json bump version 2025-06-19 21:28:36 +06:00
README.md docs: update docs in README 2025-06-25 03:13:19 +06:00
tsconfig.build.json Initial commit 2024-06-20 20:45:14 +04:00
tsconfig.json Initial commit 2024-06-20 20:45:14 +04:00

@session.js/keypair

Session messenger & Session.js keypairs utilities.

type Keypair

Keypair is a pair of two Sodium-like KeyPairs: x25519 (curve25519) and ed25519

type Keypair = {
  x25519: SodiumKeypair
  ed25519: SodiumKeypair
}

Session ID consists of x25519's public key prepended with 05.

Ed25519 keypairs are used mainly for messages encryption.

getKeypairFromSeed

Converts seed hex to Keypair:

import { getKeypairFromSeed } from '@session.js/keypair'

const keypairs = getKeypairFromSeed('39038c8988db02c1af44e8c847bd9713')
console.log(keypairs.x25519.publicKey) // => 0548054830367d369d94605247999a375dbd0a0f65fdec5de1535612bcb6d4de452c69

generateSeedHex

Generates random seed and converts it to hex. Under the hood it uses CSPRNG from @noble/curves.

import { generateSeedHex } from '@session.js/keypair'

const seed = await generateSeedHex()
console.log(seed) // => 39038c8988db02c1af44e8c847bd9713

Made for session.js

Use Session messenger programmatically with Session.js: Session bots, custom Session clients, and more.

Donate

hloth.dev/donate