Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
wip: having trait bound error
Browse files Browse the repository at this point in the history
  • Loading branch information
KimiWu123 committed Jan 10, 2024
1 parent 1e04b70 commit 9f248ba
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 83 deletions.
100 changes: 29 additions & 71 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions zkevm-circuits/src/sig_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ pub struct SigCircuitConfigArgs<F: Field> {

/// SignVerify Configuration
#[derive(Debug, Clone)]
pub struct SigCircuitConfig<F: Field> {
pub struct SigCircuitConfig<F>
where
F: Field + halo2_base::utils::ScalarField,
{
/// ECDSA
ecdsa_config: FpChip<F>,
// ecdsa_config: FpConfig<F, Fp>,
/// An advice column to store RLC witnesses
rlc_column: Column<Advice>,
/// selector for keccak lookup table
Expand All @@ -84,7 +88,10 @@ pub struct SigCircuitConfig<F: Field> {
sig_table: SigTable,
}

impl<F: Field> SubCircuitConfig<F> for SigCircuitConfig<F> {
impl<F> SubCircuitConfig<F> for SigCircuitConfig<F>
where
F: Field + halo2_base::utils::ScalarField,
{
type ConfigArgs = SigCircuitConfigArgs<F>;

/// Return a new SigConfig
Expand Down Expand Up @@ -199,7 +206,7 @@ impl<F: Field> SubCircuitConfig<F> for SigCircuitConfig<F> {
}
}

impl<F: Field> SigCircuitConfig<F> {
impl<F: Field + halo2_base::utils::ScalarField> SigCircuitConfig<F> {
pub(crate) fn load_range(&self, layouter: &mut impl Layouter<F>) -> Result<(), Error> {
self.ecdsa_config.range.load_lookup_table(layouter)
}
Expand All @@ -217,7 +224,7 @@ pub struct SigCircuit<F: Field> {
pub _marker: PhantomData<F>,
}

impl<F: Field> SubCircuit<F> for SigCircuit<F> {
impl<F: Field + halo2_base::utils::ScalarField> SubCircuit<F> for SigCircuit<F> {
type Config = SigCircuitConfig<F>;

fn new_from_block(block: &crate::witness::Block<F>) -> Self {
Expand Down Expand Up @@ -313,7 +320,7 @@ impl<F: Field> SigCircuit<F> {
}
}

impl<F: Field> SigCircuit<F> {
impl<F: Field + halo2_base::utils::ScalarField> SigCircuit<F> {
/// Verifies the ecdsa relationship. I.e., prove that the signature
/// is (in)valid or not under the given public key and the message hash in
/// the circuit. Does not enforce the signature is valid.
Expand Down
6 changes: 3 additions & 3 deletions zkevm-circuits/src/sig_circuit/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use halo2_proofs::{circuit::SimpleFloorPlanner, plonk::Circuit};

/// SigCircuitTesterConfig
#[derive(Clone, Debug)]
pub struct SigCircuitTesterConfig<F: Field> {
pub struct SigCircuitTesterConfig<F: Field + halo2_base::utils::ScalarField> {
sign_verify: SigCircuitConfig<F>,
challenges: crate::util::Challenges,
}

impl<F: Field> SigCircuitTesterConfig<F> {
impl<F: Field + halo2_base::utils::ScalarField> SigCircuitTesterConfig<F> {
pub(crate) fn new(meta: &mut ConstraintSystem<F>) -> Self {
let keccak_table = KeccakTable::construct(meta);
let sig_table = SigTable::construct(meta);
Expand All @@ -34,7 +34,7 @@ impl<F: Field> SigCircuitTesterConfig<F> {
}
}

impl<F: Field> Circuit<F> for SigCircuit<F> {
impl<F: Field + halo2_base::utils::ScalarField> Circuit<F> for SigCircuit<F> {
type Config = SigCircuitTesterConfig<F>;
type FloorPlanner = SimpleFloorPlanner;
type Params = ();
Expand Down
8 changes: 4 additions & 4 deletions zkevm-circuits/src/sig_circuit/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub(super) type FqChip<F> = FpConfig<F, Fq>;
/// Chip to handle ECDSA::Fp, the base field
pub(super) type FpChip<F> = FpConfig<F, Fp>;

pub(crate) struct AssignedECDSA<F: Field, FC: FieldChip<F>> {
pub(crate) struct AssignedECDSA<F: Field + halo2_base::utils::ScalarField, FC: FieldChip<F>> {
pub(super) pk: EcPoint<F, FC::FieldPoint>,
pub(super) pk_is_zero: AssignedValue<F>,
pub(super) msg_hash: CRTInteger<F>,
Expand All @@ -76,7 +76,7 @@ pub(crate) struct AssignedECDSA<F: Field, FC: FieldChip<F>> {
}

#[derive(Debug, Clone)]
pub(crate) struct AssignedSignatureVerify<F: Field> {
pub(crate) struct AssignedSignatureVerify<F: Field + halo2_base::utils::ScalarField> {
pub(crate) address: AssignedValue<F>,
pub(crate) msg_len: usize,
pub(crate) msg_rlc: Value<F>,
Expand All @@ -87,13 +87,13 @@ pub(crate) struct AssignedSignatureVerify<F: Field> {
pub(crate) sig_is_valid: AssignedValue<F>,
}

pub(super) struct SignDataDecomposed<F: Field> {
pub(super) struct SignDataDecomposed<F: Field + halo2_base::utils::ScalarField> {
pub(super) pk_hash_cells: Vec<QuantumCell<F>>,
pub(super) msg_hash_cells: Vec<QuantumCell<F>>,
pub(super) pk_cells: Vec<QuantumCell<F>>,
pub(super) address: AssignedValue<F>,
pub(super) is_address_zero: AssignedValue<F>,
pub(super) r_cells: Vec<QuantumCell<F>>,
pub(super) s_cells: Vec<QuantumCell<F>>,
//v: AssignedValue<'v, F>, // bool
// v: AssignedValue<'v, F>, // bool
}

0 comments on commit 9f248ba

Please sign in to comment.