herumi / bls

288 stars 132 forks source link

Issue with deserializing public key and signature #101

Closed domwoe closed 1 year ago

domwoe commented 1 year ago

we are trying to verify a BLS signature from the Internet Computer with herumi/bls using the C# and JS/WASM wrappers. See the links for example projects/tests.

However, deserialization of the public key and signature fails.

In the code of a Rust verification library to verify BLS signatures from the Internet Computer, there's the following comment:

/// The signature must be exactly 48 bytes (compressed G1 element)
/// The key must be exactly 96 bytes (compressed G2 element)

Is there any way to verify these signatures with herumi?

herumi commented 1 year ago

Sorry for the late response. You call blsSetETHserialization(1); once after calling blsInit.

herumi commented 1 year ago

And you may have to call mclBnG1_setDst.

herumi commented 1 year ago

mclBnG1_setDst is not provided for C#/WASM, so I'll append it later. What generator ofG2 is?

herumi commented 1 year ago

It works when initialized as follows. https://github.com/herumi/bls/commit/57b8da02bfc7883f5f09c7dea6c39dd55e55e234

domwoe commented 1 year ago

Thanks a lot, @herumi. Do you know if the C# and Go wrappers provide everything that is needed?

herumi commented 1 year ago

Now I've added a sample for C#. https://github.com/herumi/bls/commit/88defaabc6eb471b933b67af091dd2834541e097

herumi commented 1 year ago

I've added a sample for Go. https://github.com/herumi/bls-go-binary/commit/d496a2684849e627d4f1c0a0a138159c1ac30ac0

herumi commented 1 year ago

The Wasm version.

Gekctek commented 1 year ago

Thank you! I have been working with @domwoe and I have confirmed that this solution works

domwoe commented 1 year ago

Thank you a lot @herumi!