Skip to content

Commit

Permalink
Clean up types full_knowledge_proof
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanorendorff committed Aug 4, 2023
1 parent c66469e commit c8c466f
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions logproof/src/linear_relation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1600,35 +1600,34 @@ mod test {

// Convert all components into their polynomial representations in the
// fields we use in this package.
let m: DensePolynomial<Fp<MontBackend<F, N>, N>> = DensePolynomial {
let m = DensePolynomial {
coeffs: strip_trailing_value(
(0..plaintext.len())
.map(|i| Fp::<MontBackend<F, N>, N>::from(plaintext.get_coefficient(i)))
.map(|i| Fp::from(plaintext.get_coefficient(i)))
.collect::<Vec<Fp<MontBackend<F, N>, N>>>(),
Fp::<MontBackend<F, N>, N>::zero(),
Fp::zero(),
),
};

let u: DensePolynomial<Fp<MontBackend<F, N>, N>> =
convert_to_polynomial(u.clone()).pop().unwrap();
let u = convert_to_polynomial(u.clone()).pop().unwrap();

let mut es = convert_to_polynomial(e);
let e_1 = es.remove(0);
let e_2 = es.remove(0);

let mut cs: Vec<DensePolynomial<Fp<MontBackend<F, N>, N>>> =
let mut cs =
convert_to_polynomial(PolynomialArray::new_from_ciphertext(&ctx, &ciphertext).unwrap());
let c_0 = cs.remove(0);
let c_1 = cs.remove(0);

let mut pk: Vec<DensePolynomial<Fp<MontBackend<F, N>, N>>> =
let mut pk =
convert_to_polynomial(PolynomialArray::new_from_public_key(&ctx, &public_key).unwrap());
let p_0 = pk.remove(0);
let p_1 = pk.remove(0);

let r: DensePolynomial<Fp<MontBackend<F, N>, N>> = DensePolynomial {
let r = DensePolynomial {
coeffs: (0..round.len())
.map(|i| Fp::<MontBackend<F, N>, N>::from(round.get_coefficient(i)))
.map(|i| Fp::from(round.get_coefficient(i)))
.collect::<Vec<Fp<MontBackend<F, N>, N>>>(),
};

Expand All @@ -1637,7 +1636,7 @@ mod test {
let modulus_bigint_lowered = BigInt::<N>(modulus_bigint.0[0..N].try_into().unwrap());
let plain_modulus_bigint = BigInt::<N>::from(plain_modulus.value());
let delta_dc = div_rem_bigint(modulus_bigint_lowered, plain_modulus_bigint).0;
let delta_dc = Fp::<MontBackend<F, N>, N>::from(delta_dc);
let delta_dc = Fp::from(delta_dc);

let delta = DensePolynomial {
coeffs: vec![delta_dc],
Expand All @@ -1647,7 +1646,7 @@ mod test {
let one = make_poly(&[1]);
let zero = make_poly(&[]);

let a: Matrix<DensePolynomial<Fp<MontBackend<F, N>, N>>> = MatrixPoly::from([
let a = MatrixPoly::from([
[
delta.clone(),
one.clone(),
Expand All @@ -1664,7 +1663,7 @@ mod test {
],
]);

let s: Matrix<DensePolynomial<Fp<MontBackend<F, N>, N>>> = MatrixPoly::from([
let s = MatrixPoly::from([
[m.clone()],
[r.clone()],
[u.clone()],
Expand All @@ -1676,7 +1675,7 @@ mod test {
let mut divisor_coefficients = vec![0; (degree + 1) as usize];
divisor_coefficients[0] = 1;
divisor_coefficients[degree as usize] = 1;
let divisor: DensePolynomial<Fp<MontBackend<F, N>, N>> = make_poly(&divisor_coefficients);
let divisor = make_poly(&divisor_coefficients);

// We do this without the polynomial division and then perform that at
// the end.
Expand Down

0 comments on commit c8c466f

Please sign in to comment.