Skip to content

Commit

Permalink
Fix some typos (#265)
Browse files Browse the repository at this point in the history
* chore: fixing typos

* fix: lint issue
  • Loading branch information
0xisk authored Mar 29, 2024
1 parent a471b14 commit 321f00b
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 48 deletions.
2 changes: 1 addition & 1 deletion halo2-base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ QuantumCell contains the following enum variants.
Assigns an entirely new witness value into the advice column, such as a private input. When `assign_cell()` is called the value is wrapped in as an `Assigned::Trivial()` which marks it for exclusion from batch inversion.

- **WitnessFraction**:
Assigns an entirely new witness value to the advice column. `WitnessFraction` exists for optimization purposes and accepts Assigned values wrapped in `Assigned::Rational()` marked for batch inverion (see [Assigned](#assigned)).
Assigns an entirely new witness value to the advice column. `WitnessFraction` exists for optimization purposes and accepts Assigned values wrapped in `Assigned::Rational()` marked for batch inversion (see [Assigned](#assigned)).

- **Constant**:
A value that is a "known" constant. A "known" refers to known at circuit creation time to both the Prover and Verifier. When you assign a constant value there exists another secret Fixed column in the circuit constraint table whose values are fixed at circuit creation time. When you assign a Constant value, you are adding this value to the Fixed column, adding the value as a witness to the Advice column, and then imposing an equality constraint between the two corresponding cells in the Fixed and Advice columns.
4 changes: 2 additions & 2 deletions halo2-base/src/gates/circuit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<F: ScalarField> Default for BaseCircuitBuilder<F> {
impl<F: ScalarField> BaseCircuitBuilder<F> {
/// Creates a new [BaseCircuitBuilder] with all default managers.
/// * `witness_gen_only`:
/// * If true, the builder only does witness asignments and does not store constraint information -- this should only be used for the real prover.
/// * If true, the builder only does witness assignments and does not store constraint information -- this should only be used for the real prover.
/// * If false, the builder also imposes constraints (selectors, fixed columns, copy constraints). Primarily used for keygen and mock prover (but can also be used for real prover).
///
/// By default, **no** circuit configuration parameters have been set.
Expand Down Expand Up @@ -254,7 +254,7 @@ impl<F: ScalarField> BaseCircuitBuilder<F> {

/// Auto-calculates configuration parameters for the circuit and sets them.
///
/// * `k`: The number of in the circuit (i.e. numeber of rows = 2<sup>k</sup>)
/// * `k`: The number of in the circuit (i.e. number of rows = 2<sup>k</sup>)
/// * `minimum_rows`: The minimum number of rows in the circuit that cannot be used for witness assignments and contain random `blinding factors` to ensure zk property, defaults to 0.
/// * `lookup_bits`: The fixed lookup table will consist of [0, 2<sup>lookup_bits</sup>)
pub fn calculate_params(&mut self, minimum_rows: Option<usize>) -> BaseCircuitParams {
Expand Down
6 changes: 3 additions & 3 deletions halo2-base/src/gates/flex_gate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ pub trait GateInstructions<F: ScalarField> {
ctx.last().unwrap()
}

/// Constrains and returns `a & b`, assumeing `a` and `b` are boolean.
/// Constrains and returns `a & b`, assuming `a` and `b` are boolean.
///
/// Defines a vertical gate of form | 0 | a | b | out |, where out = a * b.
/// * `ctx`: [Context] to add the constraints to.
Expand Down Expand Up @@ -590,7 +590,7 @@ pub trait GateInstructions<F: ScalarField> {
ctx.last().unwrap()
}

/// Constrains and returns `!a` assumeing `a` is boolean.
/// Constrains and returns `!a` assuming `a` is boolean.
///
/// Defines a vertical gate of form | 1 - a | a | 1 | 1 |, where 1 - a = out.
/// * `ctx`: [Context] to add the constraints to.
Expand Down Expand Up @@ -1204,7 +1204,7 @@ impl<F: ScalarField> GateInstructions<F> for GateChip<F> {
ctx.last().unwrap()
}

/// Constains and returns `a || (b && c)`, assuming `a`, `b` and `c` are boolean.
/// Constrains and returns `a || (b && c)`, assuming `a`, `b` and `c` are boolean.
///
/// Defines a vertical gate of form `| 1 - b c | b | c | 1 | a - 1 | 1 - b c | out | a - 1 | 1 | 1 | a |`, where out = a + b * c - a * b * c.
/// * `ctx`: [Context] to add the constraints to
Expand Down
4 changes: 2 additions & 2 deletions halo2-base/src/gates/flex_gate/threads/multi_phase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl<F: ScalarField> MultiPhaseCoreManager<F> {
/// Creates a new [MultiPhaseCoreManager] with a default [SinglePhaseCoreManager] in phase 0.
/// Creates an empty [SharedCopyConstraintManager] and sets `witness_gen_only` flag.
/// * `witness_gen_only`: If true, the [MultiPhaseCoreManager] is used for witness generation only.
/// * If true, the gate thread builder only does witness asignments and does not store constraint information -- this should only be used for the real prover.
/// * If true, the gate thread builder only does witness assignments and does not store constraint information -- this should only be used for the real prover.
/// * If false, the gate thread builder is used for keygen and mock prover (it can also be used for real prover) and the builder stores circuit information (e.g. copy constraints, fixed columns, enabled selectors).
/// * These values are fixed for the circuit at key generation time, and they do not need to be re-computed by the prover in the actual proving phase.
pub fn new(witness_gen_only: bool) -> Self {
Expand Down Expand Up @@ -126,7 +126,7 @@ impl<F: ScalarField> MultiPhaseCoreManager<F> {

/// Auto-calculates configuration parameters for the circuit
///
/// * `k`: The number of in the circuit (i.e. numeber of rows = 2<sup>k</sup>)
/// * `k`: The number of in the circuit (i.e. number of rows = 2<sup>k</sup>)
/// * `minimum_rows`: The minimum number of rows in the circuit that cannot be used for witness assignments and contain random `blinding factors` to ensure zk property, defaults to 0.
pub fn calculate_params(&self, k: usize, minimum_rows: Option<usize>) -> FlexGateConfigParams {
let max_rows = (1 << k) - minimum_rows.unwrap_or(0);
Expand Down
2 changes: 1 addition & 1 deletion halo2-base/src/gates/flex_gate/threads/single_phase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct SinglePhaseCoreManager<F: ScalarField> {
impl<F: ScalarField> SinglePhaseCoreManager<F> {
/// Creates a new [SinglePhaseCoreManager] and spawns a main thread.
/// * `witness_gen_only`: If true, the [SinglePhaseCoreManager] is used for witness generation only.
/// * If true, the gate thread builder only does witness asignments and does not store constraint information -- this should only be used for the real prover.
/// * If true, the gate thread builder only does witness assignments and does not store constraint information -- this should only be used for the real prover.
/// * If false, the gate thread builder is used for keygen and mock prover (it can also be used for real prover) and the builder stores circuit information (e.g. copy constraints, fixed columns, enabled selectors).
/// * These values are fixed for the circuit at key generation time, and they do not need to be re-computed by the prover in the actual proving phase.
pub fn new(witness_gen_only: bool, copy_manager: SharedCopyConstraintManager<F>) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion halo2-base/src/gates/tests/bitwise_rotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn test_bitwise_rotate_gen<const BIT: usize, const NUM_BITS: usize>(

#[test]
fn test_bitwise_rotate() {
// "<<" is leftroate. ">>" is rightrotate.
// "<<" is leftrotate. ">>" is rightrotate.
// 1 << 8 == 256
test_bitwise_rotate_gen::<8, 10>(8, true, 1, 256, true);
// 1 << 8 != 255
Expand Down
2 changes: 1 addition & 1 deletion halo2-base/src/gates/tests/neg_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn arb_indicator<F: ScalarField>(max_size: usize) -> impl Strategy<Value = Vec<F

fn check_idx_to_indicator(idx: Fr, len: usize, ind_witnesses: &[Fr]) -> bool {
// check that:
// the length of the witnes array is correct
// the length of the witness array is correct
// the sum of the witnesses is 1, indicting that there is only one index that is 1
if ind_witnesses.len() != len
|| ind_witnesses.iter().fold(Fr::zero(), |acc, val| acc + *val) != Fr::one()
Expand Down
2 changes: 1 addition & 1 deletion halo2-base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use virtual_region::copy_constraints::SharedCopyConstraintManager;
pub mod gates;
/// Module for the Poseidon hash function.
pub mod poseidon;
/// Module for SafeType which enforce value range and realted functions.
/// Module for SafeType which enforce value range and related functions.
pub mod safe_types;
/// Utility functions for converting between different types of field elements.
pub mod utils;
Expand Down
2 changes: 1 addition & 1 deletion halo2-base/src/poseidon/hasher/mds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct SparseMDSMatrix<F: PrimeField, const T: usize, const RATE: usize> {
pub(crate) col_hat: [F; RATE],
}

/// `MDSMatrix` is applied to `State` to achive linear layer of Poseidon
/// `MDSMatrix` is applied to `State` to achieve linear layer of Poseidon
#[derive(Clone, Debug)]
pub struct MDSMatrix<F, const T: usize, const RATE: usize>(pub(crate) Mds<F, T>);

Expand Down
22 changes: 12 additions & 10 deletions halo2-base/src/poseidon/hasher/tests/hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct Payload<F: ScalarField> {
}

// check if the results from hasher and native sponge are same for hash_var_len_array.
fn hasher_compatiblity_verification<
fn hasher_compatibility_verification<
const T: usize,
const RATE: usize,
const R_F: usize,
Expand Down Expand Up @@ -50,7 +50,7 @@ fn hasher_compatiblity_verification<
}

// check if the results from hasher and native sponge are same for hash_compact_input.
fn hasher_compact_inputs_compatiblity_verification<
fn hasher_compact_inputs_compatibility_verification<
const T: usize,
const RATE: usize,
const R_F: usize,
Expand Down Expand Up @@ -115,7 +115,7 @@ fn hasher_compact_inputs_compatiblity_verification<
}

// check if the results from hasher and native sponge are same for hash_compact_input.
fn hasher_compact_chunk_inputs_compatiblity_verification<
fn hasher_compact_chunk_inputs_compatibility_verification<
const T: usize,
const RATE: usize,
const R_F: usize,
Expand Down Expand Up @@ -189,7 +189,7 @@ fn random_payload_without_len<F: ScalarField>(max_len: usize, max_value: usize)
}

#[test]
fn test_poseidon_hasher_compatiblity() {
fn test_poseidon_hasher_compatibility() {
{
const T: usize = 3;
const RATE: usize = 2;
Expand All @@ -216,7 +216,7 @@ fn test_poseidon_hasher_compatiblity() {
random_payload(RATE * 2 + 1, RATE * 2 + 1, usize::MAX),
random_payload(RATE * 5 + 1, RATE * 5 + 1, usize::MAX),
];
hasher_compatiblity_verification::<T, RATE, 8, 57>(payloads);
hasher_compatibility_verification::<T, RATE, 8, 57>(payloads);
}
}

Expand Down Expand Up @@ -262,7 +262,9 @@ fn test_poseidon_hasher_compact_inputs() {
random_payload(RATE * 5, RATE * 5, usize::MAX),
];
base_test().k(12).run(|ctx, range| {
hasher_compact_inputs_compatiblity_verification::<T, RATE, 8, 57>(payloads, ctx, range);
hasher_compact_inputs_compatibility_verification::<T, RATE, 8, 57>(
payloads, ctx, range,
);
});
}
}
Expand All @@ -289,7 +291,7 @@ fn test_poseidon_hasher_compact_inputs_with_prover() {
.collect::<Vec<_>>();
base_test().k(12).bench_builder(init_payloads, logic_payloads, |pool, range, input| {
let ctx = pool.main();
hasher_compact_inputs_compatiblity_verification::<T, RATE, 8, 57>(input, ctx, range);
hasher_compact_inputs_compatibility_verification::<T, RATE, 8, 57>(input, ctx, range);
});
}
}
Expand All @@ -306,7 +308,7 @@ fn test_poseidon_hasher_compact_chunk_inputs() {
(random_payload(RATE * 3, RATE * 3, usize::MAX), true),
];
base_test().k(12).run(|ctx, range| {
hasher_compact_chunk_inputs_compatiblity_verification::<T, RATE, 8, 57>(
hasher_compact_chunk_inputs_compatibility_verification::<T, RATE, 8, 57>(
payloads, ctx, range,
);
});
Expand All @@ -320,7 +322,7 @@ fn test_poseidon_hasher_compact_chunk_inputs() {
(random_payload(0, 0, usize::MAX), false),
];
base_test().k(12).run(|ctx, range| {
hasher_compact_chunk_inputs_compatiblity_verification::<T, RATE, 8, 57>(
hasher_compact_chunk_inputs_compatibility_verification::<T, RATE, 8, 57>(
payloads, ctx, range,
);
});
Expand Down Expand Up @@ -349,7 +351,7 @@ fn test_poseidon_hasher_compact_chunk_inputs_with_prover() {
.collect::<Vec<_>>();
base_test().k(12).bench_builder(init_payloads, logic_payloads, |pool, range, input| {
let ctx = pool.main();
hasher_compact_chunk_inputs_compatiblity_verification::<T, RATE, 8, 57>(
hasher_compact_chunk_inputs_compatibility_verification::<T, RATE, 8, 57>(
input, ctx, range,
);
});
Expand Down
8 changes: 4 additions & 4 deletions halo2-base/src/safe_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const BITS_PER_BYTE: usize = 8;
/// where each [`AssignedValue`] represents 1 byte. However, the range of [`AssignedValue<F>`] is much
/// larger than 1 byte(0~255). If a circuit takes 32 [`AssignedValue<F>`] as inputs and some of them
/// are actually greater than 255, there could be some undefined behaviors.
/// [`SafeType`] gurantees the value range of its owned [`AssignedValue<F>`]. So circuits don't need to
/// [`SafeType`] guarantees the value range of its owned [`AssignedValue<F>`]. So circuits don't need to
/// do any extra value checking if they take SafeType as inputs.
/// - `TOTAL_BITS` is the number of total bits of this type.
/// - `BYTES_PER_ELE` is the number of bytes of each element.
Expand Down Expand Up @@ -131,7 +131,7 @@ impl<'a, F: ScalarField> SafeTypeChip<'a, F> {

/// Convert a vector of AssignedValue (treated as little-endian) to a SafeType.
/// The number of bytes of inputs must equal to the number of bytes of outputs.
/// This function also add contraints that a AssignedValue in inputs must be in the range of a byte.
/// This function also add constraints that a AssignedValue in inputs must be in the range of a byte.
pub fn raw_bytes_to<const BYTES_PER_ELE: usize, const TOTAL_BITS: usize>(
&self,
ctx: &mut Context<F>,
Expand Down Expand Up @@ -276,7 +276,7 @@ impl<'a, F: ScalarField> SafeTypeChip<'a, F> {
///
/// * inputs: Vector representing the byte array, right padded to `max_len`. See [VarLenBytesVec] for details about padding.
/// * len: [`AssignedValue<F>`] witness representing the variable length of the byte array. Constrained to be `<= max_len`.
/// * max_len: [usize] representing the maximum length of the byte array and the number of elements it must contain. We enforce this to be provided explictly to make sure length of `inputs` is determinstic.
/// * max_len: [usize] representing the maximum length of the byte array and the number of elements it must contain. We enforce this to be provided explicitly to make sure length of `inputs` is deterministic.
///
/// ## Assumptions
/// * `max_len < u64::MAX` to prevent overflow (but you should never make an array this large)
Expand Down Expand Up @@ -311,7 +311,7 @@ impl<'a, F: ScalarField> SafeTypeChip<'a, F> {
/// Converts a slice of AssignedValue(treated as little-endian) to FixLenBytesVec.
///
/// * inputs: Slice representing the byte array.
/// * len: length of the byte array. We enforce this to be provided explictly to make sure length of `inputs` is determinstic.
/// * len: length of the byte array. We enforce this to be provided explicitly to make sure length of `inputs` is deterministic.
pub fn raw_to_fix_len_bytes_vec(
&self,
ctx: &mut Context<F>,
Expand Down
2 changes: 1 addition & 1 deletion halo2-ecc/src/bigint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl<F: BigPrimeField> FixedOverflowInteger<F> {

/// Input: a BigInteger `value`, Output: the `FixedOverflowInteger` that represents the same value
/// Can handle signs
/// Note the representation of the integer will be in proper (no overflow) format, if signs are interpretted correctly
/// Note the representation of the integer will be in proper (no overflow) format, if signs are interpreted correctly
pub fn from_native(value: &BigUint, num_limbs: usize, limb_bits: usize) -> Self {
let limbs = decompose_biguint(value, num_limbs, limb_bits);
Self { limbs }
Expand Down
4 changes: 2 additions & 2 deletions halo2-ecc/src/ecc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ where
EcPoint::new(Rx, Ry)
}

// takes the dot product of points with sel, where each is intepreted as
// takes the dot product of points with sel, where each is interpreted as
// a _vector_
pub fn ec_select_by_indicator<F: BigPrimeField, FC, Pt>(
chip: &FC,
Expand Down Expand Up @@ -635,7 +635,7 @@ where

// need to supply an extra generic `C` implementing `CurveAffine` trait in order to generate random witness points on the curve in question
// Using Simultaneous 2^w-Ary Method, see https://www.bmoeller.de/pdf/multiexp-sac2001.pdf
// Random Accumlation point trick learned from halo2wrong: https://hackmd.io/ncuKqRXzR-Cw-Au2fGzsMg?view
// Random Accumulation point trick learned from halo2wrong: https://hackmd.io/ncuKqRXzR-Cw-Au2fGzsMg?view
// Input:
// - `scalars` is vector of same length as `P`
// - each `scalar` in `scalars` satisfies same assumptions as in `scalar_multiply` above
Expand Down
2 changes: 1 addition & 1 deletion halo2-ecc/src/ecc/schnorr_signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ where
let x_neq = base_chip.gate().not(ctx, x_eq);

// R = s⋅G - e⋅P
// R is not infinity point implicitly constrainted by is_strict = true
// R is not infinity point implicitly constrained by is_strict = true
let R = chip.sub_unequal(ctx, s_G, e_P, true);

// check R.y is even
Expand Down
2 changes: 1 addition & 1 deletion halo2-ecc/src/fields/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub trait FieldChip<F: BigPrimeField>: Clone + Send + Sync {
/// Assigns `fe` as private witness. Note that the witness may **not** be constrained to be a unique representation of the field element `fe`.
fn load_private(&self, ctx: &mut Context<F>, fe: Self::FieldType) -> Self::FieldPoint;

/// Assigns `fe` as private witness and contrains the witness to be in reduced form.
/// Assigns `fe` as private witness and constrains the witness to be in reduced form.
fn load_private_reduced(
&self,
ctx: &mut Context<F>,
Expand Down
2 changes: 1 addition & 1 deletion halo2-ecc/src/fields/native_fp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<'range, F: BigPrimeField> FieldChip<F> for NativeFieldChip<'range, F> {
a: impl Into<AssignedValue<F>>,
max_bits: usize, // the maximum bits that a.value could take
) {
// skip range chek if max_bits >= F::NUM_BITS
// skip range check if max_bits >= F::NUM_BITS
if max_bits < F::NUM_BITS as usize {
let a: AssignedValue<F> = a.into();
self.range().range_check(ctx, a, max_bits);
Expand Down
Loading

0 comments on commit 321f00b

Please sign in to comment.