MCPcopy Create free account
hub / github.com/docknetwork/crypto / new

Method new

kvac/src/bbs_sharp/mac.rs:54–81  ·  view source on GitHub ↗
(
        rng: &mut R,
        messages: &[G::ScalarField],
        user_public_key: &UserPublicKey<G>,
        signer_secret_key: &SecretKey<G::ScalarField>,
        params: impl AsRef<MACParams<G>>,

Source from the content-addressed store, hash-verified

52
53impl<G: AffineRepr> MAC<G> {
54 pub fn new<R: RngCore>(
55 rng: &mut R,
56 messages: &[G::ScalarField],
57 user_public_key: &UserPublicKey<G>,
58 signer_secret_key: &SecretKey<G::ScalarField>,
59 params: impl AsRef<MACParams<G>>,
60 ) -> Result<Self, KVACError> {
61 if messages.is_empty() {
62 return Err(KVACError::NoMessageGiven);
63 }
64 let params = params.as_ref();
65 expect_equality!(
66 messages.len(),
67 params.supported_message_count(),
68 KVACError::MessageCountIncompatibleWithMACParams
69 );
70 let mut e = G::ScalarField::rand(rng);
71 while (e + signer_secret_key.0).is_zero() {
72 e = G::ScalarField::rand(rng)
73 }
74 // 1/(e+x)
75 let e_plus_x_inv = (e + signer_secret_key.0).inverse().unwrap();
76 let A = params.b(messages.iter().enumerate(), user_public_key)? * e_plus_x_inv;
77 Ok(Self {
78 A: A.into_affine(),
79 e,
80 })
81 }
82
83 pub fn verify(
84 &self,

Callers

nothing calls this directly

Calls 9

randFunction · 0.85
is_zeroMethod · 0.80
mapMethod · 0.80
is_emptyMethod · 0.45
as_refMethod · 0.45
bMethod · 0.45
iterMethod · 0.45
gen_proofMethod · 0.45

Tested by

no test coverage detected