Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrchardZSA backward compatability using traits #31

Merged
merged 123 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 120 commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
80dfd60
add initial doc
Apr 23, 2024
d3a6f42
clean up code
Apr 24, 2024
86bd33f
remove cfg[test]
Apr 24, 2024
989f29b
remove generator table trait, fix hash_to_point
Apr 25, 2024
507a53c
update code for hash
Apr 29, 2024
2e31e97
fmt
Apr 29, 2024
b02478a
fix run tests error
Apr 29, 2024
e6d1dbe
minor update
Apr 29, 2024
23a2951
test error
Apr 29, 2024
301e7d8
Revert "test error"
Apr 29, 2024
c324006
re-naming structs and functions
Apr 30, 2024
af29df4
fix complex type
Apr 30, 2024
1ea04bb
add round trip test to verify that the pinned verification key (repre…
May 6, 2024
684c13e
update serialized_proof_test_case
May 6, 2024
a25a6ad
update
May 6, 2024
42f1b0a
update short lookup test
May 6, 2024
2b89fae
cargo fmt
May 6, 2024
8552c97
fix Clippy error
May 6, 2024
f35cbe9
clean up code
May 7, 2024
f65d5a3
add initial files
May 10, 2024
7e50d0b
minor update
May 10, 2024
58f8b3f
remove pub(crate) in ecc
May 13, 2024
738eabe
add a line after cargo.toml
May 13, 2024
0fb6dd4
add a line after cargo.toml
May 13, 2024
e2c9c30
slide lines in base_field_elem
May 13, 2024
5322c81
slide lines in base_field_elem
May 13, 2024
46773e3
adjuct function orders for configure in sinsemilla/chip
May 13, 2024
3621e0e
adjuct function orders for hash_message
May 13, 2024
a30596b
adjuct function orders for hash_message
May 13, 2024
b3cb453
cleanup code
May 13, 2024
cf2bd37
cleanup code
May 13, 2024
da85c71
cleanup code
May 13, 2024
a5bf5ee
resolve review
May 14, 2024
8d27dd7
Introduce conditionally_save_circuit_to_disk function to reuse the pr…
dmidem May 14, 2024
48f941e
Rename conditionally_save_circuit_to_disk function to conditionally_s…
dmidem May 14, 2024
58b7eff
Introduce test_serialized_proof_with_vk and test_serialized_proof fun…
dmidem May 14, 2024
756bb78
Fix cargo clippy error
dmidem May 14, 2024
6814fc2
rename
May 14, 2024
64a8ac2
fix git error
May 14, 2024
704d3f6
Move all test .bin files and test_circuit.rs module to new tests fold…
dmidem May 14, 2024
d0d3a6f
Add missed files
dmidem May 14, 2024
35f161d
Move all .bin and vk_ test data files into src/tests folder
dmidem May 14, 2024
497c290
add tests for short range check
May 14, 2024
d3a9d4e
Add fixed_verification_key_test_with_circuit function to generalize V…
dmidem May 15, 2024
cf8aca0
Avoid duplicating test data folder name src/tests in every file name,…
dmidem May 15, 2024
b7c7261
Remove 'else' in fixed_verification_key_test_with_circuit function, t…
dmidem May 15, 2024
d3c7eb0
Use fs::read, fs::write instad of read_test_case and write_test_case
dmidem May 15, 2024
af5fd9c
Merge branch 'improve-backward-compatability-without-zsa' of github.c…
May 15, 2024
5248a0a
revert .github/workflows/ci.yml
May 15, 2024
8a68152
rename circuit.rs
May 15, 2024
8dbb582
add a line
May 15, 2024
32842df
fix ci.yml
May 15, 2024
3324348
Rename PallasLookupRC LookupRangeCheck trait alias to PallasLookup. A…
dmidem May 15, 2024
92922be
Move circuit test data to tests/circuit_reference_data folder, fix na…
dmidem May 15, 2024
6c7713f
Rename circuit_reference_data to circuit_data
dmidem May 15, 2024
8922ed6
Fix cargo fmt issues
dmidem May 15, 2024
f75b054
Try to increase cargo-tarpaulin timeout in ci.yml from 600 to 1800 to…
dmidem May 16, 2024
5414d95
Add default generic arguments for PallasLookup to improve backward co…
dmidem May 17, 2024
396bbde
Try to increase cargo-tarpaulin timeout in ci.yml from to 3600
dmidem May 22, 2024
1ae0a31
update
May 28, 2024
adf4d0d
cargo fmt
May 28, 2024
807304d
Merge branch 'improve-backward-compatability-without-zsa-default-gene…
dmidem May 28, 2024
1bb0b84
add index to proofs
May 28, 2024
923293b
rename PallasLookupRC10b to PallasLookupRCConfig
May 30, 2024
9ecbd65
resolve some comments
May 30, 2024
9337142
add zsa feature
Jun 3, 2024
8a8aca2
fix cargo clippy
Jun 3, 2024
4de57c1
fix shrot test
Jun 3, 2024
1c694c6
add some docs
Jun 3, 2024
aedcc54
Fix error in ci.yml
Jun 4, 2024
b252579
remove space in ci.yml
Jun 4, 2024
ce24e86
order functions in hash_to_point
Jun 4, 2024
5474c7c
order functions in hash_to_point
Jun 4, 2024
1cac5b7
crate -> super
Jun 4, 2024
ddee3ed
re-order cond_swap and lookup
Jun 4, 2024
637abbc
re-order cond_swap
Jun 4, 2024
9cef0b0
remove crate for configure_with_tag
Jun 4, 2024
f69907b
lookup tests update
Jun 4, 2024
9b4c51f
change sinsemillachip to sinsemillachipOptimized
Jun 4, 2024
2069bd1
Cleanup code and some renamings
ConstanceBeguier Jun 11, 2024
1a21413
rust fmt
ConstanceBeguier Jun 11, 2024
de56201
Remove EccInstructionsOptimized
ConstanceBeguier Jun 14, 2024
52e6fbb
Remove dead_code flag on EccPointQ
ConstanceBeguier Jun 14, 2024
8d13e7a
Remove CondSwapInstructionsOptimized
ConstanceBeguier Jun 14, 2024
36a9319
Clean imports
ConstanceBeguier Jun 17, 2024
6cab338
Remove redundancy in lookup_range_check tests
ConstanceBeguier Jun 18, 2024
474cfac
Save test files for optimized lookup range check
ConstanceBeguier Jun 21, 2024
ce807ea
Fix test_against_stored_ecc_chip_4_5_b
ConstanceBeguier Jun 21, 2024
8c55c6f
Put together test_against_stored_vk/proof into test_against_stored_ci…
ConstanceBeguier Jun 21, 2024
c9d8006
Add test on mul_sign for non optimized lookup
ConstanceBeguier Jun 22, 2024
06746f7
Remove redundancy in ecc tests
ConstanceBeguier Jun 22, 2024
36e03e3
Add expected_proof_size in test_against_stored_circuit
ConstanceBeguier Jun 23, 2024
5623a78
Fix Merkle tests with optimized lookup
ConstanceBeguier Jun 23, 2024
2c1f636
Rename layout images for circuits with optimized lookup
ConstanceBeguier Jun 23, 2024
ac71097
Remove redundancy in mul_fixed short tests
ConstanceBeguier Jun 24, 2024
61d223e
Move load_with_tag
ConstanceBeguier Jun 24, 2024
b4a70ab
Light modifications on hash_to_point
ConstanceBeguier Jun 24, 2024
a208dca
Add test on mux with non optimized lookup
ConstanceBeguier Jun 24, 2024
fda20b9
Rename some lookup traits and structures
ConstanceBeguier Jun 24, 2024
cd4d43a
Rename Sinsemilla/MerkleChipOptimized
ConstanceBeguier Jun 24, 2024
18e3e0d
Put together some imports
ConstanceBeguier Jun 25, 2024
d6bcf3b
Fix LookupangeCheck loading in Sinsemilla
ConstanceBeguier Jun 25, 2024
b5d8916
Fix Sinsemilla45BChip and Merkle45BChip
ConstanceBeguier Jun 25, 2024
1fbc7de
Rename Sinsemilla/Merkle45BChip
ConstanceBeguier Jun 25, 2024
37e9380
Clean lookup range check tests
ConstanceBeguier Jun 25, 2024
eda965f
Rename some layouter images
ConstanceBeguier Jun 27, 2024
6af9ebf
Update some comments
ConstanceBeguier Jun 27, 2024
2021f5e
Simplify Sinsemilla/Merkle chips thanks to enable_hash_from_private_p…
ConstanceBeguier Jul 1, 2024
0d2512a
Refactoring
ConstanceBeguier Jul 1, 2024
e2c9e93
Refactor
ConstanceBeguier Jul 2, 2024
7f5c0ba
Remove MerkleSinsemillaInstructions
ConstanceBeguier Jul 2, 2024
41c7d2e
Restore code coverage
ConstanceBeguier Jul 5, 2024
9c29f27
Refactor
ConstanceBeguier Jul 5, 2024
714fff0
Remove redundancy in Merkle tests
ConstanceBeguier Jul 7, 2024
70af809
Rename MyCircuit into MyMagnitudeSignCircuit on fixed_mul/short tests
ConstanceBeguier Jul 7, 2024
68d65e0
Refactor
ConstanceBeguier Jul 7, 2024
a8832c9
Make cond_swap_config public in merkle_config
ConstanceBeguier Jul 16, 2024
8a2cbee
Take into account Pablo's review
ConstanceBeguier Jul 17, 2024
03dbe70
Take into account Pablo's review
ConstanceBeguier Aug 2, 2024
a34d146
Some renamings
ConstanceBeguier Aug 2, 2024
9df4fb6
Replace enable_hash_from_private_point by init_from_private_point
ConstanceBeguier Aug 8, 2024
493bf53
Remove unnecessary changes in CI
ConstanceBeguier Aug 8, 2024
46db5d4
Rename Error::HashFromPrivatePoint to Error::IllegalHashFromPrivatePoint
ConstanceBeguier Aug 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 31 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ jobs:
with:
beta-features: ${{ matrix.stage == 'beta' }}
nightly-features: ${{ matrix.stage == 'nightly' }}
- name: Update apt
run: sudo apt-get update
- name: Install cross-platform support dependencies
run: sudo apt install gcc-multilib
run: sudo apt-get install gcc-multilib
ConstanceBeguier marked this conversation as resolved.
Show resolved Hide resolved
- run: rustup target add i686-unknown-linux-gnu
- name: Run tests
run: >
Expand Down Expand Up @@ -125,33 +127,34 @@ jobs:
- name: Test halo2 book
run: mdbook test -L target/debug/deps book/

# codecov:
# name: Code coverage
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v3
# # Use stable for this to ensure that cargo-tarpaulin can be built.
# - id: prepare
# uses: ./.github/actions/prepare
# with:
# toolchain: stable
# nightly-features: true
# - name: Install cargo-tarpaulin
# uses: actions-rs/cargo@v1
# with:
# command: install
# args: cargo-tarpaulin
# - name: Generate coverage report
# uses: actions-rs/cargo@v1
# with:
# command: tarpaulin
# args: >
# ${{ steps.prepare.outputs.feature-flags }}
# --timeout 600
# --out Xml
# - name: Upload coverage to Codecov
# uses: codecov/[email protected]
codecov:
name: Code coverage
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
# Use stable for this to ensure that cargo-tarpaulin can be built.
- id: prepare
uses: ./.github/actions/prepare
with:
toolchain: stable
nightly-features: true
- name: Install cargo-tarpaulin
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-tarpaulin
- name: Generate coverage report
uses: actions-rs/cargo@v1
with:
command: tarpaulin
# Extend the timeout to 3600 to ensure the code coverage test pass
args: >
${{ steps.prepare.outputs.feature-flags }}
--timeout 3600
--out Xml
- name: Upload coverage to Codecov
uses: codecov/[email protected]

doc-links:
name: Intra-doc links
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

97 changes: 74 additions & 23 deletions halo2_gadgets/src/ecc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ impl<C: CurveAffine, EccChip: EccInstructions<C> + Clone + Debug + Eq> Point<C,
point.map(|inner| Point { chip, inner })
}

/// Constructs a new point with the given fixed value.
/// Witnesses the given constant point as a private input to the circuit.
/// This allows the point to be the identity, mapped to (0, 0) in affine coordinates.
pub fn new_from_constant(
chip: EccChip,
mut layouter: impl Layouter<C::Base>,
Expand Down Expand Up @@ -622,14 +623,7 @@ impl<C: CurveAffine, EccChip: EccInstructions<C>> FixedPointShort<C, EccChip> {
pub(crate) mod tests {
use ff::PrimeField;
use group::{prime::PrimeCurveAffine, Curve, Group};

use halo2_proofs::{
circuit::{Layouter, SimpleFloorPlanner, Value},
dev::MockProver,
plonk::{Circuit, ConstraintSystem, Error},
};
use lazy_static::lazy_static;
use pasta_curves::pallas;
use std::marker::PhantomData;

use super::{
chip::{
Expand All @@ -638,7 +632,19 @@ pub(crate) mod tests {
},
FixedPoints,
};
use crate::utilities::lookup_range_check::LookupRangeCheckConfig;
use crate::{
tests::test_utils::test_against_stored_circuit,
utilities::lookup_range_check::{
PallasLookupRangeCheck, PallasLookupRangeCheck4_5BConfig, PallasLookupRangeCheckConfig,
},
};
use halo2_proofs::{
circuit::{Layouter, SimpleFloorPlanner, Value},
dev::MockProver,
plonk::{Circuit, ConstraintSystem, Error},
};
use lazy_static::lazy_static;
use pasta_curves::pallas;

#[derive(Debug, Eq, PartialEq, Clone)]
pub(crate) struct TestFixedBases;
Expand Down Expand Up @@ -766,17 +772,27 @@ pub(crate) mod tests {
type Base = BaseField;
}

struct MyCircuit {
struct EccCircuit<Lookup: PallasLookupRangeCheck> {
test_errors: bool,
_lookup_marker: PhantomData<Lookup>,
}

impl<Lookup: PallasLookupRangeCheck> EccCircuit<Lookup> {
fn new(test_errors: bool) -> Self {
Self {
test_errors,
_lookup_marker: PhantomData,
}
}
}

#[allow(non_snake_case)]
impl Circuit<pallas::Base> for MyCircuit {
type Config = EccConfig<TestFixedBases>;
impl<Lookup: PallasLookupRangeCheck> Circuit<pallas::Base> for EccCircuit<Lookup> {
type Config = EccConfig<TestFixedBases, Lookup>;
type FloorPlanner = SimpleFloorPlanner;

fn without_witnesses(&self) -> Self {
MyCircuit { test_errors: false }
EccCircuit::new(false)
}

fn configure(meta: &mut ConstraintSystem<pallas::Base>) -> Self::Config {
Expand All @@ -793,7 +809,6 @@ pub(crate) mod tests {
meta.advice_column(),
];
let lookup_table = meta.lookup_table_column();
let table_range_check_tag = meta.lookup_table_column();
let lagrange_coeffs = [
meta.fixed_column(),
meta.fixed_column(),
Expand All @@ -808,13 +823,13 @@ pub(crate) mod tests {
let constants = meta.fixed_column();
meta.enable_constant(constants);

let range_check = LookupRangeCheckConfig::configure(
let range_check = Lookup::configure(meta, advices[9], lookup_table);
EccChip::<TestFixedBases, Lookup>::configure(
meta,
advices[9],
lookup_table,
table_range_check_tag,
);
EccChip::<TestFixedBases>::configure(meta, advices, lagrange_coeffs, range_check)
advices,
lagrange_coeffs,
range_check,
)
}

fn synthesize(
Expand Down Expand Up @@ -953,11 +968,17 @@ pub(crate) mod tests {
#[test]
fn ecc_chip() {
let k = 13;
let circuit = MyCircuit { test_errors: true };
let circuit = EccCircuit::<PallasLookupRangeCheckConfig>::new(true);
let prover = MockProver::run(k, &circuit, vec![]).unwrap();
assert_eq!(prover.verify(), Ok(()))
}

#[test]
fn test_ecc_chip_against_stored_circuit() {
let circuit = EccCircuit::<PallasLookupRangeCheckConfig>::new(false);
test_against_stored_circuit(circuit, "ecc_chip", 3872);
}

#[cfg(feature = "test-dev-graph")]
#[test]
fn print_ecc_chip() {
Expand All @@ -967,7 +988,37 @@ pub(crate) mod tests {
root.fill(&WHITE).unwrap();
let root = root.titled("Ecc Chip Layout", ("sans-serif", 60)).unwrap();

let circuit = MyCircuit { test_errors: false };
let circuit = EccCircuit::<PallasLookupRangeCheckConfig>::new(false);
halo2_proofs::dev::CircuitLayout::default()
.render(13, &circuit, &root)
.unwrap();
}

#[test]
fn ecc_chip_4_5b() {
let k = 13;
let circuit = EccCircuit::<PallasLookupRangeCheck4_5BConfig>::new(true);
let prover = MockProver::run(k, &circuit, vec![]).unwrap();

assert_eq!(prover.verify(), Ok(()))
}

#[test]
fn test_against_stored_ecc_chip_4_5b() {
let circuit = EccCircuit::<PallasLookupRangeCheck4_5BConfig>::new(false);
test_against_stored_circuit(circuit, "ecc_chip_4_5b", 3968);
}

#[cfg(feature = "test-dev-graph")]
#[test]
fn print_ecc_chip_4_5b() {
use plotters::prelude::*;

let root = BitMapBackend::new("ecc-chip-4_5b-layout.png", (1024, 7680)).into_drawing_area();
root.fill(&WHITE).unwrap();
let root = root.titled("Ecc Chip Layout", ("sans-serif", 60)).unwrap();

let circuit = EccCircuit::<PallasLookupRangeCheck4_5BConfig>::new(false);
halo2_proofs::dev::CircuitLayout::default()
.render(13, &circuit, &root)
.unwrap();
Expand Down
Loading
Loading