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

non-standard seed not support #274

Open
aitimate opened this issue Nov 8, 2024 · 1 comment
Open

non-standard seed not support #274

aitimate opened this issue Nov 8, 2024 · 1 comment

Comments

@aitimate
Copy link

aitimate commented Nov 8, 2024

I used an Ethereum mnemonic for import and wallet generation, but I received an 'invalid seed' error. I reviewed the code and the official implementation, and I understand why this error occurs. However, when I try directly importing the same mnemonic into MyTonWallet and Tonkeeper, I don’t get any error. This has made me reconsider the issue: how should we correctly use mnemonics from other networks on the TON network? Below are my attempts, which were unsuccessful:

func TestAddress(t *testing.T) {
	words := strings.Split(seeds[0].Mnemonic, " ")
	mac := hmac.New(sha512.New, []byte(strings.Join(words, " ")))
	//mac.Write([]byte(""))
	hash := mac.Sum(nil)
	k := pbkdf2.Key(hash, []byte("TON default seed"), 100000, 32, sha512.New)
	{
		hd, err := wallet.FromPrivateKey(nil, ed25519.NewKeyFromSeed(k), wallet.ConfigV5R1Final{
			NetworkGlobalID: wallet.MainnetGlobalID,
		})
		panicIf.Err(err)
		log.Println(hd.WalletAddress())
	}
	{
		hd, err := wallet.FromPrivateKey(nil, ed25519.NewKeyFromSeed(k), wallet.V4R2)
		panicIf.Err(err)
		log.Println(hd.WalletAddress())
	}
	{
		hd, err := wallet.FromPrivateKey(nil, ed25519.NewKeyFromSeed(k), wallet.V3R2)
		panicIf.Err(err)
		log.Println(hd.WalletAddress())
	}
	{
		hd, err := wallet.FromPrivateKey(nil, ed25519.NewKeyFromSeed(k), wallet.V3R1)
		panicIf.Err(err)
		log.Println(hd.WalletAddress())
	}
	{
		hd, err := wallet.FromPrivateKey(nil, ed25519.NewKeyFromSeed(k), wallet.V3)
		panicIf.Err(err)
		log.Println(hd.WalletAddress())
	}
}

ps: Strictly speaking, it wasn’t exactly a failure, but rather that the result I generated didn’t match the wallet’s output. I tried many other approaches, but none of them produced a matching result.

@aitimate
Copy link
Author

aitimate commented Nov 11, 2024

solution: #275

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