0

Take test seed here: https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md

seed: "e0eec84fe165cd427cb7bc9b6cfdef0555aa1cb6f9043ff1fe986c3c8ddd22e3"

correct result: m/44'/148'/0' GDRXE2BQUC3AZNPVFSCEZ76NJ3WWL25FYFK6RGZGIEKWE4SOOHSUJUJ6 SBGWSG6BTNCKCOB3DIFBGCVMUPQFYPA2G4O34RMTB343OYPXU5DJDVMN

How to properly turn seed into a correct result (keypair)? Trying:

import (
    "github.com/stellar/go/keypair"
)
var seeds [32]byte
copy(seeds[:], []byte("e0eec84fe165cd427cb7bc9b6cfdef0555aa1cb6f9043ff1fe986c3c8ddd22e3"))
pair, err := keypair.FromRawSeed(seeds)
xlmAddr := pair.Address()
xlmPK := pair.Seed()
fmt.Println(xlmAddr)
fmt.Println(xlmPK)

Result is different...

0

Perhaps someone will need it,

https://github.com/stellar/go/issues/3478

I tried to change it to this:

xlmSeed, _ := hex.DecodeString("e0eec84fe165cd427cb7bc9b6cfdef0555aa1cb6f9043ff1fe986c3c8ddd22e3")
xlmKey, err := xlmDrv.DeriveForPath(xlmDrv.StellarPrimaryAccountPath, xlmSeed)
pair, err := keypair.FromRawSeed(xlmKey.RawSeed())
fmt.Println(pair.Seed())
fmt.Println(pair.Address())
Still the wrong result.

But it turned out to be wrong...

overcat(Jun Luo) answered in my question:

You should use BIP39 Seed in SEP-05, not m/44'/148' key. If you want to reproduce test 1 in SEP-10, please use the following code.

package main

import (
    "encoding/hex"
    "fmt"
    "github.com/stellar/go/exp/crypto/derivation"
    "github.com/stellar/go/keypair"
)

func main() {
    // I ignored all errors.
    bip39Seed, _ := hex.DecodeString("e4a5a632e70943ae7f07659df1332160937fad82587216a4c64315a0fb39497ee4a01f76ddab4cba68147977f3a147b6ad584c41808e8238a07f6cc4b582f186")
    for i := 0; i < 10; i++ {
        path := fmt.Sprintf(derivation.StellarAccountPathFormat, i)
        key, _ := derivation.DeriveForPath(path, bip39Seed)
        keyPair, _ := keypair.FromRawSeed(key.RawSeed())
        fmt.Printf("%s %s %s\n", path, keyPair.Address(), keyPair.Seed())
    }
}

Actually m/44'/148' key is the intermediate value generated during the calculation, if you are interested in it, add a breakpoint here and explore k.Key.

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.