Skip to content

Commit

Permalink
reduce errors
Browse files Browse the repository at this point in the history
  • Loading branch information
YaoGalteland committed Apr 15, 2024
1 parent 330a70a commit f78bd8b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 9 deletions.
2 changes: 2 additions & 0 deletions halo2_gadgets/src/ecc_opt.rs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
//! Optimized ECC gadgets.
pub mod chip;
2 changes: 0 additions & 2 deletions halo2_gadgets/src/sinsemilla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,6 @@ pub(crate) mod tests {
meta.enable_constant(constants);

let table_idx = meta.lookup_table_column();
#[cfg(feature = "zsa")]
let table_range_check_tag = meta.lookup_table_column();
let lagrange_coeffs = [
meta.fixed_column(),
meta.fixed_column(),
Expand Down
16 changes: 15 additions & 1 deletion halo2_gadgets/src/sinsemilla/chip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ where
F: FixedPoints<pallas::Affine>,
Commit: CommitDomains<pallas::Affine, F, Hash>,
{
/// The `LookupConfigType` associated type defines the configuration type used by
/// the implementing structure for lookup operations.
type LookupConfigType;

/// Returns a reference to the `SinsemillaConfigCommon` instance.
Expand Down Expand Up @@ -111,6 +113,7 @@ where
/// Configures constraints in the constraint system `meta` using the value 'y_q'
/// This function sets up various gates within the circuit to enforce the correct relationships
/// between variables according to elliptic curve arithmetic and the Sinsemilla hash function.
#[allow(non_snake_case)]
fn configure_from_y_q(&self, meta: &mut ConstraintSystem<pallas::Base>) {
let two = pallas::Base::from(2);

Expand Down Expand Up @@ -230,12 +233,23 @@ where
F: FixedPoints<pallas::Affine>,
Commit: CommitDomains<pallas::Affine, F, Hash>,
{
/// A type that holds any general chip state that needs to be loaded at the start of
/// [`Circuit::synthesize`]. This might simply be `()` for some chips.

Check failure on line 237 in halo2_gadgets/src/sinsemilla/chip.rs

View workflow job for this annotation

GitHub Actions / Intra-doc links

unresolved link to `Circuit::synthesize`

Check failure on line 237 in halo2_gadgets/src/sinsemilla/chip.rs

View workflow job for this annotation

GitHub Actions / Intra-doc links

unresolved link to `Circuit::synthesize`
type Loaded;

/// The `RangeCheckConfigType` associated type defines the configuration type used by
/// the implementing structure for lookup range check operations.
type RangeCheckConfigType;

/// The `SinsemillaConfigType` associated type defines the configuration type used by
/// the implementing structure for Sinsemilla hash operations.
type SinsemillaConfigType: SinsemillaConfigProps<Hash, Commit, F>;

/// The `LookupType` defines the number of column used in implementation.
/// It is (TableColumn, TableColumn, TableColumn) in the Vanilla version
/// It is (TableColumn, TableColumn, TableColumn, TableColumn) in the Optimized version
type LookupType;

/// Returns a reference to the `SinsemillaConfigCommon` instance.
fn base(&self) -> &SinsemillaConfigCommon<Hash, Commit, F>;

/// Reconstructs this chip from the given config.
Expand Down
12 changes: 10 additions & 2 deletions halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::super::{CommitDomains, HashDomains, SinsemillaInstructions};
use super::{NonIdentityEccPoint, SinsemillaChip, SinsemillaChipProps, SinsemillaConfigProps};
use super::{NonIdentityEccPoint, SinsemillaChip};
use crate::{
ecc::FixedPoints,
sinsemilla::primitives::{self as sinsemilla, lebs2ip_k, INV_TWO_POW_K, SINSEMILLA_S},
Expand All @@ -15,7 +15,6 @@ use group::ff::{PrimeField, PrimeFieldBits};
use pasta_curves::{arithmetic::CurveAffine, pallas};

use crate::sinsemilla::primitives::{K, S_PERSONALIZATION};

Check warning on line 17 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

unused imports: `K`, `S_PERSONALIZATION`

warning: unused imports: `K`, `S_PERSONALIZATION` --> halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs:17:37 | 17 | use crate::sinsemilla::primitives::{K, S_PERSONALIZATION}; | ^ ^^^^^^^^^^^^^^^^^

Check warning on line 17 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

unused imports: `K`, `S_PERSONALIZATION`

Check warning on line 17 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

unused imports: `K`, `S_PERSONALIZATION`

Check warning on line 17 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Book tests

unused imports: `K`, `S_PERSONALIZATION`

Check warning on line 17 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Book tests

unused imports: `K`, `S_PERSONALIZATION`

Check warning on line 17 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

unused imports: `K`, `S_PERSONALIZATION`

Check warning on line 17 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

unused imports: `K`, `S_PERSONALIZATION`

Check failure on line 17 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

unused imports: `K`, `S_PERSONALIZATION`

error: unused imports: `K`, `S_PERSONALIZATION` --> halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs:17:37 | 17 | use crate::sinsemilla::primitives::{K, S_PERSONALIZATION}; | ^ ^^^^^^^^^^^^^^^^^ | = note: `-D unused-imports` implied by `-D warnings`

Check warning on line 17 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

unused imports: `K`, `S_PERSONALIZATION`

Check warning on line 17 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

unused imports: `K`, `S_PERSONALIZATION`

Check warning on line 17 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

unused imports: `K`, `S_PERSONALIZATION`

Check warning on line 17 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

unused imports: `K`, `S_PERSONALIZATION`

Check warning on line 17 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

unused imports: `K`, `S_PERSONALIZATION`

Check warning on line 17 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

unused imports: `K`, `S_PERSONALIZATION`
use crate::utilities::lookup_range_check::LookupRangeCheck;
use group::prime::PrimeCurveAffine;

Check warning on line 18 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

unused import: `group::prime::PrimeCurveAffine`

warning: unused import: `group::prime::PrimeCurveAffine` --> halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs:18:5 | 18 | use group::prime::PrimeCurveAffine; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Check warning on line 18 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

unused import: `group::prime::PrimeCurveAffine`

Check warning on line 18 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

unused import: `group::prime::PrimeCurveAffine`

Check warning on line 18 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Book tests

unused import: `group::prime::PrimeCurveAffine`

Check warning on line 18 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Book tests

unused import: `group::prime::PrimeCurveAffine`

Check warning on line 18 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

unused import: `group::prime::PrimeCurveAffine`

Check warning on line 18 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

unused import: `group::prime::PrimeCurveAffine`

Check failure on line 18 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

unused import: `group::prime::PrimeCurveAffine`

error: unused import: `group::prime::PrimeCurveAffine` --> halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs:18:5 | 18 | use group::prime::PrimeCurveAffine; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Check warning on line 18 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

unused import: `group::prime::PrimeCurveAffine`

Check warning on line 18 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

unused import: `group::prime::PrimeCurveAffine`

Check warning on line 18 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

unused import: `group::prime::PrimeCurveAffine`

Check warning on line 18 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

unused import: `group::prime::PrimeCurveAffine`

Check warning on line 18 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

unused import: `group::prime::PrimeCurveAffine`

Check warning on line 18 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

unused import: `group::prime::PrimeCurveAffine`
use group::Curve;

Check warning on line 19 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

unused import: `group::Curve`

warning: unused import: `group::Curve` --> halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs:19:5 | 19 | use group::Curve; | ^^^^^^^^^^^^

Check warning on line 19 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

unused import: `group::Curve`

Check warning on line 19 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

unused import: `group::Curve`

Check warning on line 19 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Book tests

unused import: `group::Curve`

Check warning on line 19 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Book tests

unused import: `group::Curve`

Check warning on line 19 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

unused import: `group::Curve`

Check warning on line 19 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

unused import: `group::Curve`

Check failure on line 19 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

unused import: `group::Curve`

error: unused import: `group::Curve` --> halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs:19:5 | 19 | use group::Curve; | ^^^^^^^^^^^^

Check warning on line 19 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

unused import: `group::Curve`

Check warning on line 19 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

unused import: `group::Curve`

Check warning on line 19 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

unused import: `group::Curve`

Check warning on line 19 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

unused import: `group::Curve`

Check warning on line 19 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

unused import: `group::Curve`

Check warning on line 19 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

unused import: `group::Curve`
use pasta_curves::arithmetic::CurveExt;

Check warning on line 20 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Clippy (beta)

unused import: `pasta_curves::arithmetic::CurveExt`

warning: unused import: `pasta_curves::arithmetic::CurveExt` --> halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs:20:5 | 20 | use pasta_curves::arithmetic::CurveExt; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Check warning on line 20 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Book tests

unused import: `pasta_curves::arithmetic::CurveExt`

Check warning on line 20 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Book tests

unused import: `pasta_curves::arithmetic::CurveExt`

Check warning on line 20 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

unused import: `pasta_curves::arithmetic::CurveExt`

Check warning on line 20 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-wasi

unused import: `pasta_curves::arithmetic::CurveExt`

Check failure on line 20 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Clippy (MSRV)

unused import: `pasta_curves::arithmetic::CurveExt`

error: unused import: `pasta_curves::arithmetic::CurveExt` --> halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs:20:5 | 20 | use pasta_curves::arithmetic::CurveExt; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Check warning on line 20 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

unused import: `pasta_curves::arithmetic::CurveExt`

Check warning on line 20 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

unused import: `pasta_curves::arithmetic::CurveExt`

Check warning on line 20 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

unused import: `pasta_curves::arithmetic::CurveExt`

Check warning on line 20 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with nightly features

unused import: `pasta_curves::arithmetic::CurveExt`

Check warning on line 20 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with beta features

unused import: `pasta_curves::arithmetic::CurveExt`

Check warning on line 20 in halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest

unused import: `pasta_curves::arithmetic::CurveExt`
Expand Down Expand Up @@ -126,6 +125,9 @@ where
/// [Specification](https://p.z.cash/halo2-0.1:sinsemilla-constraints?partial).
#[allow(non_snake_case)]
#[allow(clippy::type_complexity)]
/// TODO: remove this function, the first step is to remove hash_to_point_with_private_init in SinsemillaInstructions
/// How can we enable hash_to_point_with_private_init in SinsemillaInstructions for the optimized version,
/// while disabling hash_to_point_with_private_init in SinsemillaInstructions for the orchard version?
pub(crate) fn hash_message_with_private_init(
&self,
region: &mut Region<'_, pallas::Base>,
Expand All @@ -150,6 +152,11 @@ where
}

#[allow(non_snake_case)]
/// Assign the coordinates of the initial public point `Q`
///
/// | offset | x_A | q_sinsemilla4 | fixed_y_q |
/// --------------------------------------
/// | 0 | x_Q | 1 | y_Q |
fn public_initialization_vanilla(
&self,
region: &mut Region<'_, pallas::Base>,
Expand Down Expand Up @@ -198,6 +205,7 @@ where
/// --------------------------------------
/// | 0 | | y_Q | |
/// | 1 | x_Q | | 1 |
/// TODO: remove this function, the first step is to remove hash_to_point_with_private_init in SinsemillaInstructions
fn private_initialization(
&self,
region: &mut Region<'_, pallas::Base>,
Expand Down
2 changes: 2 additions & 0 deletions halo2_gadgets/src/sinsemilla_opt.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
//! Optimized Sinsemilla gadgets.
pub mod chip;

Check failure on line 3 in halo2_gadgets/src/sinsemilla_opt.rs

View workflow job for this annotation

GitHub Actions / Intra-doc links

missing documentation for a module

Check failure on line 3 in halo2_gadgets/src/sinsemilla_opt.rs

View workflow job for this annotation

GitHub Actions / Intra-doc links

missing documentation for a module
pub mod merkle;
2 changes: 2 additions & 0 deletions halo2_gadgets/src/utilities/cond_swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub trait CondSwapInstructions<F: Field>: UtilitiesInstructions<F> {
swap: Value<bool>,
) -> Result<(Self::Var, Self::Var), Error>;

/// Given an input `(choice, left, right)` where `choice` is a boolean flag,
/// returns `left` if `choice` is not set and `right` if `choice` is set.
fn mux(
&self,
layouter: &mut impl Layouter<F>,
Expand Down
4 changes: 2 additions & 2 deletions halo2_gadgets/src/utilities/lookup_range_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ impl<F: PrimeFieldBits, const K: usize> LookupRangeCheck<F, K> for LookupRangeCh

// In the short range check, the word is directly witnessed.
let short_lookup = {
let short_word = z_cur.clone();
let q_short = one.clone() - q_running;
let short_word = z_cur;
let q_short = one - q_running;

q_short * short_word
};
Expand Down
5 changes: 3 additions & 2 deletions halo2_gadgets/src/utilities_opt.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Utility gadgets.
// TODO: after ecc_opt
//! Optimized Utility gadgets.
//!
// TODO: cond_swap after ecc_opt
//pub mod cond_swap;
pub mod lookup_range_check;

0 comments on commit f78bd8b

Please sign in to comment.