[go] public member of G1/G2

update-fork
MITSUNARI Shigeo 5 years ago
parent 92681e984e
commit 26c565176d
  1. 53
      ffi/go/mcl/mcl.go

@ -19,18 +19,24 @@ const CurveFp382_1 = C.mclBn_CurveFp382_1
// CurveFp382_2 -- 382 bit curve 2 // CurveFp382_2 -- 382 bit curve 2
const CurveFp382_2 = C.mclBn_CurveFp382_2 const CurveFp382_2 = C.mclBn_CurveFp382_2
// BLS12_381 // BLS12_381 --
const BLS12_381 = C.MCL_BLS12_381 const BLS12_381 = C.MCL_BLS12_381
// IoSerializeHexStr // IoSerializeHexStr --
const IoSerializeHexStr = C.MCLBN_IO_SERIALIZE_HEX_STR const IoSerializeHexStr = C.MCLBN_IO_SERIALIZE_HEX_STR
// GetFrUnitSize() -- // IO_EC_AFFINE --
const IO_EC_AFFINE = C.MCLBN_IO_EC_AFFINE
// IO_EC_PROJ --
const IO_EC_PROJ = C.MCLBN_IO_EC_PROJ
// GetFrUnitSize --
func GetFrUnitSize() int { func GetFrUnitSize() int {
return int(C.MCLBN_FR_UNIT_SIZE) return int(C.MCLBN_FR_UNIT_SIZE)
} }
// GetFpUnitSize() -- // GetFpUnitSize --
// same as GetMaxOpUnitSize() // same as GetMaxOpUnitSize()
func GetFpUnitSize() int { func GetFpUnitSize() int {
return int(C.MCLBN_FP_UNIT_SIZE) return int(C.MCLBN_FP_UNIT_SIZE)
@ -71,6 +77,18 @@ func GetFieldOrder() string {
return string(buf[:n]) return string(buf[:n])
} }
// SetETHserialization --
func SetETHserialization(enable bool) {
var v C.int
if enable {
v = 1
} else {
v = 0
}
// #nosec
C.mclBn_setETHserialization(v)
}
// Fr -- // Fr --
type Fr struct { type Fr struct {
v C.mclBnFr v C.mclBnFr
@ -411,10 +429,11 @@ func FpSquareRoot(out *Fp, x *Fp) bool {
return C.mclBnFp_squareRoot(out.getPointer(), x.getPointer()) == 0 return C.mclBnFp_squareRoot(out.getPointer(), x.getPointer()) == 0
} }
// Fp2 -- // Fp2 -- x = D[0] + D[1] i where i^2 = -1
type Fp2 struct { type Fp2 struct {
d [2]Fp D [2]Fp
} }
// getPointer -- // getPointer --
func (x *Fp2) getPointer() (p *C.mclBnFp2) { func (x *Fp2) getPointer() (p *C.mclBnFp2) {
// #nosec // #nosec
@ -505,9 +524,9 @@ func Fp2SquareRoot(out *Fp2, x *Fp2) bool {
// G1 -- // G1 --
type G1 struct { type G1 struct {
x Fp X Fp
y Fp Y Fp
z Fp Z Fp
} }
// getPointer -- // getPointer --
@ -590,6 +609,11 @@ func (x *G1) Serialize() []byte {
return buf[:n] return buf[:n]
} }
// G1Normalize --
func G1Normalize(out *G1, x *G1) {
C.mclBnG1_normalize(out.getPointer(), x.getPointer())
}
// G1Neg -- // G1Neg --
func G1Neg(out *G1, x *G1) { func G1Neg(out *G1, x *G1) {
C.mclBnG1_neg(out.getPointer(), x.getPointer()) C.mclBnG1_neg(out.getPointer(), x.getPointer())
@ -630,9 +654,9 @@ func G1MulCT(out *G1, x *G1, y *Fr) {
// G2 -- // G2 --
type G2 struct { type G2 struct {
x Fp2 X Fp2
y Fp2 Y Fp2
z Fp2 Z Fp2
} }
// getPointer -- // getPointer --
@ -715,6 +739,11 @@ func (x *G2) Serialize() []byte {
return buf[:n] return buf[:n]
} }
// G2Normalize --
func G2Normalize(out *G2, x *G2) {
C.mclBnG2_normalize(out.getPointer(), x.getPointer())
}
// G2Neg -- // G2Neg --
func G2Neg(out *G2, x *G2) { func G2Neg(out *G2, x *G2) {
C.mclBnG2_neg(out.getPointer(), x.getPointer()) C.mclBnG2_neg(out.getPointer(), x.getPointer())

Loading…
Cancel
Save