ristretto255: add NewElement and NewScalar

This commit is contained in:
Filippo Valsorda 2019-05-15 14:26:17 -04:00
parent 013999a2d0
commit 2f2f1c0111
2 changed files with 10 additions and 3 deletions

View File

@ -36,13 +36,15 @@ var (
)
// Element is an element of the ristretto255 prime-order group.
//
// The zero value of Element is not valid, but can be used as the receiver for
// any setting operation.
type Element struct {
r edwards25519.ProjP3
}
// NewElement returns a new Element set to the identity value.
func NewElement() *Element {
return (&Element{}).Zero()
}
// Equal returns 1 if e is equivalent to ee, and 0 otherwise.
//
// Note that Elements must not be compared in any other way.

View File

@ -16,6 +16,11 @@ type Scalar struct {
s scalar.Scalar
}
// NewScalar returns a Scalar set to the value 0.
func NewScalar() *Scalar {
return (&Scalar{}).Zero()
}
// Add sets s = x + y mod l and returns s.
func (s *Scalar) Add(x, y *Scalar) *Scalar {
s.s.Add(&x.s, &y.s)