2

If an account is not generated via PDA and is instead created as a new keypair, how should this new keypair be treated? Is it important to custody this somewhere secure?

https://github.com/coral-xyz/anchor/blob/fa1249836e2b8a73d3cb9fb525634e789290f251/tests/zero-copy/tests/zero-copy.js#L14

As an example, an anchor example here generates foo by:

const foo = anchor.web3.Keypair.generate();

foo then is used to sign and create a new account creation instruction for the zero copy program.

To make the questions concrete:

  1. Does foo have any importance after the account has been generated?
  2. What happens if foo is compromised (i.e. key pair is shared)? Will another user with foo be able do anything malicious?
  3. Does the contract deployer knowing foo present any centralized risk in the future? If so, how does one mitigate that?

Thanks in advance!

1 Answer 1

2

In this scenario, the keypair is used to generate the Account and the Owner of the Account Is the custom executing program. Hence If the Keypair is compromised, a malicious actor is unable to do anything because the corresponding Account generated from the keypair Is owned by the custom executing program rather than the System Program.

However, If the custom executing program closes the Account generated from the Keypair, then the Account is then owned by the System Program, and a malicious actor can then use the Account as a normal address. A general rule of thumb when this approach Is preferred over using a normal PDA and making the custom program the owner of the Account Is when you want to store data above 10KB(max size of PDA) on the Account and data below 10MB(max size of Accounts on solana)

0

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.