plonkup/proof_system/widget/logic/
verifierkey.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4//
5// Copyright (c) DUSK NETWORK. All rights reserved.
6
7use crate::commitment_scheme::Commitment;
8
9#[derive(Debug, PartialEq, Eq, Copy, Clone)]
10pub(crate) struct VerifierKey {
11    pub(crate) q_c: Commitment,
12    pub(crate) q_logic: Commitment,
13}
14
15#[cfg(feature = "alloc")]
16mod alloc {
17    use super::*;
18    use crate::proof_system::linearization_poly::ProofEvaluations;
19    use crate::proof_system::widget::logic::proverkey::{delta, delta_xor_and};
20    #[rustfmt::skip]
21    use ::alloc::vec::Vec;
22    use dusk_bls12_381::{BlsScalar, G1Affine};
23
24    impl VerifierKey {
25        pub(crate) fn compute_linearization_commitment(
26            &self,
27            logic_separation_challenge: &BlsScalar,
28            scalars: &mut Vec<BlsScalar>,
29            points: &mut Vec<G1Affine>,
30            evaluations: &ProofEvaluations,
31        ) {
32            let four = BlsScalar::from(4);
33
34            let kappa = logic_separation_challenge.square();
35            let kappa_sq = kappa.square();
36            let kappa_cu = kappa_sq * kappa;
37            let kappa_qu = kappa_cu * kappa;
38
39            let a = evaluations.a_next_eval - four * evaluations.a_eval;
40            let c_0 = delta(a);
41
42            let b = evaluations.b_next_eval - four * evaluations.b_eval;
43            let c_1 = delta(b) * kappa;
44
45            let d = evaluations.d_next_eval - four * evaluations.d_eval;
46            let c_2 = delta(d) * kappa_sq;
47
48            let w = evaluations.c_eval;
49            let c_3 = (w - a * b) * kappa_cu;
50
51            let c_4 =
52                delta_xor_and(&a, &b, &w, &d, &evaluations.q_c_eval) * kappa_qu;
53            scalars.push(
54                (c_0 + c_1 + c_2 + c_3 + c_4) * logic_separation_challenge,
55            );
56            points.push(self.q_logic.0);
57        }
58    }
59}