miracl / core

MIRACL Core
Apache License 2.0
199 stars 68 forks source link

G2mul for ECP? (Golang) #40

Closed mallochine closed 3 years ago

mallochine commented 3 years ago

Hi, so sorry to trouble you again with another question.

It's possible I might have missed something. I frequently make these kinds of mistake when looking at unfamiliar code.

Right now the G2mul function in PAIR.go is for ECP2

I don't think I see a corresponding one for ECP?

This is to implement "Recover" (core/SHARE.go), which is Lagrange interpolation over FP and ECP.

The corresponding source in herumi/bls is: https://github.com/herumi/mcl/blob/0114a3029f74829e79dc51de6dfb28f5da580632/include/mcl/lagrange.hpp#L11 where "F" is FP and "G" is ECP.

mallochine commented 3 years ago

and of course I can share the working version of G2mul if you need me to write the ECP version!

mcarrickscott commented 3 years ago

Hmm. I think its a nomenclature issue. In miracl core G1 is always ECP, and G2 is always ECP2 (or ECP4 or ECP8). That is G1 is always the group defined over the base field, and G2 is always the group defined over the extension field. So in G1 (that is for ECP) G1mul() is the relevant function, and in G2 it is always G2mul().

Note that the share module is completely agnostic as to the source of the secret it is sharing – the secret is always serialised into an array of bytes no matter what its origin (could be BIG,FP, ECP or ECP2).

There is some example code demonstrating the “share” feature in TestMPIN.go

Mike

On Wed, Mar 17, 2021 at 10:43 PM Alex Guo @.***> wrote:

Hi, so sorry to trouble you again with another question.

It's possible I might have missed something. I frequently make these kinds of mistake when looking at unfamiliar code.

Right now the G2mul function in PAIR.go is for ECP2

I don't think I see a corresponding one for ECP?

This is to implement "Recover" (core/SHARE.go), which is Lagrange interpolation over FP and ECP.

The corresponding source in herumi/bls is: https://github.com/herumi/mcl/blob/0114a3029f74829e79dc51de6dfb28f5da580632/include/mcl/lagrange.hpp#L11 where "F" is FP and "G" is ECP.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/miracl/core/issues/40, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAU3ZDXEHQ7RVI7FM7TUPHLTEEWCPANCNFSM4ZLPLR5A .

mallochine commented 3 years ago

oh yeah, D'OH. I did remember seeing that function, somehow I forgot. I'm closing the issue.

yeah I did see that TestMPIN, which is why I initially thought that was the right thing to use.

however I don't think it's the same thing as what herumi/bls is doing. SHARE.go uses "byte" and multiplies it out, while herumi/bls is literally multiplying a FP out.

Source is: https://github.com/herumi/mcl/blob/0114a3029f74829e79dc51de6dfb28f5da580632/include/mcl/lagrange.hpp#L11