Skip to content

Commit 0be5e0e

Browse files
committed
Remove order method from group.
1 parent 06709e6 commit 0be5e0e

File tree

4 files changed

+7
-18
lines changed

4 files changed

+7
-18
lines changed

group/group.go

-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ type Group interface {
2626
Identity() Element
2727
// Creates an element of the group set to the generator of the group.
2828
Generator() Element
29-
// Returns a scalar set to the group order.
30-
Order() Scalar
3129
// RandomElement creates an element chosen at random (using randomness
3230
// from rnd) from the set of group elements. Use crypto/rand.Reader as
3331
// a cryptographically secure random number generator

group/group_test.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,17 @@ func testCSelect(t *testing.T, testTimes int, g group.Group) {
164164
}
165165

166166
func testOrder(t *testing.T, testTimes int, g group.Group) {
167+
I := g.Identity()
167168
Q := g.NewElement()
168-
order := g.Order()
169+
minusOne := g.NewScalar().SetUint64(1)
170+
minusOne.Neg(minusOne)
169171
for i := 0; i < testTimes; i++ {
170172
P := g.RandomElement(rand.Reader)
171173

172-
Q.Mul(P, order)
173-
got := Q.IsIdentity()
174-
want := true
175-
if got != want {
174+
Q.Mul(P, minusOne)
175+
got := Q.Add(Q, P)
176+
want := I
177+
if !got.IsEqual(want) {
176178
test.ReportError(t, got, want, P)
177179
}
178180
}

group/ristretto255.go

-10
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,6 @@ func (g ristrettoGroup) Generator() Element {
5959
}
6060
}
6161

62-
func (g ristrettoGroup) Order() Scalar {
63-
q := r255.Scalar{
64-
0x5cf5d3ed, 0x5812631a, 0xa2f79cd6, 0x14def9de,
65-
0x00000000, 0x00000000, 0x00000000, 0x10000000,
66-
}
67-
return &ristrettoScalar{
68-
s: q,
69-
}
70-
}
71-
7262
func (g ristrettoGroup) RandomElement(r io.Reader) Element {
7363
var x r255.Point
7464
x.Rand()

group/short.go

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func (g wG) Identity() Element { return g.zeroElement() }
3434
func (g wG) zeroScalar() *wScl { return &wScl{g, make([]byte, (g.c.Params().BitSize+7)/8)} }
3535
func (g wG) zeroElement() *wElt { return &wElt{g, new(big.Int), new(big.Int)} }
3636
func (g wG) Generator() Element { return &wElt{g, g.c.Params().Gx, g.c.Params().Gy} }
37-
func (g wG) Order() Scalar { s := &wScl{g, nil}; s.fromBig(g.c.Params().N); return s }
3837
func (g wG) RandomElement(rd io.Reader) Element {
3938
b := make([]byte, (g.c.Params().BitSize+7)/8)
4039
if n, err := io.ReadFull(rd, b); err != nil || n != len(b) {

0 commit comments

Comments
 (0)