Skip to content

MnemonicToByteArray() does not return original byte array passed to NewMnemonic() #3

@dncohen

Description

@dncohen

I'm probably missing something fundamental... I expected address.NewMnemonic() and address.MnemonicToByteArray() to be the inverse of one another.

seed, err := address.GenerateSeed(address.RecommendedSeedLen)
mnemonic, err := address.NewMnemonic(seed)
sanity, err := address.MnemonicToByteArray(mnemonic)
if !bytes.Equal(seed, sanity) {
  log.Panic("Seed sanity check failed.")
}

In the above code, sanity has more bytes than seed. I suspect this has to do with checksum added in NewMnemonic(), but I'm not certain.

I'm wondering how can I get back the bytes that I originally passed into NewMnemonic() ?

Thanks for any help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions