Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@ jobs:
- uses: actions/checkout@v4
- name: machete
uses: bnjbvr/cargo-machete@main

typos:
name: Spell check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/typos@v1.44.0
15 changes: 15 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[default.extend-words]
# Groth16 is a zero-knowledge proof system (not "Growth")
groth = "groth"
Groth = "Groth"
GROTH = "GROTH"

[files]
extend-exclude = [
# Notebook outputs contain escaped terminal codes that trigger false positives
"playground/sage/*.ipynb",
# Base64-encoded mock keys contain random substrings
"playground/passport-input-gen/src/mock_keys.rs",
# Typst labels (e.g. <thm-hm>) are not typos
"playground/sage/*.typst",
]
8 changes: 4 additions & 4 deletions noir-examples/babyjubjub/src/montgomery.nr
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ impl MontgomeryPoint {
pub fn double(self) -> MontgomeryPoint {
// Safety: cast to unconstrained field
// lambda = (3*u^2 + 2*A*u + 1) / (2*v)
let lamda = unsafe { Self::double_lambda_unconstrained(self) };
let lambda = unsafe { Self::double_lambda_unconstrained(self) };
let num = 3 * self.u * self.u + 2 * MONT_A * self.u + 1;
let den = 2 * self.v;
assert(lamda * den == num, "Montgomery double slope constraint failed");
assert(lambda * den == num, "Montgomery double slope constraint failed");

let u3 = MONT_B * lamda * lamda - MONT_A - 2 * self.u;
let v3 = lamda * (self.u - u3) - self.v;
let u3 = MONT_B * lambda * lambda - MONT_A - 2 * self.u;
let v3 = lambda * (self.u - u3) - self.v;

MontgomeryPoint { u: u3, v: v3 }
}
Expand Down
2 changes: 1 addition & 1 deletion ntt/src/ntt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl NTTEngine {
}
}

// Returns the maximum order that it supports without extention
// Returns the maximum order that it supports without extension
fn order(&self) -> Pow2<usize> {
Pow2(self.0.len() * 2)
}
Expand Down
2 changes: 1 addition & 1 deletion playground/cm31_ntt/src/ntt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ pub fn gen_precomp_full(n: usize, w: CF, block: usize) -> Result<Vec<CF>> {
/// case which accepts an input size of NTT_BLOCK_SIZE_FOR_CACHE, and memory
/// allocation via Vecs for the higher levels. This is done to maximise cache
/// use and minimise memory allocations. This function expects a reference to a
/// zero buffer as the scratch parameter, of size NTT_BLOCK_SIZE_FOR_CACH, of
/// zero buffer as the scratch parameter, of size NTT_BLOCK_SIZE_FOR_CACHE, of
/// size NTT_BLOCK_SIZE_FOR_CACHE. The precomp_small and precomp_full parameters
/// are precomputed twiddles for the base NTT and the higher layers,
/// respectively. They must be generated using precomputed_twiddles().
Expand Down
6 changes: 3 additions & 3 deletions playground/cm31_ntt/src/ntt_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ pub fn ntt_block_8(
wt7: CF,
) -> (CF, CF, CF, CF, CF, CF, CF, CF) {
// Refer to Yuval's Radix 8 DIT diagram.
// 1st columm of black dots: a0-a8
// 2nd columm of black dots: b0-b8
// 3nd columm of black dots: res[0]-res[8]
// 1st column of black dots: a0-a8
// 2nd column of black dots: b0-b8
// 3nd column of black dots: res[0]-res[8]

let t0 = f0;
let t1 = f1 * wt;
Expand Down
6 changes: 3 additions & 3 deletions playground/cm31_ntt/src/rm31.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl RF {
}

pub fn mul_2exp_u64(&self, exp: u64) -> Self {
// Adpated from https://github.com/Plonky3/Plonky3/blob/6049a30c3b1f5351c3eb0f7c994dc97e8f68d10d/mersenne-31/src/lib.rs#L162
// Adapted from https://github.com/Plonky3/Plonky3/blob/6049a30c3b1f5351c3eb0f7c994dc97e8f68d10d/mersenne-31/src/lib.rs#L162
let reduced = reduce(self.val);
let exp = exp % 31;
let left = (reduced << exp) & P;
Expand All @@ -102,7 +102,7 @@ impl RF {
}

pub fn div_2exp_u64(&self, exp: u64) -> Self {
// Adpated from https://github.com/Plonky3/Plonky3/blob/6049a30c3b1f5351c3eb0f7c994dc97e8f68d10d/mersenne-31/src/lib.rs#L162
// Adapted from https://github.com/Plonky3/Plonky3/blob/6049a30c3b1f5351c3eb0f7c994dc97e8f68d10d/mersenne-31/src/lib.rs#L162
let reduced = reduce(self.val);
let exp = (exp % 31) as u8;
let left = reduced >> exp;
Expand Down Expand Up @@ -383,7 +383,7 @@ mod tests {
}
}

// Print all faling test cases. This is useful for debugging. I don't use
// Print all failing test cases. This is useful for debugging. I don't use
// test_case here as I want to reuse TEST_CASES, and I ran into issues
// with test_case name clashes.
if failing_test_cases.len() > 0 {
Expand Down
22 changes: 11 additions & 11 deletions playground/sage/fri-and-friends/src/fri.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ def deep_rational_poly(eval_poly, ood_challenges):
poly_evals = [(v, eval_poly(v)) for v in ood_challenges]
numerator = PolyRing.lagrange_polynomial(poly_evals)
x = PolyRing.gen()
denomonator = prod([(x - v) for v in ood_challenges])
return (numerator, denomonator)
denominator = prod([(x - v) for v in ood_challenges])
return (numerator, denominator)

@staticmethod
def consistancy_cross_check(this_round: Self, prev_round : Self, folding_challenge, queries = 1, ood_response = None):
def consistency_cross_check(this_round: Self, prev_round : Self, folding_challenge, queries = 1, ood_response = None):
previous_round_proof = prev_round.gen_proof()
this_round_proof = this_round.gen_proof()
alphas = [prev_round.folding_root**i for i in range(prev_round.folding_factor)]
Expand Down Expand Up @@ -232,7 +232,7 @@ def verify_proximity(self, max_degree, query_count = 10):
this_fri = this_round.fri_round
fold_random = this_round.fold_randomness
deep_frac = this_round.deep_poly
is_good = FRIRound.consistancy_cross_check(this_fri,
is_good = FRIRound.consistency_cross_check(this_fri,
prev_round,
fold_random,
query_count,
Expand Down Expand Up @@ -321,14 +321,14 @@ def verify_proof(self,
# Reed Solomon evaluation domains are incompatible!
return False

rs_orignal = original.gen_proof()
rs_original = original.gen_proof()
rs_quot = quot.gen_proof()
votes = 0

for _ in range(self.query_count):
ndx = int(random()*len(rs_orignal))
ndx = int(random()*len(rs_original))
reconstructed = expected_value + (rs_quot[ndx] * (eval_points[ndx] - evaluation_point))
if reconstructed == rs_orignal[ndx]:
if reconstructed == rs_original[ndx]:
votes += 1

# Overwhelming majority might be too weak!
Expand Down Expand Up @@ -358,8 +358,8 @@ def run_test_friopp(code_dimension=2048, rate_factor=4, folding_factor=4, ood_co
folding_factor=folding_factor,
ood_count=ood_count)

assert iopp.verify_proximity(poly_degree), "FRI IOPP varification should work"
assert not iopp.verify_proximity(poly_degree // folding_factor - 1), "FRI IOPP varification should fail if the max degree is 1/folding factor away"
assert iopp.verify_proximity(poly_degree), "FRI IOPP verification should work"
assert not iopp.verify_proximity(poly_degree // folding_factor - 1), "FRI IOPP verification should fail if the max degree is 1/folding factor away"


def run_test_fri_round(code_dimension=2048, rate_factor=4, folding_factor=4, ood_count = 5):
Expand All @@ -371,7 +371,7 @@ def run_test_fri_round(code_dimension=2048, rate_factor=4, folding_factor=4, ood
folding_randomness = Fq.random_element()
ood_randomness = [Fq.random_element() for _ in range(ood_count)]
(second_oracle, ood_response) = first_oracle.fold(folding_randomness, ood_randomness)
assert FRIRound.consistancy_cross_check(second_oracle, first_oracle, folding_challenge=folding_randomness, queries=5, ood_response=ood_response)
assert FRIRound.consistency_cross_check(second_oracle, first_oracle, folding_challenge=folding_randomness, queries=5, ood_response=ood_response)

def run_test_pcs(code_dimension=2048, rate_factor=4, folding_factor=4, ood_count = 5):
ntt_omega = omega**(cofactor*2**(twodicity - log(code_dimension, 2)))
Expand All @@ -392,7 +392,7 @@ def run_test_pcs(code_dimension=2048, rate_factor=4, folding_factor=4, ood_count
"An invalid opening of evaluation point should not succeed, but it did"

assert not verifier.verify_proof(commitment, proof, evaluation_point, expected_value + 1), \
"An invalid opening of evaluation value shoud not succeed, but it did"
"An invalid opening of evaluation value should not succeed, but it did"

run_test_fri_round()
run_test_friopp()
Expand Down
12 changes: 6 additions & 6 deletions playground/sage/fri-and-friends/src/whir.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def fold_virtually(oracle_ndxes : list[int], # list of indices in proof oracle

1. First compute the fold_factor ℓ := 2^{len(fold_challenges)}
2. Compute ℓ-th roots of unity `fold_omega` from `ntt_omega`.
2. Given `ndx`, compute other indicies that are ℓ-th root
2. Given `ndx`, compute other indices that are ℓ-th root
conjugates corresponding to `ndx`.
3. Given a polynomial f(x), it can be written as
f(x) = f_0(x^ℓ) + x•f_1(x^ℓ) + ••• + x^{ℓ}•f_{ℓ-1}(x^ℓ)
Expand Down Expand Up @@ -193,12 +193,12 @@ def __init__(self,
last_whir_round: Self,
whir_round : Self,
ood_data: dict[FiniteField, FiniteField] ,
shift_qeries : list[FiniteField],
shift_queries : list[FiniteField],
):
self.last_round = last_whir_round
self.this_round = whir_round
self.ood_data = ood_data
self.shift_queries = shift_qeries
self.shift_queries = shift_queries


def __init__(self,
Expand Down Expand Up @@ -515,7 +515,7 @@ def update_weight(self,
trace : bool = True
):
ood_challenge = list(ood_query.keys())[0]
ood_reponse = ood_query[ood_challenge]
ood_response = ood_query[ood_challenge]

weight_eq_vars = self.polyvars()

Expand All @@ -525,7 +525,7 @@ def update_weight(self,
weight = weight_updt(ood_challenge)

if trace:
print(f"\n V> Weight update for OOD challenge {ood_challenge} => {ood_reponse} : {self.weight_var}*({weight})")
print(f"\n V> Weight update for OOD challenge {ood_challenge} => {ood_response} : {self.weight_var}*({weight})")

update_sum = gamma*weight

Expand All @@ -540,7 +540,7 @@ def update_weight(self,
if trace:
print(f" V> Updated new weight: {self.weight_polynomial}")

h_terms = [ood_reponse] + [r for (_,r) in shift_query]
h_terms = [ood_response] + [r for (_,r) in shift_query]
h_update = sum([ sresp * gamma**(i+1) for (i,sresp) in enumerate(h_terms)])

if trace:
Expand Down
8 changes: 4 additions & 4 deletions playground/sage/fri-and-friends/whir.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@
],
"source": [
"verifier = WhirVerifier(weight_poly, ntt_omega, pcs_evaluation_claim)\n",
"succes = verifier.validate_pcs_claim(prover)\n",
"if succes == True:\n",
"success = verifier.validate_pcs_claim(prover)\n",
"if success == True:\n",
" print(f\"PCS verification succeeded\")\n",
"else:\n",
" print(f\"PCS verification failed\")"
Expand Down Expand Up @@ -395,8 +395,8 @@
"prover = WhirRound(input_poly, weight_poly, ntt_omega, pcs_evaluation_claim)\n",
"\n",
"verifier = WhirVerifier(weight_poly, ntt_omega, pcs_evaluation_claim + 1)\n",
"succes = verifier.validate_pcs_claim(prover)\n",
"if succes == True:\n",
"success = verifier.validate_pcs_claim(prover)\n",
"if success == True:\n",
" print(f\"PCS verification succeeded\")\n",
"else:\n",
" print(f\"PCS verification failed\")"
Expand Down
2 changes: 1 addition & 1 deletion provekit/common/src/utils/sumcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub fn eval_cubic_poly(poly: [FieldElement; 4], point: FieldElement) -> FieldEle
poly[0] + point * (poly[1] + point * (poly[2] + point * poly[3]))
}

/// Given a path to JSON file with sparce matrices and a witness, calculates
/// Given a path to JSON file with sparse matrices and a witness, calculates
/// matrix-vector multiplication and returns them
#[instrument(skip_all)]
pub fn calculate_witness_bounds(
Expand Down
2 changes: 1 addition & 1 deletion provekit/r1cs-compiler/src/memory/ram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn add_ram_checking(
// required range checks later.
let mut all_mem_op_index_and_rt = vec![];

// For each of the writes in the inititialization, add a factor to the write
// For each of the writes in the initialization, add a factor to the write
// hash
block
.initial_value_witnesses
Expand Down
4 changes: 2 additions & 2 deletions recursive-verifier/app/circuit/mtUtilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func initialSumcheck(
}
combinedLinearStatementEvaluations[evaluationIndex] = sum
}
OODAnswersAndStatmentEvaluations := append(initialOODAnswers, combinedLinearStatementEvaluations...)
lastEval := utilities.DotProduct(api, initialCombinationRandomness, OODAnswersAndStatmentEvaluations)
OODAnswersAndStatementEvaluations := append(initialOODAnswers, combinedLinearStatementEvaluations...)
lastEval := utilities.DotProduct(api, initialCombinationRandomness, OODAnswersAndStatementEvaluations)

initialSumcheckFoldingRandomness, lastEval, err := runWhirSumcheckRounds(api, lastEval, arthur, whirParams.FoldingFactorArray[0], 3)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion recursive-verifier/app/circuit/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type WHIRParams struct {
FinalFoldingPowBits int
StartingDomainBackingDomainGenerator frontend.Variable
DomainSize int
CommittmentOODSamples int
CommitmentOODSamples int
FinalSumcheckRounds int
MVParamsNumberOfVariables int
BatchSize int
Expand Down
10 changes: 5 additions & 5 deletions recursive-verifier/app/circuit/whir.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewWhirParams(cfg WHIRConfig) WHIRParams {
FinalFoldingPowBits: cfg.FinalFoldingPowBits,
StartingDomainBackingDomainGenerator: *startingDomainGen,
DomainSize: domainSize,
CommittmentOODSamples: 1,
CommitmentOODSamples: 1,
FinalSumcheckRounds: finalSumcheckRounds,
MVParamsNumberOfVariables: mvParamsNumberOfVariables,
BatchSize: cfg.BatchSize,
Expand Down Expand Up @@ -598,20 +598,20 @@ func runWhir(
return
}

initialOODQueries, initialOODAnswers, tempErr := fillInOODPointsAndAnswers(whirParams.CommittmentOODSamples, arthur)
initialOODQueries, initialOODAnswers, tempErr := fillInOODPointsAndAnswers(whirParams.CommitmentOODSamples, arthur)
if tempErr != nil {
err = tempErr
return
}

initialCombinationRandomness, tempErr := GenerateCombinationRandomness(api, arthur, whirParams.CommittmentOODSamples+len(linearStatementEvaluations))
initialCombinationRandomness, tempErr := GenerateCombinationRandomness(api, arthur, whirParams.CommitmentOODSamples+len(linearStatementEvaluations))
if tempErr != nil {
err = tempErr
return
}

OODAnswersAndStatmentEvaluations := append(initialOODAnswers, linearStatementEvaluations...)
lastEval := utilities.DotProduct(api, initialCombinationRandomness, OODAnswersAndStatmentEvaluations)
OODAnswersAndStatementEvaluations := append(initialOODAnswers, linearStatementEvaluations...)
lastEval := utilities.DotProduct(api, initialCombinationRandomness, OODAnswersAndStatementEvaluations)

initialSumcheckFoldingRandomness, lastEval, tempErr := runWhirSumcheckRounds(api, lastEval, arthur, whirParams.FoldingFactorArray[0], 3)
if tempErr != nil {
Expand Down
2 changes: 1 addition & 1 deletion recursive-verifier/app/circuit/whir_utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func computeWPoly(
value = api.Add(value, api.Mul(initialData.InitialCombinationRandomness[j], utilities.EqPolyOutside(api, utilities.ExpandFromUnivariate(api, initialData.InitialOODQueries[j], numberVars), totalFoldingRandomness)))
}

// Values are directly used as all linearStatements are deffered and hints were given. Checking of hints will be done later on.
// Values are directly used as all linearStatements are deferred and hints were given. Checking of hints will be done later on.
for j, linearStatementValueAtPoint := range linearStatementValuesAtPoints {
value = api.Add(value, api.Mul(initialData.InitialCombinationRandomness[len(initialData.InitialOODQueries)+j], linearStatementValueAtPoint))
}
Expand Down
2 changes: 1 addition & 1 deletion skyscraper/bn254-multiplier/examples/count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn diagonal() -> [usize; 12] {
println!();
}

// Since there is no data of the diagionals yet it is safe to double them. This
// Since there is no data of the diagonals yet it is safe to double them. This
// means that t[8][1] = t[9] needs to be included.
// t[0][1] is not touched by the diagonalisation so no need to include t[0]

Expand Down
2 changes: 1 addition & 1 deletion skyscraper/core/src/reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn reduce_partial(x: [u64; 4]) -> [u64; 4] {
/// Combined partial reduction and add round constant
/// Input can be any value.
/// Output is in range [0, 2M + ϵ) (TODO: Analyse more carefully)
/// TODO: Maybe with a round dependend lookup factor it can be [0, M + ϵ)
/// TODO: Maybe with a round dependent lookup factor it can be [0, M + ϵ)
#[inline(always)]
pub fn reduce_partial_add_rc(x: [u64; 4], rc: usize) -> [u64; 4] {
// The compiler should turn this division by constant into an umulh.
Expand Down
2 changes: 1 addition & 1 deletion skyscraper/fp-rounding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub unsafe fn with_rounding_mode<Mode: RoundingDirectionMarker, Input, Result>(
let guard = RoundingGuard::new();
// Tie the mode to the input such that mode will be seated before the first use
// of input by f.
// Tieing the input to the Mode does not seem to be strictly necessary, but it's
// Tying the input to the Mode does not seem to be strictly necessary, but it's
// here for added safety.
let (guard, input) = fence((guard, input));
let result = f(&guard, input);
Expand Down
Loading