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

Convert Signature and Public key into G1 and G2 format. #119

Open
wdcs-amitkumar opened this issue Jan 7, 2022 · 10 comments
Open

Convert Signature and Public key into G1 and G2 format. #119

wdcs-amitkumar opened this issue Jan 7, 2022 · 10 comments
Labels
enhancement New feature or request

Comments

@wdcs-amitkumar
Copy link

Hi Team !!
Thanks you bls-dkg to provide such a complex implemetation in rust.

I would like to request if it is possible to convert public key and signature into G1 and G2 format.
So that I can verify dkg-bls signature in the ethereum smart contract.

Currently I tried to input those PK and SIG in python ECC library
Line 40 , 51

but it produces G1 and G2 of length 115 but this smart contract Line 38 verifyBLSTest()

accepts G1 G2 value of length 77.

In short do any way to get G1 G2 values in for required length ??

@wdcs-amitkumar wdcs-amitkumar added the enhancement New feature or request label Jan 7, 2022
@wdcs-amitkumar
Copy link
Author

Meanwhile I tried to convert public key and signature into G1 and G2 and found that
They are producing output of different length.

Screenshot from 2022-01-10 02-27-34

image

@wdcs-amitkumar
Copy link
Author

BLS_VERIFY_ETH.pdf

Just for reference of Signature I generated from BLS DKG rust and Python

@maqi
Copy link
Member

maqi commented Jan 10, 2022

Hi, @AmitCZ,

Thank you for the comment.

First, regarding the table of PK/Sig length you attached above, I think for bls_dkg, it shall be 192 for the PK and 384 for the Sig ?

Second, the format of PK/Sig that bls_dkg using is from threshold_crypto .
In that crate, you can define the length of PK/Sig by changing the value of PK_SIZE and SIG_SIZE.
That crate has test using mock PK/Sig type by change the PK_SIZE and SIG_SIZE to 4.
I am not sure whether the bls_dkg can support a changed PK_SZIE/SIG_SIZE directly, worth to have a try.

Hope this helps.
Cheers,

@davidrusu
Copy link
Contributor

Just to add some notes here,

@AmitCZ there are a few different representations of G1/G2 points and there's a distinction between PublicKeySets and PublicKeys that you may missing.

G1/G1 can be in compressed or affine forms (or projective, but this is rarely serialized), these sizes are in the table below

             | G1 |  G2 |
-------------------------
| compressed | 48 |  96 |
| affine     | 96 | 192 |

Make sure you are converting your G1/G2 points into the representation your function expects.

Second, you may be confusing the PublicKeySet for the PublicKey. make sure to call public_key()

BLS-DKG exposes the compressed G1/G2 points, by calling to_bytes() on the PublicKey / PublicKeyShare / Signature / SignatureShare

This compressed representation should be parse-able by other BLS libraries and from that you can convert to Affine if necessary.

@wdcs-amitkumar
Copy link
Author

Hi, @AmitCZ,

Thank you for the comment.

First, regarding the table of PK/Sig length you attached above, I think for bls_dkg, it shall be 192 for the PK and 384 for the Sig ?

Second, the format of PK/Sig that bls_dkg using is from threshold_crypto . In that crate, you can define the length of PK/Sig by changing the value of PK_SIZE and SIG_SIZE. That crate has test using mock PK/Sig type by change the PK_SIZE and SIG_SIZE to 4. I am not sure whether the bls_dkg can support a changed PK_SZIE/SIG_SIZE directly, worth to have a try.

Hope this helps. Cheers,

fn threshold_signature() -> Result<()> {

This line prints public key : 384 characters and Signature : 192 characters
What encoding has been used ??

@wdcs-amitkumar
Copy link
Author

wdcs-amitkumar commented Jan 10, 2022

Hi Team Maidsafe!!

Thank you for your efforts, I am able to get Affine values for my public key and signature.
Here is the code with changes :

Screenshot from 2022-01-11 02-15-08

One last help I need
How can i convert those hex affine values into big int that following contract can take as input

Line 42 : bls-verifier-contract

Again very much thankful for all your support.
Waiting for response :)

@davidrusu
Copy link
Contributor

I don't think we can help you much with your contract, but those numbers are hex encoded, if you want the decimal representation, you can simply re-encode as decimal

@wdcs-amitkumar
Copy link
Author

Hi @davidrusu

I tried to convert public key points , it is giving 115 character numbers,
But smart contract (since it supports max uin256 size) only takes 77 character number as input.

Still hopeful

It it possible to get 77 character long public key from your repo.

Appreciated if provided with code snippet.
Thanks :)

@davidrusu
Copy link
Contributor

PublicKeys are always 48 bytes when compressed and 96 bytes in Affine.

it is giving 115 character numbers,

I'm not sure what a "character" is, but you should be counting in bytes, not characters.

@maqi
Copy link
Member

maqi commented Jan 12, 2022

It it possible to get 77 character long public key from your repo.

You may try with the threshold_crypto repo to refactor the PK_SIZE and SIG_SIZE to what you want.
However, this may comes with cost of reduced security.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants