pub fn generate_nonce(seed: &[u8; 32], grinding_factor: u8) -> Option<u64> {
    let inner_hash = get_inner_hash(seed, grinding_factor);
    let limit = 1 << (64 - grinding_factor);

    #[cfg(not(feature = "parallel"))]
    return (0..u64::MAX).find(|&candidate_nonce| {
        is_valid_nonce_for_inner_hash(&inner_hash, candidate_nonce, limit)
    });

    #[cfg(feature = "parallel")]
    return (0..u64::MAX).into_par_iter().find_any(|&candidate_nonce| {
        is_valid_nonce_for_inner_hash(&inner_hash, candidate_nonce, limit)
    });
}
Performs grinding, returning a new nonce for the proof.
The nonce generated is such that:
Hash(Hash(prefix || seed || grinding_factor) || nonce) has at least `grinding_factor` zeros
to the left.
`prefix` is the bit-string `0x123456789abcded`

# Parameters

* `seed`: the input seed,
* `grinding_factor`: the number of leading zeros needed.

# Returns

A `nonce` satisfying the required condition.
crates/provers/stark/src/grinding.rs