Aptos Go-SDK #605
-
Discord user IDNo response Describe your question in detail.Hey there all!!! I have generated an account using aptos-labs/go-lang sdk as such I want to ask how to get access of the Private Key for this generated Account. What error, if any, are you getting?No response What have you tried or looked at? Or how can we reproduce the error?No response Which operating system are you using?Linux (Ubuntu, Fedora, Windows WSL, etc.) Which SDK or tool are you using? (if any)N/A Describe your environment or tooling in detailNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
[Go] Recovering Ed25519PrivateKey from Ed25519AccountIt's a bit hard due to the levels of abstraction, but because you know the signer is a There are types of accounts, that may not have As CryptoMaterial: package main
import (
"github.com/aptos-labs/aptos-go-sdk"
"github.com/aptos-labs/aptos-go-sdk/crypto"
)
func main() {
acc1, _ := aptos.NewEd25519Account()
key := acc1.Signer.(crypto.CryptoMaterial)
println(key.ToHex())
} As Ed25519PrivateKey: package main
import (
"github.com/aptos-labs/aptos-go-sdk"
"github.com/aptos-labs/aptos-go-sdk/crypto"
)
func main() {
acc1, _ := aptos.NewEd25519Account()
key := acc1.Signer.(*crypto.Ed25519PrivateKey)
println(key.ToHex())
} |
Beta Was this translation helpful? Give feedback.
[Go] Recovering Ed25519PrivateKey from Ed25519Account
It's a bit hard due to the levels of abstraction, but because you know the signer is a
Ed25519PrivateKey
you can cast it for now. Or even cast toCryptoMaterial
which is supported also on most Signer.There are types of accounts, that may not have
CryptoMaterial
applied, e.g. when Keyless is supported here, it would not be able to print the private key (because there isn't one)As CryptoMaterial:
As Ed25519P…