pub extern "C" fn atms_aggregate_sigs(
    msg_ptr: *const c_char,
    sigs_ptr: *const SignaturePtr,
    pks_ptr: *const PublicKeyPtr,
    reg_ptr: RegistrationPtr,
    nr_signatures: usize,
    aggr_sig: *mut AggregateSigPtr,
) -> i64 {
    unsafe {
        if let (Some(ref_msg), Some(ref_sigs), Some(ref_pks), Some(ref_reg), Some(ref_aggr_sig)) = (
            msg_ptr.as_ref(),
            sigs_ptr.as_ref(),
            pks_ptr.as_ref(),
            reg_ptr.as_ref(),
            aggr_sig.as_mut(),
        ) {
            let msg = CStr::from_ptr(ref_msg);
            let mut sigs = Vec::with_capacity(nr_signatures);

            for (p, k) in slice::from_raw_parts(ref_sigs, nr_signatures)
                .iter()
                .zip(slice::from_raw_parts(ref_pks, nr_signatures).iter())
            {
                let indices = ref_reg.get_index(&**k);
                for index in indices {
                    sigs.push((index, **p));
                }
            }

            match AggregateSig::new(ref_reg, &sigs, msg.to_bytes()) {
                Ok(sig) => *ref_aggr_sig = Box::into_raw(Box::new(sig)),
                Err(AtmsError::NonRegisteredParticipant) => return -1,
                Err(AtmsError::InvalidSignature) => return -2,
                Err(AtmsError::UnexpectedBlstTypes) => return -3,
                Err(AtmsError::SerializationError) => return -4,
                Err(_) => unreachable!("No other erros should happen when aggregating signatures."),
            }

            return 0;
        }
        NULLPOINTERERR
    }
}
/// Aggregate a list of signatures.
/// The signature aggregation can be performed by any third party. Given `nr_signatures` pairs of
/// signatures, `sigs`,  with their corresponding public key `pks`
/// the aggregator produces the aggregate signature. It begins by checking all signatures
/// are valid, and which public keys
/// are missing from the tuple of submitted signatures. It computes the proof
/// of set membership within the set of eligible signers for the missing signers. Then it proceeds
/// with the computation of the aggregate signature (addition of all submitted signatures). Returns:
/// * 0 if all signatures are valid
/// * -1 if one of the signatures is invalid
/// * -2 if one of the submitted signatures comes from a non-registered participant
Aggregate a list of signatures.
The signature aggregation can be performed by any third party.
Aggregate a list of signatures . The signature aggregation can be performed by any third party .
pub extern "C" fn atms_aggregate_sigs(
    msg_ptr: *const c_char,
    sigs_ptr: *const SignaturePtr,
    pks_ptr: *const PublicKeyPtr,
    reg_ptr: RegistrationPtr,
    nr_signatures: usize,
    aggr_sig: *mut AggregateSigPtr,
) -> i64 {
    unsafe {
        if let (Some(ref_msg), Some(ref_sigs), Some(ref_pks), Some(ref_reg), Some(ref_aggr_sig)) = (
            msg_ptr.as_ref(),
            sigs_ptr.as_ref(),
            pks_ptr.as_ref(),
            reg_ptr.as_ref(),
            aggr_sig.as_mut(),
        ) {
            let msg = CStr::from_ptr(ref_msg);
            let mut sigs = Vec::with_capacity(nr_signatures);
            for (p, k) in slice::from_raw_parts(ref_sigs, nr_signatures)
                .iter()
                .zip(slice::from_raw_parts(ref_pks, nr_signatures).iter())
            {
                let indices = ref_reg.get_index(&**k);
                for index in indices {
                    sigs.push((index, **p));
                }
            }
            match AggregateSig::new(ref_reg, &sigs, msg.to_bytes()) {
                Ok(sig) => *ref_aggr_sig = Box::into_raw(Box::new(sig)),
                Err(AtmsError::NonRegisteredParticipant) => return -1,
                Err(AtmsError::InvalidSignature) => return -2,
                Err(AtmsError::UnexpectedBlstTypes) => return -3,
                Err(AtmsError::SerializationError) => return -4,
                Err(_) => unreachable!("No other erros should happen when aggregating signatures."),
            }
            return 0;
        }
        NULLPOINTERERR
    }
}
pub extern " " fn atms_aggregate_sigs ( msg_ptr : * const c_char , sigs_ptr : * const SignaturePtr , pks_ptr : * const PublicKeyPtr , reg_ptr : RegistrationPtr , nr_signatures : usize , aggr_sig : * mut AggregateSigPtr , ) -> i64 { unsafe { if let ( Some ( ref_msg ) , Some ( ref_sigs ) , Some ( ref_pks ) , Some ( ref_reg ) , Some ( ref_aggr_sig ) ) = ( msg_ptr . as_ref ( ) , sigs_ptr . as_ref ( ) , pks_ptr . as_ref ( ) , reg_ptr . as_ref ( ) , aggr_sig . as_mut ( ) , ) { let msg = CStr :: from_ptr ( ref_msg ) ; let mut sigs = Vec :: with_capacity ( nr_signatures ) ; for ( p , k ) in slice :: from_raw_parts ( ref_sigs , nr_signatures ) . iter ( ) . zip ( slice :: from_raw_parts ( ref_pks , nr_signatures ) . iter ( ) ) { let indices = ref_reg . get_index ( & * * k ) ; for index in indices { sigs . push ( ( index , * * p ) ) ; } } match AggregateSig :: new ( ref_reg , & sigs , msg . to_bytes ( ) ) { Ok ( sig ) => * ref_aggr_sig = Box :: into_raw ( Box :: new ( sig ) ) , Err ( AtmsError :: NonRegisteredParticipant ) => return - 1 , Err ( AtmsError :: InvalidSignature ) => return - 2 , Err ( AtmsError :: UnexpectedBlstTypes ) => return - 3 , Err ( AtmsError :: SerializationError ) => return - 4 , Err ( _ ) => unreachable ! ( " " ) , } return 0 ; } NULLPOINTERERR } }
Aggregate a list of signatures.
Aggregate a list of signatures .
msg_ptr
*const c_char
sigs_ptr
*const SignaturePtr
pks_ptr
*const PublicKeyPtr
reg_ptr
RegistrationPtr
nr_signatures
usize
aggr_sig
*mut AggregateSigPtr