Exemplo n.º 1
0
func (p *point) Base() abstract.Point {
	genp := C.EC_GROUP_get0_generator(p.c.g)
	if genp == nil {
		panic("EC_GROUP_get0_generator: " + getErrString())
	}
	if C.EC_POINT_copy(p.p, genp) == 0 {
		panic("EC_POINT_copy: " + getErrString())
	}
	return p
}
Exemplo n.º 2
0
func (p *point) Neg(ca abstract.Point) abstract.Point {
	if ca != p {
		a := ca.(*point)
		if C.EC_POINT_copy(p.p, a.p) == 0 {
			panic("EC_POINT_copy: " + getErrString())
		}
	}
	if C.EC_POINT_invert(p.c.g, p.p, p.c.ctx) == 0 {
		panic("EC_POINT_invert: " + getErrString())
	}
	return p
}
Exemplo n.º 3
0
func (p *point) Sub(ca, cb abstract.Point) abstract.Point {
	a := ca.(*point)
	b := cb.(*point)
	// Add the point inverse.  Must use temporary if p == a.
	t := p
	if p == a {
		t = newPoint(p.c)
	}
	if C.EC_POINT_copy(t.p, b.p) == 0 {
		panic("EC_POINT_copy: " + getErrString())
	}
	if C.EC_POINT_invert(p.c.g, t.p, p.c.ctx) == 0 {
		panic("EC_POINT_invert: " + getErrString())
	}
	if C.EC_POINT_add(p.c.g, p.p, a.p, t.p, p.c.ctx) == 0 {
		panic("EC_POINT_add: " + getErrString())
	}
	return p
}