Skip to content

Commit cafb024

Browse files
authored
added check for bump seeds to ensure they are canonical (#13)
1 parent 1dbf9b7 commit cafb024

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

program/src/instruction/init_timelock.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,25 @@ pub fn process_init_timelock(accounts: &[AccountInfo<'_>], data: &[u8]) -> Progr
5757
let owner = virtual_account_owner_info.key.clone();
5858
let nonce = vm.get_current_poh();
5959

60-
let timelock_address = pdas::create_virtual_timelock_address(
60+
let (timelock_address, timelock_bump) = pdas::find_virtual_timelock_address(
6161
&vm.get_mint(),
6262
&vm.get_authority(),
6363
&owner,
6464
vm.get_lock_duration(),
65-
args.virtual_timelock_bump,
6665
);
6766

68-
let unlock_address = pdas::create_unlock_address(
67+
if args.virtual_timelock_bump != timelock_bump {
68+
return Err(ProgramError::InvalidArgument);
69+
}
70+
71+
let (unlock_address, unlock_bump) = pdas::find_unlock_address(
6972
&owner,
7073
&timelock_address,
71-
vm_info.key,
72-
args.unlock_pda_bump);
74+
vm_info.key);
75+
76+
if args.unlock_pda_bump != unlock_bump {
77+
return Err(ProgramError::InvalidArgument);
78+
}
7379

7480
// We could technically require the user to provide the withdraw_bump,
7581
// however, that would make using this instruction more cumbersome since the

0 commit comments

Comments
 (0)