pub(crate) fn refresh_private_tree(
        &mut self,
        credential_bundle: &CredentialBundle,
        group_context: &[u8],
        new_leaves_indexes: HashSet<&LeafIndex>,
        backend: &impl OpenMlsCryptoProvider,
    ) -> Result<(UpdatePath, KeyPackageBundle), TreeError> {
        // Generate new keypair
        let own_index = self.own_node_index();
        let own_key_package = self.own_key_package();

        // Replace the init key in the current KeyPackage
        let key_package_bundle_unsigned =
            KeyPackageBundlePayload::from_rekeyed_key_package(own_key_package, backend);
        // FIXME: #419 THIS IS UNNECESSARY
        let key_package_bundle = key_package_bundle_unsigned.sign(backend, credential_bundle)?;

        // Replace the private tree with a new one based on the new key package
        // bundle and store the key package in the own node.
        // XXX: #419 this step of setting the key package must go away.
        self.nodes[own_index] = Node::new_leaf(Some(key_package_bundle.key_package().clone()));
        let path_nodes = self
            .replace_private_tree_path_(
                backend,
                key_package_bundle.leaf_secret(),
                group_context,
                Some(new_leaves_indexes), /* with update path */
            )
            .ok_or(TreeError::InvalidTree)?;

        // Compute the parent hash extension and update the KeyPackage and sign it
        let parent_hash = self.set_parent_hashes(backend, own_index);
        let mut key_package_bundle_unsigned = key_package_bundle.unsigned();
        key_package_bundle_unsigned.update_parent_hash(&parent_hash);
        let key_package_bundle = key_package_bundle_unsigned.sign(backend, credential_bundle)?;

        // Use new key package
        let mut path = UpdatePath::new(key_package_bundle.key_package().clone(), path_nodes);

        // Store it in the UpdatePath and the tree
        path.leaf_key_package = key_package_bundle.key_package().clone();
        self.set_key_package(key_package_bundle.key_package());

        Ok((path, key_package_bundle))
    }
/// Update the private tree.
///
/// Returns the update path and an updated key package bundle.
Update the private tree.
Returns the update path and an updated key package bundle.
Update the private tree . Returns the update path and an updated key package bundle .
pub(crate) fn refresh_private_tree(
        &mut self,
        credential_bundle: &CredentialBundle,
        group_context: &[u8],
        new_leaves_indexes: HashSet<&LeafIndex>,
        backend: &impl OpenMlsCryptoProvider,
    ) -> Result<(UpdatePath, KeyPackageBundle), TreeError> {
        // Generate new keypair
        let own_index = self.own_node_index();
        let own_key_package = self.own_key_package();
        // Replace the init key in the current KeyPackage
        let key_package_bundle_unsigned =
            KeyPackageBundlePayload::from_rekeyed_key_package(own_key_package, backend);
        // FIXME: #419 THIS IS UNNECESSARY
        let key_package_bundle = key_package_bundle_unsigned.sign(backend, credential_bundle)?;
        // Replace the private tree with a new one based on the new key package
        // bundle and store the key package in the own node.
        // XXX: #419 this step of setting the key package must go away.
        self.nodes[own_index] = Node::new_leaf(Some(key_package_bundle.key_package().clone()));
        let path_nodes = self
            .replace_private_tree_path_(
                backend,
                key_package_bundle.leaf_secret(),
                group_context,
                Some(new_leaves_indexes), /* with update path */
            )
            .ok_or(TreeError::InvalidTree)?;
        // Compute the parent hash extension and update the KeyPackage and sign it
        let parent_hash = self.set_parent_hashes(backend, own_index);
        let mut key_package_bundle_unsigned = key_package_bundle.unsigned();
        key_package_bundle_unsigned.update_parent_hash(&parent_hash);
        let key_package_bundle = key_package_bundle_unsigned.sign(backend, credential_bundle)?;
        // Use new key package
        let mut path = UpdatePath::new(key_package_bundle.key_package().clone(), path_nodes);
        // Store it in the UpdatePath and the tree
        path.leaf_key_package = key_package_bundle.key_package().clone();
        self.set_key_package(key_package_bundle.key_package());
        Ok((path, key_package_bundle))
    }
pub ( crate ) fn refresh_private_tree ( & mut self , credential_bundle : & CredentialBundle , group_context : & [ u8 ] , new_leaves_indexes : HashSet < & LeafIndex > , backend : & impl OpenMlsCryptoProvider , ) -> Result < ( UpdatePath , KeyPackageBundle ) , TreeError > { // Generate new keypair let own_index = self . own_node_index ( ) ; let own_key_package = self . own_key_package ( ) ; // Replace the init key in the current KeyPackage let key_package_bundle_unsigned = KeyPackageBundlePayload :: from_rekeyed_key_package ( own_key_package , backend ) ; // FIXME: #419 THIS IS UNNECESSARY let key_package_bundle = key_package_bundle_unsigned . sign ( backend , credential_bundle ) ? ; // Replace the private tree with a new one based on the new key package // bundle and store the key package in the own node. // XXX: #419 this step of setting the key package must go away. self . nodes [ own_index ] = Node :: new_leaf ( Some ( key_package_bundle . key_package ( ) . clone ( ) ) ) ; let path_nodes = self . replace_private_tree_path_ ( backend , key_package_bundle . leaf_secret ( ) , group_context , Some ( new_leaves_indexes ) , /* with update path */ ) . ok_or ( TreeError :: InvalidTree ) ? ; // Compute the parent hash extension and update the KeyPackage and sign it let parent_hash = self . set_parent_hashes ( backend , own_index ) ; let mut key_package_bundle_unsigned = key_package_bundle . unsigned ( ) ; key_package_bundle_unsigned . update_parent_hash ( & parent_hash ) ; let key_package_bundle = key_package_bundle_unsigned . sign ( backend , credential_bundle ) ? ; // Use new key package let mut path = UpdatePath :: new ( key_package_bundle . key_package ( ) . clone ( ) , path_nodes ) ; // Store it in the UpdatePath and the tree path . leaf_key_package = key_package_bundle . key_package ( ) . clone ( ) ; self . set_key_package ( key_package_bundle . key_package ( ) ) ; Ok ( ( path , key_package_bundle ) ) }
Update the private tree.
Update the private tree .
&mut self
credential_bundle
&CredentialBundle
group_context
&[u8]
new_leaves_indexes
HashSet<&LeafIndex>
backend
&impl OpenMlsCryptoProvider
&mut self
credential_bundle
&CredentialBundle
group_context
&[u8]
new_leaves_indexes
HashSet<&LeafIndex>
backend
&impl OpenMlsCryptoProvider