mirror of https://github.com/gtank/ristretto255
ristretto255: add NewElement and NewScalar
This commit is contained in:
parent
013999a2d0
commit
2f2f1c0111
|
@ -36,13 +36,15 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Element is an element of the ristretto255 prime-order group.
|
// 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 {
|
type Element struct {
|
||||||
r edwards25519.ProjP3
|
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.
|
// Equal returns 1 if e is equivalent to ee, and 0 otherwise.
|
||||||
//
|
//
|
||||||
// Note that Elements must not be compared in any other way.
|
// Note that Elements must not be compared in any other way.
|
||||||
|
|
|
@ -16,6 +16,11 @@ type Scalar struct {
|
||||||
s scalar.Scalar
|
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.
|
// Add sets s = x + y mod l and returns s.
|
||||||
func (s *Scalar) Add(x, y *Scalar) *Scalar {
|
func (s *Scalar) Add(x, y *Scalar) *Scalar {
|
||||||
s.s.Add(&x.s, &y.s)
|
s.s.Add(&x.s, &y.s)
|
||||||
|
|
Loading…
Reference in New Issue