Esempio n. 1
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
}
Esempio n. 2
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
}