Add warning to program derived address docs (#25412)

This commit is contained in:
Jack May 2022-05-20 10:19:41 -07:00 committed by GitHub
parent 9ef0acdf5d
commit 397a14b127
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -236,6 +236,16 @@ pub fn find_program_address(
}
```
**Warning**: Because of the way the seeds are hashed there is a potential for
program address collisions for the same program id. The seeds are hashed
sequentially which means that seeds {"abcdef"}, {"abc", "def"}, and {"ab",
"cd", "ef"} will all result in the same program address given the same program
id. Since the chance of collision is local to a given program id, the developer
of that program must take care to choose seeds that do not collide with each
other. For seed schemes that are susceptible to this type of hash collision, a
common remedy is to insert separators between seeds, e.g. transforming {"abc",
"def"} into {"abc", "-", "def"}.
### Using program addresses
Clients can use the `create_program_address` function to generate a destination