Example #1
0
func (e *G1) String() string {
	C.g1_make_affine(&e.p)
	c := newConvertContext()
	x := c.doublesToInt(new(big.Int), C.g1_x(&e.p))
	y := c.doublesToInt(new(big.Int), C.g1_y(&e.p))
	return "bn256.G1(" + x.String() + ", " + y.String() + ")"
}
Example #2
0
func (e *G1) ScalarMult(base *G1, k *big.Int) *G1 {
	words, bitLen := powerToWords(k)
	if bitLen == 0 {
		C.g1_set(&e.p, &base.p)
	} else {
		C.g1_make_affine(&base.p)
		C.g1_scalar_mult(&e.p, &base.p, (*C.ulonglong)(unsafe.Pointer(&words[0])), C.unsigned(bitLen))
	}
	return e
}
Example #3
0
func (e *G1) Marshal() []byte {
	out := make([]byte, numBytes*2)
	C.g1_make_affine(&e.p)

	c := newConvertContext()
	c.doublesToBytes(out, C.g1_x(&e.p))
	c.doublesToBytes(out[numBytes:], C.g1_y(&e.p))

	return out
}