예제 #1
0
파일: curve.go 프로젝트: LegoShrimp/crypto
func (p *point) Mul(ca abstract.Point, cs abstract.Scalar) abstract.Point {

	// Convert the scalar to fixed-length little-endian form.
	sb := cs.(*nist.Int).V.Bytes()
	shi := len(sb) - 1
	var b [32]byte
	for i := range sb {
		b[shi-i] = sb[i]
	}

	if ca == nil {
		// Optimized multiplication by precomputed base point
		C.ge_scalarmult_base(&p.p, (*C.uchar)(unsafe.Pointer(&b[0])))
	} else {
		// General scalar multiplication
		a := ca.(*point)
		C.ge_scalarmult(&p.p, (*C.uchar)(unsafe.Pointer(&b[0])), &a.p)
	}
	return p
}
예제 #2
0
파일: curve.go 프로젝트: LegoShrimp/crypto
func (p *point) Base() abstract.Point {

	// Way to kill a fly with a sledgehammer...
	C.ge_scalarmult_base(&p.p, (*C.uchar)(unsafe.Pointer(&s1.b[0])))
	return p
}