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
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.
-
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? Commented Jan 5, 2023 at 16:56
-
2Programs 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. Commented 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. Commented Jan 5, 2023 at 19:34