Skip to content

Aptos Go-SDK #605

Discussion options

You must be logged in to vote

[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 to CryptoMaterial 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:

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 Ed25519P…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gregnazario
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants