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

Method init

kvac/src/bbs_sharp/proof.rs:137–190  ·  view source on GitHub ↗

Pass the appropriate type in `hw_sig_type` which corresponds to the signature type generated by user's secure hardware If `verifier_pub_key` is provided, then create a designated verifier proof which only the verifier can verify

(
        rng: &mut R,
        mac: &MAC<G>,
        params: &MACParams<G>,
        messages_and_blindings: MBI,
        user_public_key: &UserPublicKey<G>,
        hw_sig_type: HardwareSignatureType,

Source from the content-addressed store, hash-verified

135 /// Pass the appropriate type in `hw_sig_type` which corresponds to the signature type generated by user's secure hardware
136 /// If `verifier_pub_key` is provided, then create a designated verifier proof which only the verifier can verify
137 pub fn init<'a, MBI, R: RngCore>(
138 rng: &mut R,
139 mac: &MAC<G>,
140 params: &MACParams<G>,
141 messages_and_blindings: MBI,
142 user_public_key: &UserPublicKey<G>,
143 hw_sig_type: HardwareSignatureType,
144 verifier_pub_key: Option<&G>,
145 ) -> Result<Self, KVACError>
146 where
147 MBI: IntoIterator<Item = MessageOrBlinding<'a, G::ScalarField>>,
148 {
149 let (messages, indexed_blindings) =
150 match split_messages_and_blindings(rng, messages_and_blindings, params) {
151 Ok(t) => t,
152 Err(l) => {
153 return Err(KVACError::MessageCountIncompatibleWithMACParams(
154 l,
155 params.supported_message_count(),
156 ))
157 }
158 };
159
160 let r1 = G::ScalarField::rand(rng);
161 let mut r2 = G::ScalarField::rand(rng);
162 while r2.is_zero() {
163 r2 = G::ScalarField::rand(rng);
164 }
165 let r3 = r2.inverse().unwrap();
166
167 let A_hat = mac.A * (r1 * r2);
168 // B = (e+x) * A = g_0 + user_pk + \sum(g_vec_i*m_i) for all i in I
169 let B = params.b(messages.iter().enumerate(), &user_public_key)?;
170 let D = B * r2;
171
172 let minus_e = -mac.e;
173 let B_bar = D * r1 + A_hat * minus_e;
174 Self::_init(
175 rng,
176 A_hat.into(),
177 B_bar.into(),
178 D.into(),
179 r1,
180 r3,
181 minus_e,
182 messages,
183 indexed_blindings,
184 params,
185 user_public_key,
186 hw_sig_type,
187 None,
188 verifier_pub_key,
189 )
190 }
191
192 /// Initialize the protocol using token received in HOL mode.
193 /// Pass the appropriate type in `hw_sig_type` which corresponds to the signature type generated by user's secure hardware

Callers

nothing calls this directly

Calls 6

randFunction · 0.85
is_zeroMethod · 0.80
bMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected