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

Add simple curve cycle trait for curve cycles #190

Merged
merged 13 commits into from
Feb 4, 2021

Conversation

drewstone
Copy link
Contributor

@drewstone drewstone commented Jan 30, 2021

Description

The purpose of this PR is to define a trait for standard (potentially non-pairing based) and pairing based curve cycles.

  • Targeted PR against correct branch (master)
  • Linked to Github issue with discussion and accepted design OR have an explanation in the PR that describes this work.
  • Updated relevant documentation in the code
  • Added a relevant changelog entry to the Pending section in CHANGELOG.md

No unit tests as this is just new trait def.

@drewstone
Copy link
Contributor Author

Ngl I just wanna contribute to this awesome project. I am still wearing my training wheels when looking around. Let me know if this isn't the right place or implementation for something like this. I have yet to see a PCD or cycle engine defined for non-pairing based curves so I figured there ought to be one.

@daira
Copy link
Contributor

daira commented Jan 30, 2021

Looks good. Can you impl this for Pallas and Vesta?

@Pratyush
Copy link
Member

This makes me think we need to have a CurveCycle trait, like so:

pub trait CurveCycle 
where
    <Self::E1 as AffineCurve>::Projective: MulAssign<<Self::E2 as AffineCurve>::BaseField>,
    <Self::E2 as AffineCurve>::Projective: MulAssign<<Self::E1 as AffineCurve>::BaseField>,
{
	// Maybe these constraints are too tight and could cause rust's constraint solver
	// error out due to cycles (heh); we remove the
	// bounds on the associated types if that's the case.
	type E1: AffineCurve<
		BaseField = <Self::E2 as AffineCurve>::ScalarField,
		ScalarField = <Self::E2 as AffineCurve>::BaseField,
	>;
	type E2: AffineCurve<
		BaseField = <Self::E1 as AffineCurve>::ScalarField,
		ScalarField = <Self::E1 as AffineCurve>::BaseField,
	>;
}

pub trait PairingFriendlyCycle: CurveCycle {
	// add whatever extra bounds are necessary.
	type Engine1: PairingEngine<
		G1Affine = Self::E1,
		G1Projective = <Self::E1 as AffineCurve>::Projective,
		Fq = <Self::E1 as AffineCurve>::BaseField,
		Fr = <Self::E1 as AffineCurve>::ScalarField,
	>;
	
	type Engine2: PairingEngine<
		G2Affine = Self::E2,
		G2Projective = <Self::E2 as AffineCurve>::Projective,
		Fq = <Self::E2 as AffineCurve>::BaseField,
		Fr = <Self::E2 as AffineCurve>::ScalarField,
	>;
}

@drewstone
Copy link
Contributor Author

drewstone commented Jan 31, 2021

@daira where's the right place to implement that.. should be as simple as this right?

impl SimpleCycleEngine for PastaCycle {
    type E1 = Pallas;
    type E2 = Vesta;
}

And that seems more robust @Pratyush, happy to add that. Ideally any change is backwards compatible but otherwise would require updating the downstream dependencies.

@drewstone
Copy link
Contributor Author

I've updated the trait with your feedback @Pratyush. Getting rid of the strict def on E2 managed to get it to compile without issues. Let me know your thoughts!

ec/src/lib.rs Outdated Show resolved Hide resolved
ec/src/lib.rs Outdated Show resolved Hide resolved
@Pratyush
Copy link
Member

Pratyush commented Feb 4, 2021

Thanks for the PR! could you add a relevant entry in CHANGELOG.md under Improvements? Oh and a final format.

@drewstone
Copy link
Contributor Author

All set @Pratyush

@Pratyush Pratyush changed the title Add simple curve cycle trait for future non-pairing based curve cycles Add simple curve cycle trait for curve cycles Feb 4, 2021
@Pratyush Pratyush merged commit 26707c3 into arkworks-rs:master Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants