Skip to content

Commit

Permalink
Fixed allowance of illegal inputs in tests (hacspec#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
lassebramer authored Jun 26, 2023
1 parent a403012 commit 3efdf5e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 43 deletions.
13 changes: 10 additions & 3 deletions halo2/src/halo2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ fn inner_product(u: Polyx, v: Polyx) -> FpVesta {
/// * `a` - sequence of scalars (LHS)
/// * `g` - sequence of group (curve) elements (RHS)
fn msm(a: Polyx, g: Seq<G1_pallas>) -> G1_pallas {
let mut res: G1_pallas = g1mul_pallas(a[usize::zero()], g[usize::zero()]);
for i in 1..a.len() {
// initial value is zero
let mut res: G1_pallas = (FpPallas::ZERO(), FpPallas::ZERO(), true);
for i in 0..a.len() {
res = g1add_pallas(res, g1mul_pallas(a[i], g[i]));
}

Expand Down Expand Up @@ -1239,8 +1240,10 @@ fn test_step_5_6_7_8() {

// STEP 6
let H_s = step_6(h_s.clone(), &(G.clone(), W), h_blindings.clone());

// STEP 7
let H_prime = step_7(H_s, x, n);

// STEP 8
let (h_prime, h_prime_blinding) = step_8(h_s, x, n, h_blindings.clone());

Expand Down Expand Up @@ -5364,7 +5367,7 @@ pub fn check_not_zero_polyx(p: Polyx) -> bool {
///
/// * `p` - the polynomial
pub fn trim_polyx(p: Polyx) -> Polyx {
let mut last_val_idx = 0;
let mut last_val_idx = 1;
for i in 0..p.len() {
if p[i] != FpVesta::ZERO() {
last_val_idx = i + 1;
Expand Down Expand Up @@ -5562,6 +5565,10 @@ impl Arbitrary for PolyxContainer {
let new_val: FpVesta = FpVesta::from_literal(u128::arbitrary(g));
v.push(new_val);
}
if size == 0 {
v.push(FpVesta::ZERO())
}

PolyxContainer(Seq::<FpVesta>::from_vec(v))
}
}
Expand Down
67 changes: 27 additions & 40 deletions katex-header.html
Original file line number Diff line number Diff line change
@@ -1,43 +1,30 @@
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
integrity="sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx"
crossorigin="anonymous"
></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"
integrity="sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe"
crossorigin="anonymous"
></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe" crossorigin="anonymous"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
renderMathInElement(document.body, {
delimiters: [
{ left: "$$", right: "$$", display: true },
{ left: "\\(", right: "\\)", display: false },
{ left: "$", right: "$", display: false },
{ left: "\\[", right: "\\]", display: true },
],
macros: {
"\\prover": "\\mathcal{P}",
"\\verifier": "\\mathcal{V}",
"\\relation": "\\mathcal{R}",
"\\zero": "\\mathcal{O}",
"\\field": "\\mathbb{F}",
"\\group": "\\mathbb{G}",
"\\halo": "\\mathbf{Halo}",
"\\setup": "\\textrm{Setup}",
"\\pp": "\\textrm{pp}",
"\\innerprod": "\\langle #1,#2 \\rangle",
"\\sec": "\\lambda",
"\\lo": "_\{lo\}",
"\\hi": "_\{hi\}",
},
document.addEventListener("DOMContentLoaded", function() {
renderMathInElement(document.body, {
delimiters: [
{left: "$$", right: "$$", display: true},
{left: "\\(", right: "\\)", display: false},
{left: "$", right: "$", display: false},
{left: "\\[", right: "\\]", display: true}
],
macros: {
"\\prover": "\\mathcal{P}",
"\\verifier": "\\mathcal{V}",
"\\relation": "\\mathcal{R}",
"\\zero": "\\mathcal{O}",
"\\field": "\\mathbb{F}",
"\\group": "\\mathbb{G}",
"\\halo": "\\mathbf{Halo}",
"\\setup": "\\textrm{Setup}",
"\\pp": "\\textrm{pp}",
"\\innerprod": "\\langle #1,#2 \\rangle",
"\\sec": "\\lambda",
"\\lo": "_\{lo\}",
"\\hi": "_\{hi\}",
}
});
});
});
</script>

0 comments on commit 3efdf5e

Please sign in to comment.