use crate::VerificationStatus;
use solana_program::pubkey::Pubkey;
use solana_program::sysvar::clock::Clock;
pub type MrEnclave = [u8; 32];
#[repr(C)]
#[derive(Debug, Copy, Clone, bytemuck::Zeroable, bytemuck::Pod)]
pub struct Quote {
pub enclave_signer: Pubkey,
pub mr_enclave: [u8; 32],
pub verification_status: u8,
padding1: [u8; 7],
pub verification_timestamp: i64,
pub valid_until: i64,
pub quote_registry: [u8; 32],
pub registry_key: [u8; 64],
pub secp256k1_signer: [u8; 64],
pub last_ed25519_signer: Pubkey,
pub last_secp256k1_signer: [u8; 64],
pub last_rotate_slot: u64,
pub guardian_approvers: [Pubkey; 64],
pub guardian_approvers_len: u8,
padding2: [u8; 7],
pub _ebuf: [u8; 1024],
}
impl Default for Quote {
fn default() -> Self {
unsafe { std::mem::zeroed() }
}
}
impl Quote {
pub fn is_verified(&self, clock: &Clock) -> bool {
match self.verification_status.into() {
VerificationStatus::VerificationOverride => true,
VerificationStatus::VerificationSuccess => self.valid_until > clock.unix_timestamp,
_ => false,
}
}
}