Skip to content
This repository has been archived by the owner on Dec 9, 2021. It is now read-only.

Implement support for the Pasta curves #100

Merged
merged 1 commit into from
Feb 17, 2021
Merged

Conversation

unzvfu
Copy link
Collaborator

@unzvfu unzvfu commented Feb 14, 2021

This PR implements support for the Pasta curve pair which provide some benefits over the Tweedle* curve pair.

This PR does not attempt to implement any of the performance improvements mentioned in the aforementioned reference; the benefits such are likely to be fairly modest.

Most of the work was just converting the published constants into Montgomery form and pasting them into the right slots. This means that there is some additional duplication with the other field and curve implementations; this will be refactored in due course. The only exception to this was the choice of the ZETA and ZETA_SCALAR parameters which are not mandated by the Pasta curves, just their properties; so a choice was made and set in the implementation.

@unzvfu unzvfu requested a review from dlubarov February 14, 2021 10:22
@unzvfu unzvfu self-assigned this Feb 14, 2021
Copy link
Member

@dlubarov dlubarov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good!

I had forgotten how much work it was to work out all the constants and stuff. It would be nice if we could compute most of them at compile time, but I think it's tricky in Rust since compile time computations are so limited, e.g. we can't allocate BigUInts.

We should probably unify the tests at some point (a la test_arithmetic), but I can do that afterward.

@unzvfu
Copy link
Collaborator Author

unzvfu commented Feb 17, 2021

Thanks, looks good!

Thanks. :)

I had forgotten how much work it was to work out all the constants and stuff. It would be nice if we could compute most of them at compile time, but I think it's tricky in Rust since compile time computations are so limited, e.g. we can't allocate BigUInts.

Yes, I gave this some thought since it proved quite error-prone to work out which values needed to be converted to Montgomery form and which didn't, and to do the Montgomery calculation "manually" for each value and copy it across. I think it's probably possible to make Montgomery multiplication a const fn and get most of the functionality we'd want, but I'm not sure it's worth it at this stage, since you can't even use for in a const fn (tail recursion only).

We should probably unify the tests at some point (a la test_arithmetic), but I can do that afterward.

Agreed. I'm also happy to do the refactoring; I guess we'll see who gets there first. :)

@unzvfu unzvfu merged commit 424d903 into master Feb 17, 2021
@unzvfu unzvfu deleted the issue-99-pasta-curves branch February 17, 2021 09:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants