Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

derivation path issue #42

Open
oxijoined opened this issue Sep 12, 2024 · 0 comments
Open

derivation path issue #42

oxijoined opened this issue Sep 12, 2024 · 0 comments

Comments

@oxijoined
Copy link

oxijoined commented Sep 12, 2024

How can I use this library to create an identity with derivation path m/44'/223'/0'/0/0 like in BitfinityWallet?

I should get oap7l-lib6g-7bly6-ksdy3-kv45y-tld53-tbvfg-en7y3-rtzab-4qzlb-sqe, not rsqft-yxgsv-3mlzx-xbhsd-jkqnq-oyl3i-bmo67-g2whv-u6jxy-2vgo3-aae
package main

import (
	"fmt"
	"log"

	"github.com/aviate-labs/agent-go/identity"
	"github.com/aviate-labs/secp256k1"
	"github.com/tyler-smith/go-bip39"
)

func main() {
	seedPhrase := "final advice catch admit matter garage lottery hotel roof frown object able cart draw illegal" // test seed

	// Generate seed from seed phrase
	seed, err := bip39.NewSeedWithErrorChecking(seedPhrase, "")
	if err != nil {
		log.Fatalf("Error generating seed: %v", err)
	}

	// Generate secp256k1 private key from seed
	secp256k1PrivateKey, _ := secp256k1.PrivKeyFromBytes(secp256k1.S256(), seed[:32])

	// Create secp256k1 identity
	secp256k1Identity, err := identity.NewSecp256k1Identity(secp256k1PrivateKey)
	if err != nil {
		log.Fatalf("Error creating Secp256k1 identity: %v", err)
	}

	// Get principal for Secp256k1
	secp256k1Principal := secp256k1Identity.Sender()

	// Output Secp256k1 principal
	fmt.Println("Secp256k1 Principal:", secp256k1Principal) // Must be oap7l-lib6g-7bly6-ksdy3-kv45y-tld53-tbvfg-en7y3-rtzab-4qzlb-sqe, not rsqft-yxgsv-3mlzx-xbhsd-jkqnq-oyl3i-bmo67-g2whv-u6jxy-2vgo3-aae

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant