2

Is it possible to have multiple valid PDAs (off the curve) using the same seeds? since bump can be from 0 to 255.


find_program_address

This function will do its very best to find an address off the curve. It will take the seeds you give it and also concatenate a nonce (the bump) to it, and the bytestring "ProgramDerivedAddress", counting down from 255 to 0 (ref)

it's also seen here

pub fn find_program_address(seeds: &[&[u8]],program_id: &Pubkey) -> Option<(Pubkey, u8)> {
    let mut bump_seed = [std::u8::MAX];
    for _ in 0..std::u8::MAX {
        ..
        ..
        bump_seed[0] -= 1;
    }
    None
}

find_program_address will stop when it finds a valid PDA and will return both the address and the bump. if I skip the first valid PDA. is it possible to find another one that's also valid (different bump)?

If yes then would it cause a security hazard if you use the second bump for a PDA in a program?

1 Answer 1

2

"if I skip the first valid PDA. is it possible to find another one that's also valid"

Yes, there are multiple PDAs to be found, in fact up to 255. However, all programs should verify the PDA provided is using the canonical PDA, as in the first valid PDA decrementing the bump_seed starting from std::u8::MAX.

With anchor it is as simple as using the bump constraint.

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.