MCPcopy Create free account
hub / github.com/Lightprotocol/light-protocol-v1 / check_tx_integrity_hash

Function check_tx_integrity_hash

program/src/instructions.rs:171–204  ·  view source on GitHub ↗
(
    recipient: Vec<u8>,
    ext_amount: Vec<u8>,
    relayer: Vec<u8>,
    fee: Vec<u8>,
    tx_integrity_hash: Vec<u8>,
    merkle_tree_index: u8,
    encrypted_utxos: Vec<u8>,
    merkle_tree_pda_

Source from the content-addressed store, hash-verified

169}
170
171pub fn check_tx_integrity_hash(
172 recipient: Vec<u8>,
173 ext_amount: Vec<u8>,
174 relayer: Vec<u8>,
175 fee: Vec<u8>,
176 tx_integrity_hash: Vec<u8>,
177 merkle_tree_index: u8,
178 encrypted_utxos: Vec<u8>,
179 merkle_tree_pda_pubkey: Vec<u8>,
180) -> Result<(), ProgramError> {
181 let input = [
182 recipient,
183 ext_amount,
184 relayer,
185 fee,
186 merkle_tree_pda_pubkey,
187 vec![merkle_tree_index],
188 encrypted_utxos,
189 ]
190 .concat();
191 // msg!("integrity_hash inputs: {:?}", input);
192 let hash = solana_program::keccak::hash(&input[..]).try_to_vec()?;
193 msg!("hash computed {:?}", hash);
194
195 if Fq::from_be_bytes_mod_order(&hash[..]) != Fq::from_le_bytes_mod_order(&tx_integrity_hash) {
196 msg!(
197 "tx_integrity_hash verification failed.{:?} != {:?}",
198 &hash[..],
199 &tx_integrity_hash
200 );
201 return Err(ProgramError::InvalidInstructionData);
202 }
203 Ok(())
204}
205
206pub fn check_and_insert_nullifier<'a, 'b>(
207 program_id: &Pubkey,

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected