pub fn new(keys_pop: &[PublicKeyPoP]) -> Result<Self, AtmsError> {
        let mut checked_keys: Vec<PublicKey> = Vec::with_capacity(keys_pop.len());

        for key_pop in keys_pop {
            checked_keys.push(key_pop.verify()?);
        }

        let aggregate_key = checked_keys.iter().sum();

        // This ensures the order is the same for permutations of the input keys
        checked_keys.sort();

        let mut tree_vec = Vec::with_capacity(keys_pop.len());
        let mut leaf_map = HashMap::new();
        // todo: compress or serialize
        for (index, &key) in checked_keys.iter().enumerate() {
            if leaf_map.insert(index, key).is_some() {
                return Err(AtmsError::RegisterExistingKey(key));
            }
            tree_vec.push(key.0.compress().to_vec());
        }

        Ok(Registration {
            aggregate_key,
            tree: MerkleTree::create(&tree_vec),
            leaf_map,
        })
    }
/// Aggregate a set of keys, and commit to them in a canonical order. The canonical order
/// is defined as the ordering of the byte representation of the compressed public keys. In
/// practice, this ordering can be any deterministic function as long as the aggregator and
/// the verifier use the same.
///
/// Provided with a vector of keys with their proof of possession, `PublicKeyPoP`, the registration
/// proceeds by checking all proofs of possession. Then, it aggregates all public key by adding
/// them. Similarly, it commits to them by first ordering them, and then committing them in a
/// Merkle Tree. Finally, it computes a hash map, by creating the relation of the relative
/// position of each key in the committed vector. Registration guarantees that there are no
/// repeated keys.
///
/// # Error
/// The function returns `AtmsError::InvalidPoP` if one of the proofs of possession is invalid,
/// and `AtmsError::RegisterExistingKey` if the input tuple contains a repeated key.
Aggregate a set of keys, and commit to them in a canonical order. The canonical order
is defined as the ordering of the byte representation of the compressed public keys. In
practice, this ordering can be any deterministic function as long as the aggregator and
the verifier use the same.

Provided with a vector of keys with their proof of possession, `PublicKeyPoP`, the registration
proceeds by checking all proofs of possession. Then, it aggregates all public key by adding
them. Similarly, it commits to them by first ordering them, and then committing them in a
Merkle Tree. Finally, it computes a hash map, by creating the relation of the relative
position of each key in the committed vector. Registration guarantees that there are no
repeated keys.
Aggregate a set of keys and commit to them in a canonical order . The canonical order is defined as the ordering of the byte representation of the compressed public keys . In practice this ordering can be any deterministic function as long as the aggregator and the verifier use the same . Provided with a vector of keys with their proof of possession ` PublicKeyPoP ` the registration proceeds by checking all proofs of possession . Then it aggregates all public key by adding them . Similarly it commits to them by first ordering them and then committing them in a Merkle Tree . Finally it computes a hash map by creating the relation of the relative position of each key in the committed vector . Registration guarantees that there are no repeated keys .
pub fn new(keys_pop: &[PublicKeyPoP]) -> Result<Self, AtmsError> {
        let mut checked_keys: Vec<PublicKey> = Vec::with_capacity(keys_pop.len());
        for key_pop in keys_pop {
            checked_keys.push(key_pop.verify()?);
        }
        let aggregate_key = checked_keys.iter().sum();
        // This ensures the order is the same for permutations of the input keys
        checked_keys.sort();
        let mut tree_vec = Vec::with_capacity(keys_pop.len());
        let mut leaf_map = HashMap::new();
        // todo: compress or serialize
        for (index, &key) in checked_keys.iter().enumerate() {
            if leaf_map.insert(index, key).is_some() {
                return Err(AtmsError::RegisterExistingKey(key));
            }
            tree_vec.push(key.0.compress().to_vec());
        }
        Ok(Registration {
            aggregate_key,
            tree: MerkleTree::create(&tree_vec),
            leaf_map,
        })
    }
pub fn new ( keys_pop : & [ PublicKeyPoP ] ) -> Result < Self , AtmsError > { let mut checked_keys : Vec < PublicKey > = Vec :: with_capacity ( keys_pop . len ( ) ) ; for key_pop in keys_pop { checked_keys . push ( key_pop . verify ( ) ? ) ; } let aggregate_key = checked_keys . iter ( ) . sum ( ) ; // This ensures the order is the same for permutations of the input keys checked_keys . sort ( ) ; let mut tree_vec = Vec :: with_capacity ( keys_pop . len ( ) ) ; let mut leaf_map = HashMap :: new ( ) ; // todo: compress or serialize for ( index , & key ) in checked_keys . iter ( ) . enumerate ( ) { if leaf_map . insert ( index , key ) . is_some ( ) { return Err ( AtmsError :: RegisterExistingKey ( key ) ) ; } tree_vec . push ( key . 0 . compress ( ) . to_vec ( ) ) ; } Ok ( Registration { aggregate_key , tree : MerkleTree :: create ( & tree_vec ) , leaf_map , } ) }
Aggregate a set of keys, and commit to them in a canonical order.
Aggregate a set of keys and commit to them in a canonical order .
keys_pop
&[PublicKeyPoP]
error
The function returns `AtmsError::InvalidPoP` if one of the proofs of possession is invalid,
and `AtmsError::RegisterExistingKey` if the input tuple contains a repeated key.
The function returns ` AtmsError :: InvalidPoP ` if one of the proofs of possession is invalid and ` AtmsError :: RegisterExistingKey ` if the input tuple contains a repeated key .