Mnemonic/seed phrase utilities for Session messenger. Seed hex (and thus random mnemonic and random Session ID) can be generated using @session.js/keypair.
To encode mnemonic:
import { encode } from '@session.js/mnemonic'
encode('39038c8988db02c1af44e8c847bd9713') // => 'puffin luxury annoyed rustled memoir faxed smidgen puddle kiwi nylon utopia zinger kiwi'
To decode mnemonic:
import { decode } from '@session.js/mnemonic'
decode('puffin luxury annoyed rustled memoir faxed smidgen puddle kiwi nylon utopia zinger kiwi') // => '39038c8988db02c1af44e8c847bd9713'
Install @session.js/keypair to generate random seed hex.
Hint: Session IDs are x25519 aka Curve25519 public keys prepended with
05
import { generateSeedHex, getKeypairFromSeed } from '@session.js/keypair'
import { encode } from '@session.js/mnemonic'
const seedHex = generateSeedHex()
const keypair = getKeypairFromSeed(seedHex)
const mnemonic = encode(seedHex)
const sessionID = keypair.x25519.publicKey
console.log('Generated session ID:', sessionID)
console.log('Mnemonic for it:', mnemonic)
By default, this package comes only with english dictionary. You can add your own mnemonic languages:
import { decode, mnemonicLanguages, addMnemonicLanguage } from '@session.js/mnemonic'
mnemonicLanguages.russian = addMnemonicLanguage({
prefixLen: 3,
words: [/* ... */]
})
decode('любовь любовь любовь любовь любовь любовь любовь любовь любовь любовь любовь любовь любовь', 'russian')
Use Session messenger programmatically with Session.js: Session bots, custom Session clients, and more.