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

Get access to the Fp12 representation from Gt #96

Open
abizjak opened this issue Oct 24, 2022 · 5 comments
Open

Get access to the Fp12 representation from Gt #96

abizjak opened this issue Oct 24, 2022 · 5 comments

Comments

@abizjak
Copy link

abizjak commented Oct 24, 2022

The https://docs.rs/bls12_381/0.7.0/bls12_381/struct.Gt.html has very little functionality exposed at the moment.
It implements the Group trait and a few helpers, however this is not enough for one of the ZK protocols we have.

What would suffice for us is a way to get the underlying Fp12 representation of Gt. For example,

impl AsRef<Fp12> for Gt {
   ...
}

would be perfectly adequate, or any other alternative you would prefer.

Is this something you are open to adding to the library? Without this we cannot upgrade from the old pairing crate that embedded the bls implementation to the recent one.

This is related to #10 although I need less than that.

@str4d
Copy link
Member

str4d commented Dec 6, 2022

It implements the Group trait and a few helpers, however this is not enough for one of the ZK protocols we have.

What functionality do you need? I'm generally reluctant to expose the underlying Fp12 representation, as it affects the type safety of this crate (which is something that we specifically had in mind when improving the APIs of this crate over the old pairing crate impl). I'm more inclined to first see whether the functionality you require can be exposed in some other way.

@abizjak
Copy link
Author

abizjak commented Dec 12, 2022

The only thing we need is that we can serialize the value in a specific way.

        // coefficients in the extension F_6
        let c0_6 = self.c0;
        let c1_6 = self.c1;

        let coeffs = [
            // coefficients of c1_6 in the extension F_2
            c1_6.c2, c1_6.c1, c1_6.c0, // coefficients of c0_6 in the extension F_2
            c0_6.c2, c0_6.c1, c0_6.c0,
        ];
        for p in coeffs.iter() {
            let repr_c1 = FqRepr::from(p.c1);
            let repr_c0 = FqRepr::from(p.c0);
            for d in repr_c1.as_ref().iter() {
                d.serial(out);
            }
            for d in repr_c0.as_ref().iter() {
                d.serial(out);
            }
        }
    }

We could actually work around this and shuffle some other things around I think so we maybe wouldn't have to do this, but we cannot change the protocol we have now without massive migration pain, so we have to stick with the exact format we have at the moment.

@abizjak
Copy link
Author

abizjak commented Dec 12, 2022

I do sympathize with wanting to have as type-safe API as possible :)

@randombit
Copy link

Is there any way to make progress on this? I'm running into the same problem while trying to implement an IBE scheme where we need to hash elements of Gt; any (stable over time) serialization would be fine, no deserialization required.

@abizjak
Copy link
Author

abizjak commented Aug 1, 2023

@str4d is there any way to make progress on this? Would you accept a PR where this was exposed conditionally based on a feature that is off by default and documented as unstable/unsafe?

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

No branches or pull requests

3 participants