herumi / mcl

a portable and fast pairing-based cryptography library
BSD 3-Clause "New" or "Revised" License
450 stars 151 forks source link

add G1GetBasePoint in golang api #170

Closed levyfan closed 1 year ago

levyfan commented 1 year ago

Hi @herumi , I add the G1GetBasePoint api to golang. Please let me known if this is OK.

herumi commented 1 year ago

This API is useful for only SECP* curve. Is it okay?

levyfan commented 1 year ago

I see. I need a base point for BN254.

herumi commented 1 year ago

I don't think that the base point of BN254 is defined. If you want to set it as a point (x, y), then use setStr(P, "1 <x> <y>", 10). https://github.com/herumi/mcl/blob/master/api.md#set-string

levyfan commented 1 year ago

As the curve is Y²=X³+3, I guess we can just set X=1 and Y=2? https://github.com/ConsenSys/gnark-crypto/blob/7fcb6a36443a7c998756e3910d0d99aeb37d0213/ecc/bn254/bn254.go#L108

herumi commented 1 year ago

Yes. You can useg1Gen.SetString("1 1 2", 10). The first 1 means Affine format string.

levyfan commented 1 year ago

All right, they are 2 different curves. I can use the G here https://neuromancer.sk/std/other/Fp254BNb.

BN254 -> alt_bn_128(Y²=X³+3) https://github.com/ConsenSys/gnark-crypto/tree/master/ecc/bn254 BN254 -> Fp254BNb(Y²=X³+2) https://neuromancer.sk/std/other/Fp254BNb

There is an article about it https://hackmd.io/@jpw/bn254

herumi commented 1 year ago

How about MCL_BN_SNARK1?

levyfan commented 1 year ago

ok get that~