1

Generating a vanity address with a custom suffix is easy (from a custom made script) but is it possible to use the generated keypair with the Ledger Nano S?

If so, how?

5

Generating a vanity address is trial and error process. You generate key pairs until you find a public key with a prefix you want.

You can apply the same method here. For example, in Go use derivation package and generate random mnemonic seeds as long as the primary account (m/44'/148'/0') has a public key with the searched prefix:

package main

import (
  "fmt"
  "strings"

  "github.com/bartekn/go-bip39"
  "github.com/stellar/go/exp/crypto/derivation"
  "github.com/stellar/go/keypair"
)

const EntropySize = 256
const Prefix = "GABC"

func main() {
  for {
    entropy, err := bip39.NewEntropy(EntropySize)
    if err != nil {
      panic(err)
    }

    mnemonic, err := bip39.NewMnemonic(entropy)
    if err != nil {
      panic(err)
    }

    seed, err := bip39.NewSeedWithErrorChecking(mnemonic, "")
    if err != nil {
      panic(err)
    }

    key, err := derivation.DeriveForPath(derivation.StellarPrimaryAccountPath, seed)
    if err != nil {
      panic(err)
    }

    kp, err := keypair.FromRawSeed(key.RawSeed())
    if err != nil {
      panic(err)
    }

    if strings.HasPrefix(kp.Address(), Prefix) {
      fmt.Println(mnemonic)
      fmt.Println(kp.Address())
      fmt.Println(kp.Seed())
      break
    }
  }
}

While it's technically possible, I strongly discourage you to do it. Generating cryptographic keys outside Ledger device can be less secure.


EDIT I realized that you asked about suffix, not prefix. To achieve this we need a small modification to the script:

  • Change Prefix const to Suffix
  • Change strings.HasPrefix(kp.Address(), Prefix) to strings.HasSuffix(kp.Address(), Suffix)
  • This does not reply to my question. I asked if it was possible to use the generated seed on a hardware wallet such as the Ledger Nano S. – Anthony Jan 27 '18 at 18:16
  • It does answer your question. You can import the mnemonic seed found by a script above into Ledger (using recovery feature). – Bartek Nowotarski Jan 27 '18 at 20:08
  • I see, but if I already have the address. What are the steps to add it into the device? – Anthony Jan 27 '18 at 20:09
  • You can't add vanity address to previously generated master keys on the Ledger. The only way is to generate a new keys (ex. using the script above) and use Ledger recovery function to import new keys. – Bartek Nowotarski Jan 29 '18 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.