Privora uses Program Derived Addresses (PDAs) to control who can request MPC decryption of encrypted values. This page explains the authorization system.
Standard authorization for a user to decrypt a specific encrypted value:
Copy
use privora_sdk_program::auth::pda::DecryptionAuth;// Find the PDA for a user to decrypt some datalet (pda, bump) = DecryptionAuth::find_pda(&data_hash, &user_pubkey);
Authorization based on order matching (for orderbook-style applications):
Copy
use privora_sdk_program::auth::pda::MatchAuth;// Authorize user for matched order datalet (pda, bump) = MatchAuth::find_pda( buy_order_id, sell_order_id, "price", // field being authorized &user_pubkey,);
PDA where decrypted results are stored after MPC decryption:
Copy
use privora_sdk_program::auth::pda::DecryptedResult;// Find where decrypted result will be storedlet (result_pda, bump) = DecryptedResult::find_pda(&data_hash, &user_pubkey);
// When storing encrypted balancelet balance_ref = encrypted_balance.store()?;// Authorize owner to decrypt their own balancecreate_decryption_auth( &balance_ref.hash(), &owner_pubkey,)?;
// Only authorize if trade executedif trade_executed { // Authorize buyer to see fill price create_decryption_auth( &fill_price_ref.hash(), &buyer_pubkey, )?; // Authorize seller to see fill price create_decryption_auth( &fill_price_ref.hash(), &seller_pubkey, )?;}
// Verify user should be authorizedif order.owner != user_pubkey { return Err(ProgramError::InvalidArgument);}create_decryption_auth(&order.price_ref.hash(), &user_pubkey)?;