fix: bn clipping in create_program_address (#11951)

This commit is contained in:
Jack May
2020-08-31 15:02:21 -07:00
committed by GitHub
parent ae0fd3043a
commit d167feda98
2 changed files with 20 additions and 1 deletions

View File

@ -105,7 +105,7 @@ export class PublicKey {
Buffer.from('ProgramDerivedAddress'),
]);
let hash = await sha256(new Uint8Array(buffer));
let publicKeyBytes = new BN(hash, 16).toArray();
let publicKeyBytes = new BN(hash, 16).toArray(null, 32);
if (is_on_curve(publicKeyBytes)) {
throw new Error(`Invalid seeds, address must fall off the curve`);
}