Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastinas committed Dec 7, 2024
1 parent 49a7a35 commit 5b8f402
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 29 deletions.
30 changes: 9 additions & 21 deletions src/atact.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::cmp::max;

use ark_ff::{Field, UniformRand, Zero};
use ark_serialize::CanonicalSerialize;
use rayon::iter::{IntoParallelIterator, ParallelIterator};
Expand Down Expand Up @@ -47,30 +49,16 @@ pub fn setup(

let sk = SecretKey::new();
let pk = sk.to_public_key();
let scalars: Vec<_> = (1..=max(n, t) as u64).map(Scalar::from).collect();

let pp = PublicParameters {
pk,
n,
t,
tprime,
lagrange_n: Lagrange::new(
(1..=n as u64)
.map(Scalar::from)
.collect::<Vec<_>>()
.as_ref(),
),
lagrange_t: Lagrange::new(
(1..=t as u64)
.map(Scalar::from)
.collect::<Vec<_>>()
.as_ref(),
),
lagrange_tprime: Lagrange::new(
(1..=tprime as u64)
.map(Scalar::from)
.collect::<Vec<_>>()
.as_ref(),
),
lagrange_n: Lagrange::new(&scalars[..n]),
lagrange_t: Lagrange::new(&scalars[..t]),
lagrange_tprime: Lagrange::new(&scalars[..tprime]),
tsw_pp: tsw::PublicParameters::new(l + 1),
};

Expand All @@ -96,7 +84,7 @@ pub fn register(a: &Scalar, _pp: &PublicParameters) -> Result<(StRG, Commitment)
Ok((
StRG {
a: *a,
r: *opening.as_ref(),
r: opening.r,
},
cm,
))
Expand Down Expand Up @@ -129,7 +117,7 @@ pub fn token_request(
let ak = Scalar::rand(&mut rng);
let (cm_k, o_k) = Commitment::commit(&ak);
coms.push(cm_k);
rks.push(&pp.pk * *o_k.as_ref());
rks.push(&pp.pk * o_k.r);
}

// Step 9
Expand Down Expand Up @@ -180,7 +168,7 @@ pub fn token_request(
strg: strg.clone(),
r_ks: rks,
bold_k,
bold_rk: *bold_cm_opening.as_ref(),
bold_rk: bold_cm_opening.r,
},
))
}
Expand Down
6 changes: 0 additions & 6 deletions src/pedersen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ pub struct Opening {
pub(crate) r: Scalar,
}

impl AsRef<Scalar> for Opening {
fn as_ref(&self) -> &Scalar {
&self.r
}
}

pub struct Proof {
t: G1G2,
s_1: Scalar,
Expand Down
4 changes: 2 additions & 2 deletions src/s3id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pub fn microcred(
.verify_pedersen_commitment(&cm_i, idx + 1, &sigma_i, &pp.atact_pp.tsw_pp)
.is_ok());
// 10.i
Ok(&sigma_i + &(&pp.atact_pp.pk * -*op_i.as_ref()))
Ok(&sigma_i + &(&pp.atact_pp.pk * -op_i.r))
})
.collect::<Result<Vec<_>, _>>()
}
Expand Down Expand Up @@ -238,7 +238,7 @@ pub fn appcred(
) -> Result<(Credential, Proof), S3IDError> {
let mut rng = thread_rng();

let q: Vec<_> = attribute_subset
let q = attribute_subset
.iter()
.map(|attribute| {
attributes
Expand Down

0 comments on commit 5b8f402

Please sign in to comment.