示例#1
0
文件: bn256.go 项目: carriercomm/pond
func (e *GT) String() string {
	c := newConvertContext()
	a := c.doublesFP2ToInt(new(big.Int), C.gt_aa(&e.p), 1).String()
	b := c.doublesFP2ToInt(new(big.Int), C.gt_aa(&e.p), 0).String()
	cc := c.doublesFP2ToInt(new(big.Int), C.gt_ab(&e.p), 1).String()
	d := c.doublesFP2ToInt(new(big.Int), C.gt_ab(&e.p), 0).String()
	ee := c.doublesFP2ToInt(new(big.Int), C.gt_ac(&e.p), 1).String()
	f := c.doublesFP2ToInt(new(big.Int), C.gt_ac(&e.p), 0).String()
	g := c.doublesFP2ToInt(new(big.Int), C.gt_ba(&e.p), 1).String()
	h := c.doublesFP2ToInt(new(big.Int), C.gt_ba(&e.p), 0).String()
	i := c.doublesFP2ToInt(new(big.Int), C.gt_bb(&e.p), 1).String()
	j := c.doublesFP2ToInt(new(big.Int), C.gt_bb(&e.p), 0).String()
	k := c.doublesFP2ToInt(new(big.Int), C.gt_bc(&e.p), 1).String()
	l := c.doublesFP2ToInt(new(big.Int), C.gt_bc(&e.p), 0).String()

	return "GF12(" + strings.Join([]string{a, b, cc, d, ee, f, g, h, i, j, k, l}, ",") + ")"
}
示例#2
0
文件: bn256.go 项目: carriercomm/pond
func (e *GT) Marshal() []byte {
	out := make([]byte, numBytes*12)

	c := newConvertContext()
	c.doublesFP2ToBytes(out[0*numBytes:], C.gt_aa(&e.p))
	c.doublesFP2ToBytes(out[2*numBytes:], C.gt_ab(&e.p))
	c.doublesFP2ToBytes(out[4*numBytes:], C.gt_ac(&e.p))
	c.doublesFP2ToBytes(out[6*numBytes:], C.gt_ba(&e.p))
	c.doublesFP2ToBytes(out[8*numBytes:], C.gt_bb(&e.p))
	c.doublesFP2ToBytes(out[10*numBytes:], C.gt_bc(&e.p))

	return out
}