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

elliptic-curve: patterns for wrapping fiat-crypto-provided field implementations #1017

Closed
tarcieri opened this issue May 30, 2022 · 1 comment · Fixed by #1021
Closed

elliptic-curve: patterns for wrapping fiat-crypto-provided field implementations #1017

tarcieri opened this issue May 30, 2022 · 1 comment · Fixed by #1021

Comments

@tarcieri
Copy link
Member

tarcieri commented May 30, 2022

The p384 crate is using base field and scalar field implementations from the fiat-crypto project, which synthesizes formally verified field implementations in multiple languages.

It would probably make sense to use their field implementations in p256 as well, which could enable a proper 32-bit backend which is currently missing (the existing field implementation is based on 64-bit limbs only).

Given that, it would make sense to add something to the elliptic-curve crate, be it a trait or a macro, that provides a convention for consuming fiat-crypto field implementations for both (base) FieldElement and Scalar types.

I don't think this requires any direct integration with fiat-crypto, and currently we can't make use of the fiat-crypto crate itself because it doesn't yet contain the generated code for scalar fields and we might want to postprocess the output to enable const fn usage.

Instead we could have a trait "shaped" like the generated field implementations, or a macro which accepts a list of the fiat-crypto-provided function names as arguments, and use a little bit of boilerplate to wire things up using plain old Rust code (i.e. nothing more than functions which operate over arrays of word-sized integers).

@tarcieri
Copy link
Member Author

tarcieri commented Jun 1, 2022

This PR adds a impl_sec1_field_element! macro for this purpose, presently used inside the p384 crate to DRY out the implementations of FieldElement and Scalar:

RustCrypto/elliptic-curves#586

tarcieri added a commit that referenced this issue Jun 10, 2022
Extracts the macro of the same name from the `p384` crate so it can be
used with other elliptic curve crates.

Closes #1017.
tarcieri added a commit that referenced this issue Jun 10, 2022
Extracts the macro of the same name from the `p384` crate so it can be
used with other elliptic curve crates.

Closes #1017.
tarcieri added a commit that referenced this issue Jun 10, 2022
Extracts the macro of the same name from the `p384` crate so it can be
used with other elliptic curve crates.

Closes #1017.
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 a pull request may close this issue.

1 participant