Function noah_api::anon_creds::ac_commit

source ·
pub fn ac_commit<R: CryptoRng + RngCore>(
    prng: &mut R,
    user_sk: &ACUserSecretKey,
    credential: &Credential,
    msg: &[u8]
) -> Result<CommOutput<<BLSPairingEngine as Pairing>::G1, <BLSPairingEngine as Pairing>::G2, <BLSPairingEngine as Pairing>::ScalarField>>
Expand description

Compute a commitment to a credential signature with a binding message, returning the opening key.

Example

use rand_core::SeedableRng;
use rand_chacha::ChaChaRng;
use noah_api::anon_creds::{ac_keygen_issuer, ac_keygen_user, ac_sign, ac_commit, Credential};
use noah_algebra::bls12_381::BLSScalar;
use noah_algebra::traits::Scalar;
let mut prng = ChaChaRng::from_seed([0u8;32]);
let num_attrs = 2;
let (issuer_sk, issuer_pk) = ac_keygen_issuer::<ChaChaRng>(&mut prng, num_attrs);
let (user_sk, user_pk) = ac_keygen_user::<ChaChaRng>(&mut prng, &issuer_pk);
let attr1 = 10;
let attr2 = 20;
let attributes = vec![attr1, attr2];
let signature = ac_sign::<ChaChaRng>(&mut prng, &issuer_sk, &user_pk, attributes.as_slice()).unwrap();
let credential = Credential {
  sig:signature,
  attrs:attributes,
  ipk:issuer_pk
};
let (_,_,_) = ac_commit::<ChaChaRng>(&mut prng, &user_sk, &credential, b"some addr").unwrap();
Run