Skip to content

Commit c8971c0

Browse files
committed
Adds a method to retrieve the group.
1 parent 033f07b commit c8971c0

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

group/group.go

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type Group interface {
3131

3232
// Element represents an abstract element of a prime-order group.
3333
type Element interface {
34+
Group() Group
3435
Set(Element) Element
3536
Copy() Element
3637
IsIdentity() bool
@@ -47,6 +48,7 @@ type Element interface {
4748

4849
// Scalar represents an integer scalar.
4950
type Scalar interface {
51+
Group() Group
5052
Set(Scalar) Scalar
5153
Copy() Scalar
5254
IsEqual(Scalar) bool

group/ristretto255.go

+3
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ func (g ristrettoGroup) HashToScalar(msg, dst []byte) Scalar {
126126
return s
127127
}
128128

129+
func (e *ristrettoElement) Group() Group { return Ristretto255 }
130+
129131
func (e *ristrettoElement) IsIdentity() bool {
130132
var zero r255.Point
131133
zero.SetZero()
@@ -181,6 +183,7 @@ func (e *ristrettoElement) UnmarshalBinary(data []byte) error {
181183
return e.p.UnmarshalBinary(data)
182184
}
183185

186+
func (s *ristrettoScalar) Group() Group { return Ristretto255 }
184187
func (s *ristrettoScalar) String() string { return fmt.Sprintf("0x%x", s.s.Bytes()) }
185188
func (s *ristrettoScalar) SetUint64(n uint64) { s.s.SetUint64(n) }
186189

group/short.go

+2
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ type wElt struct {
125125
x, y *big.Int
126126
}
127127

128+
func (e *wElt) Group() Group { return e.wG }
128129
func (e *wElt) String() string { return fmt.Sprintf("x: 0x%v\ny: 0x%v", e.x.Text(16), e.y.Text(16)) }
129130
func (e *wElt) IsIdentity() bool { return e.x.Sign() == 0 && e.y.Sign() == 0 }
130131
func (e *wElt) IsEqual(o Element) bool {
@@ -219,6 +220,7 @@ type wScl struct {
219220
k []byte
220221
}
221222

223+
func (s *wScl) Group() Group { return s.wG }
222224
func (s *wScl) String() string { return fmt.Sprintf("0x%x", s.k) }
223225
func (s *wScl) SetUint64(n uint64) { s.fromBig(new(big.Int).SetUint64(n)) }
224226
func (s *wScl) IsEqual(a Scalar) bool {

0 commit comments

Comments
 (0)