2

I was curious if it is possible to access/retrieve the private key of a program (or an account owned by the program) from within an Solana or Anchor program itself?

1 Answer 1

4

No, private key information is never sent to the chain. Users sign transactions using their private key to create a digital signature (aka the "transaction signature"). This signature allows programs to authenticate users without needing to access their private key. As soon as you share your private key with anyone, it is compromised.

3
  • Okay, thanks! Just to clarify - I am asking about the private key of the program or an account owned by the program. Not a user pk. I assume the answer will be the same?
    – Nelis.sol
    Jan 5, 2023 at 16:56
  • 2
    Programs don't have private keys. A user who deploys a program (via a transaction) is given authority to upgrade the program, but upgrades are done through just another transaction that the user must sign. Program-owned accounts are known as PDAs and have no associated private key. Jan 5, 2023 at 19:28
  • Consider the consequences if this were somehow possible. If you could derive or lookup a program's "private key", anyone else could as well and no program on Solana would be secure. Jan 5, 2023 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.