Notably Polite Mariner

    TypeScript icon, indicating that this package has built-in type declarations

    1.0.2 • Public • Published


    Stellar HD Accounts Generator - library.

    npm version npm license GitHub top language GitHub code size GitHub tag

    $ npm i @stellar-fox/redshift


    hierarchical deterministic addresses

    Mnemonic (a lists of specially prepared words) can be used to generate deterministic series of account addresses. The method implemented here uses 24 (or 12) words to generate series of deterministic Stellar key pairs. 24 word mnemonics are also used by many hardware wallets (such as Ledger Nano S). This library can also be used to restore account based on the mnemonic that was generated earlier by either the hardware wallet or any other wallets compatible with BIP-0032, BIP-0039, BIP-0043, BIP-0044, SLIP-0010, SLIP-0044 and SEP-0005 specifications.

    multi-account hierarchy for deterministic wallets

    redshift library uses BIP-0032 path with a hardened derivation. One can choose to derive key pair for default account (with account number equal to 0) or select other account number in m / 44' / 148' / account' hierarchy. The upper limit of account number of child accounts is 2**31 (2'147'483'648).

    key derivation methods for stellar accounts

    Stellar Ecosystem Proposal describes implementation of deterministic key derivation for Stellar accounts based on word mnemonic of different lengths. redshift library uses 24 (or 12) word mnemonics.


    API Reference

    experimenting in browser

    RunKit with @stellar-fox/redshift

    experimenting locally

    $ git clone
    Cloning into 'redshift'...
    $ cd redshift/library/
    $ npm i
    $ npm start
    Compiling for 'production' ...
    Hash: 949571f79bbc31ee54e1
    Version: webpack 4.28.1
    Time: 1373ms
    Built at: 2018-12-21 14:32:28
          Asset      Size  Chunks             Chunk Names
    redshift.js  13.5 KiB       0  [emitted]  redshift
    Entrypoint redshift = redshift.js
    [0] external "@xcmats/js-toolbox" 42 bytes {0} [built]
    [1] external "bip39" 42 bytes {0} [built]
    [3] external "@babel/runtime/helpers/typeof" 42 bytes {0} [built]
    [4] ./package.json 3.73 KiB {0} [built]
    [5] external "stellar-sdk" 42 bytes {0} [built]
    [6] ./src/index.js 4.11 KiB {0} [built]
        + 1 hidden module


    { ENTROPY: { HIGH: 256, MEDIUM: 128 },
       { CN: 'chinese_simplified',
         CT: 'chinese_traditional',
         EN: 'english',
         FR: 'french',
         IT: 'italian',
         JP: 'japanese',
         KR: 'korean',
         SP: 'spanish' },
      genMnemonic: [Function: genMnemonic],
      validateMnemonic: [Function: validateMnemonic],
      genKeypair: [Function: genKeypair],
      newAddress: [Function: newAddress],
      restoreAddress: [Function: restoreAddress],
      words: [Function words],
      mnemonicToSeedHex: [Function: mnemonicToSeedHex],
      version: [Getter] }


    • Randomly generate mnemonic of a high entropy using english words.

      redshift.genMnemonic().split(' ')
      [ 'eye',
      'initial' ]
    • Randomly generate mnemonic of a medium entropy in italian.

      redshift.genMnemonic(redshift.LANGUAGE.IT, redshift.ENTROPY.MEDIUM)
      'desumere sogno cuculo stirpe sepolto salmone elfico giocare ...'
    • Generate hex seed from a given mnemonic.

      mnemonic = redshift.genMnemonic()
      'hold awful slender tide arrange window burden erase bamboo ...'
      seed = redshift.mnemonicToSeedHex(mnemonic)
    • Generate hex seed from a given mnemonic and a secret passphrase.

      mnemonic = redshift.genMnemonic()
      'ride throw body pet abstract gossip few online acoustic ...'
      seed = redshift.mnemonicToSeedHex(mnemonic, 'my secret phrase')
    • Generate stellar keypair object from a given seed.

      kp = redshift.genKeypair(seed)
      Keypair {
      type: 'ed25519',
      _secretSeed: <Buffer ... >,
      _secretKey: <Buffer ... >,
      _publicKey: <Buffer ... > }
      kp.canSign  kp.publicKey     kp.rawPublicKey   kp.rawSecretKey
      kp.secret   kp.sign          kp.signDecorated  kp.signatureHint
      kp.verify   kp.xdrAccountId  kp.xdrPublicKey
    • Generate stellar keypair object from a given seed and an account number.

      kp = redshift.genKeypair(seed, 27)
    • Generate object with a new mnemonic of high entropy, resulting seed and stellar keypair. Optionally, passphrase and account number can be passed as an arguments.

      redshift.newAddress('strawberryFieldsF0R3V3R', 27)
      { mnemonic: 'spell crawl shiver swallow ecology mercy ...',
        passphrase: 'strawberryFieldsF0R3V3R',
        account: 27,
        seed: 'd3dbb69cf5a538ef8594fafd3...70a10a806b9a44be5157917',
         Keypair {
           type: 'ed25519',
           _secretSeed: <Buffer ... >,
           _publicKey: <Buffer ... > } }
    • Restore address from a given mnemonic, passphrase and an account number.

          'innocent yellow push captain end focus solution ...',
      { mnemonic: 'innocent yellow push captain end focus ...',
        passphrase: 's3cRET',
        account: 3,
        seed: 'ac16748b113fb3ca85fb5cac...5290d80bec70cd4fda0878',
         Keypair {
           type: 'ed25519',
           _secretSeed: <Buffer ... >,
           _secretKey: <Buffer ... >,
           _publicKey: <Buffer ... > } }


    Tested with SEP-0005 Vectors 3 and 4 (source)

    $ npm run test:full
      Test Vector 3 (SEP-0005)
        Test Vector 3 Mnemonic Validation
          ✓ should be valid
        BIP39 Seed
          ✓ should return: 937ae91...f567866
        Public Key (m/44'/148'/0')
          ✓ should return: GC3MM...BTPJQ (58ms)
        Public Key (m/44'/148'/1')
          ✓ should return: GB3MT...YYISO
        Public Key (m/44'/148'/2')
          ✓ should return: GDYF7...DGAKU
          ✓ should return: SBSHU...2ZEO2
        Secret Key (m/44'/148'/7')
          ✓ should return: SC2QO...YWC6E
        Secret Key (m/44'/148'/8')
          ✓ should return: SCGMC...MAQST
        Secret Key (m/44'/148'/9')
          ✓ should return: SCPA5...C37GF
      Test Vector 4 (SEP-0005)
        Test Vector 4 Mnemonic Validation
          ✓ should be valid
        BIP39 Seed
          ✓ should return: d425d39...742a489
        Public Key (m/44'/148'/0')
          ✓ should return: GDAHP...B63EQ
        Public Key (m/44'/148'/1')
          ✓ should return: GDY47...4OJOC
        Secret Key (m/44'/148'/9')
          ✓ should return: SDXDY...UXNOS
      44 passing (516ms)




    redshift is released under the Apache License, Version 2.0. See the LICENSE for more details.


    npm i @stellar-fox/redshift

    DownloadsWeekly Downloads






    Unpacked Size

    1.54 MB

    Total Files


    Last publish


    • syntaxval
    • xcmats