Exemple #1
0
func (e *G2) String() string {
	C.g2_make_affine(&e.p)
	c := newConvertContext()
	xa := c.doublesFP2ToInt(new(big.Int), C.g2_x(&e.p), 1)
	xb := c.doublesFP2ToInt(new(big.Int), C.g2_x(&e.p), 0)
	ya := c.doublesFP2ToInt(new(big.Int), C.g2_y(&e.p), 1)
	yb := c.doublesFP2ToInt(new(big.Int), C.g2_y(&e.p), 0)
	return "bn256.G2((" + xa.String() + ", " + xb.String() + "), (" + ya.String() + ", " + yb.String() + "))"
}
Exemple #2
0
func (e *G2) Marshal() []byte {
	out := make([]byte, numBytes*4)
	C.g2_make_affine(&e.p)

	c := newConvertContext()
	c.doublesFP2ToBytes(out, C.g2_x(&e.p))
	c.doublesFP2ToBytes(out[2*numBytes:], C.g2_y(&e.p))

	return out
}