Skip to content

Commit 88a54cf

Browse files
authored
refactor(stark): the grinding factor is not "security_bits" (#979)
Three local bindings read `proof_options.grinding_factor` and named it `security_bits`, then passed it to functions whose own parameter is `grinding_factor`: prover.rs:2286 let security_bits = air.context().proof_options.grinding_factor; verifier.rs:1582 let security_bits = air.context().proof_options.grinding_factor; verifier.rs:1665 let security_bits = air.context().proof_options.grinding_factor; Grinding is not the security level. It is one term in the query round's error, and it cannot move the commit-phase term at all — so a reader who takes these bindings at their word concludes the proof carries 20 bits of security, or that raising the grinding factor raises security generally. Neither follows. `grinding_factor` is what every function behind these call sites already calls the argument (`grinding::is_valid_nonce`, `generate_nonce`, `generate_nonce_maybe_gpu`), so the rename removes a mismatch rather than introducing a new convention. Nothing is shadowed: the name appeared in these two files only as the struct field being read. Eight identifier occurrences, no behaviour, no field moved. The one operator- facing message in the area already says the right thing — `error!("Grinding factor not satisfied")` — so no text needed correcting alongside the names.
1 parent fb6f23e commit 88a54cf

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎crypto/stark/src/prover.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,11 +2283,11 @@ pub trait IsStarkProver<
22832283
// grinding: generate nonce and append it to the transcript
22842284
#[cfg(feature = "instruments")]
22852285
let t_sub = Instant::now();
2286-
let security_bits = air.context().proof_options.grinding_factor;
2286+
let grinding_factor = air.context().proof_options.grinding_factor;
22872287
let mut nonce = None;
2288-
if security_bits > 0 {
2288+
if grinding_factor > 0 {
22892289
let nonce_value =
2290-
grinding::generate_nonce_maybe_gpu(&transcript.state(), security_bits)
2290+
grinding::generate_nonce_maybe_gpu(&transcript.state(), grinding_factor)
22912291
.expect("nonce not found");
22922292
transcript.append_bytes(&nonce_value.to_be_bytes());
22932293
nonce = Some(nonce_value);

‎crypto/stark/src/verifier.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,9 +1579,9 @@ pub trait IsStarkVerifier<
15791579
}
15801580

15811581
// Receive grinding value
1582-
let security_bits = air.context().proof_options.grinding_factor;
1582+
let grinding_factor = air.context().proof_options.grinding_factor;
15831583
let mut grinding_seed = [0u8; 32];
1584-
if security_bits > 0
1584+
if grinding_factor > 0
15851585
&& let Some(nonce_value) = proof.nonce()
15861586
{
15871587
grinding_seed = transcript.state();
@@ -1662,10 +1662,10 @@ pub trait IsStarkVerifier<
16621662
);
16631663

16641664
// verify grinding
1665-
let security_bits = air.context().proof_options.grinding_factor;
1666-
if security_bits > 0 {
1665+
let grinding_factor = air.context().proof_options.grinding_factor;
1666+
if grinding_factor > 0 {
16671667
let nonce_is_valid = proof.nonce().is_some_and(|nonce_value| {
1668-
grinding::is_valid_nonce(&challenges.grinding_seed, nonce_value, security_bits)
1668+
grinding::is_valid_nonce(&challenges.grinding_seed, nonce_value, grinding_factor)
16691669
});
16701670

16711671
if !nonce_is_valid {

0 commit comments

Comments
 (0)