pub fn prepare_blind_sign(
    params: &Parameters,
    pub_key: &elgamal::PublicKey,
    private_attributes: &[Attribute],
    public_attributes: &[Attribute],
) -> Result<BlindSignRequest> {
    if private_attributes.is_empty() {
        return Err(CoconutError::Issuance(
            "Tried to prepare blind sign request for an empty set of private attributes"
                .to_string(),
        ));
    }

    let hs = params.gen_hs();
    if private_attributes.len() + public_attributes.len() > hs.len() {
        return Err(CoconutError::IssuanceMaxAttributes {
            max: hs.len(),
            requested: private_attributes.len() + public_attributes.len(),
        });
    }

    // prepare commitment
    // Produces h0 ^ m0 * h1^m1 * .... * hn^mn
    let attr_cm = private_attributes
        .iter()
        .chain(public_attributes.iter())
        .zip(hs)
        .map(|(&m, h)| h * m)
        .sum::<G1Projective>();
    let blinder = params.random_scalar();
    // g1^r * h0 ^ m0 * h1^m1 * .... * hn^mn
    let commitment = params.gen1() * blinder + attr_cm;

    // build ElGamal encryption
    let commitment_hash = hash_g1(commitment.to_bytes());
    let (attributes_ciphertexts, ephemeral_keys): (Vec<_>, Vec<_>) = private_attributes
        .iter()
        .map(|m| pub_key.encrypt(params, &commitment_hash, m))
        .unzip();

    let pi_s = ProofCmCs::construct(
        params,
        pub_key,
        &ephemeral_keys,
        &commitment,
        &blinder,
        private_attributes,
        public_attributes,
    );

    Ok(BlindSignRequest {
        commitment,
        attributes_ciphertexts,
        pi_s,
    })
}
/// Builds cryptographic material required for blind sign.
Builds cryptographic material required for blind sign.
Builds cryptographic material required for blind sign .
pub fn prepare_blind_sign(
    params: &Parameters,
    pub_key: &elgamal::PublicKey,
    private_attributes: &[Attribute],
    public_attributes: &[Attribute],
) -> Result<BlindSignRequest> {
    if private_attributes.is_empty() {
        return Err(CoconutError::Issuance(
            "Tried to prepare blind sign request for an empty set of private attributes"
                .to_string(),
        ));
    }
    let hs = params.gen_hs();
    if private_attributes.len() + public_attributes.len() > hs.len() {
        return Err(CoconutError::IssuanceMaxAttributes {
            max: hs.len(),
            requested: private_attributes.len() + public_attributes.len(),
        });
    }
    // prepare commitment
    // Produces h0 ^ m0 * h1^m1 * .... * hn^mn
    let attr_cm = private_attributes
        .iter()
        .chain(public_attributes.iter())
        .zip(hs)
        .map(|(&m, h)| h * m)
        .sum::<G1Projective>();
    let blinder = params.random_scalar();
    // g1^r * h0 ^ m0 * h1^m1 * .... * hn^mn
    let commitment = params.gen1() * blinder + attr_cm;
    // build ElGamal encryption
    let commitment_hash = hash_g1(commitment.to_bytes());
    let (attributes_ciphertexts, ephemeral_keys): (Vec<_>, Vec<_>) = private_attributes
        .iter()
        .map(|m| pub_key.encrypt(params, &commitment_hash, m))
        .unzip();
    let pi_s = ProofCmCs::construct(
        params,
        pub_key,
        &ephemeral_keys,
        &commitment,
        &blinder,
        private_attributes,
        public_attributes,
    );
    Ok(BlindSignRequest {
        commitment,
        attributes_ciphertexts,
        pi_s,
    })
}
pub fn prepare_blind_sign ( params : & Parameters , pub_key : & elgamal :: PublicKey , private_attributes : & [ Attribute ] , public_attributes : & [ Attribute ] , ) -> Result < BlindSignRequest > { if private_attributes . is_empty ( ) { return Err ( CoconutError :: Issuance ( " " . to_string ( ) , ) ) ; } let hs = params . gen_hs ( ) ; if private_attributes . len ( ) + public_attributes . len ( ) > hs . len ( ) { return Err ( CoconutError :: IssuanceMaxAttributes { max : hs . len ( ) , requested : private_attributes . len ( ) + public_attributes . len ( ) , } ) ; } // prepare commitment // Produces h0 ^ m0 * h1^m1 * .... * hn^mn let attr_cm = private_attributes . iter ( ) . chain ( public_attributes . iter ( ) ) . zip ( hs ) . map ( | ( & m , h ) | h * m ) . sum :: < G1Projective > ( ) ; let blinder = params . random_scalar ( ) ; // g1^r * h0 ^ m0 * h1^m1 * .... * hn^mn let commitment = params . gen1 ( ) * blinder + attr_cm ; // build ElGamal encryption let commitment_hash = hash_g1 ( commitment . to_bytes ( ) ) ; let ( attributes_ciphertexts , ephemeral_keys ) : ( Vec < _ > , Vec < _ > ) = private_attributes . iter ( ) . map ( | m | pub_key . encrypt ( params , & commitment_hash , m ) ) . unzip ( ) ; let pi_s = ProofCmCs :: construct ( params , pub_key , & ephemeral_keys , & commitment , & blinder , private_attributes , public_attributes , ) ; Ok ( BlindSignRequest { commitment , attributes_ciphertexts , pi_s , } ) }
Builds cryptographic material required for blind sign.
Builds cryptographic material required for blind sign .
params
&Parameters
pub_key
&elgamal::PublicKey
private_attributes
&[Attribute]
public_attributes
&[Attribute]