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

Implemented serialization of Fp2, Fp6, Fp12 and Gt #12

Closed
wants to merge 19 commits into from

Conversation

Wassasin
Copy link

Fixes #10, and by proxy #11.

I still have to add a few tests. In expectation of a compressed Gt representation the corresponding methods are called from_uncompressed and to_uncompressed.

Before continuing however I would like to discuss my heavy use of .copy_from_slice. As it stands the hierarchical use of Fq2, Fq6 and Fq12 ensures that lots of bytes are copied around. This is due the inability to split fixed length arrays to smaller fixed length arrays in standard Rust. The only way around this copying with Rust is by either coercing at runtime (i.e. TryInto) or using crates such as arrayref. This crate implements compile-time coercion of fixed-length arrays using unsafe. Given this coercion we hope that LLVM is capable of optimizing the intermediate arrays away. We could also change the function prototype to accept &mut [u8; N] array-references and write into those.

Pending your opinions I prefer to use a crate like arrayref.

@Wassasin Wassasin changed the title Implemented serialization of F2, F6, F12 and Gt Implemented serialization of Fp2, Fp6, Fp12 and Gt Aug 20, 2019
@Wassasin
Copy link
Author

Wassasin commented Sep 5, 2019

Implemented the compressed variant just now; I would love your feedback concerning the array copying.

@Wassasin Wassasin marked this pull request as ready for review October 16, 2019 07:53
@str4d str4d requested a review from ebfull November 12, 2019 09:26
src/pairings.rs Outdated Show resolved Hide resolved
src/fp6.rs Outdated Show resolved Hide resolved
src/fp6.rs Outdated Show resolved Hide resolved
src/fp2.rs Outdated Show resolved Hide resolved
src/fp12.rs Outdated Show resolved Hide resolved
@ebfull
Copy link
Contributor

ebfull commented Nov 13, 2019

Hi there,

Apologies for the late review, my github notifications are a mess.

I'm a little wary of including Gt serialization in this library until it has been standardized to avoid stepping on other people's toes. Do you know of any concurrent work in this area?

@Wassasin
Copy link
Author

As far as I know using the byte representation of Gt::c1 (y) is the way to go for compressed serialization. I have yet to see another implementation providing this.

@ebfull
Copy link
Contributor

ebfull commented Nov 24, 2019

The outstanding question for me is whether people will be happy with an encoding based on the tower. Maybe in a standards process they'll want to encode it using a 12-th degree extension instead? I don't know...

@bwesterb
Copy link

bwesterb commented Apr 9, 2020

For an even prime power and odd characteristic, there is no way to make a choice of square independent of construction. I've written down a proof here.

@ebfull ebfull closed this Sep 8, 2020
@Wassasin
Copy link
Author

Wassasin commented Sep 9, 2020

Disappointing.

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.

Implement serialization / deserialization of Gt
3 participants