openmls 0.8.1

A Rust implementation of the Messaging Layer Security (MLS) protocol, as defined in RFC 9420.
use openmls_traits::{crypto::OpenMlsCrypto, types::Ciphersuite};

use crate::{
    binary_tree::array_representation::TreeSize,
    ciphersuite::Secret,
    schedule::{
        pprf::{Pprf, PprfError, Prefix16},
        ApplicationExportSecret,
    },
};

pub(crate) type ApplicationExportTree = Pprf<Prefix16>;

/// Error constructing component secret from the exporter tree
/// See [`PprfError`] for more details.
pub type ApplicationExportTreeError = PprfError;

impl ApplicationExportTree {
    pub(crate) fn new(application_exporter: ApplicationExportSecret) -> Self {
        let size = TreeSize::from_leaf_count(u16::MAX as u32);
        Pprf::new_with_size(application_exporter.secret, size)
    }

    pub(crate) fn safe_export_secret(
        &mut self,
        crypto: &impl OpenMlsCrypto,
        ciphersuite: Ciphersuite,
        component_id: u16,
    ) -> Result<Secret, ApplicationExportTreeError> {
        self.evaluate(crypto, ciphersuite, &component_id)
    }
}