Going through the anchor-docs provided by the official Anchor github I've learned a fair bit about how PDAs work and manipulating them. Though I get a sneaking feeling like its extremely insecure and prone to exploits galore.
const [userStatsPDA, _] = await PublicKey.findProgramAddress(
[
anchor.utils.bytes.utf8.encode('user-stats'),
provider.wallet.publicKey.toBuffer(),
],
program.programId
)
This line in particular "anchor.utils.bytes.utf8.encode('user-stats')" worries me in the fact its ran client side.
I'm running with Anchor 0.25.0, how secure is this client-side generation and is there a way to do it entirely contract side?
I want to pass as little data as possible from the client into the contract and especially not generate anything client side.