Skip to content

Commit

Permalink
Remove order method from group.
Browse files Browse the repository at this point in the history
  • Loading branch information
armfazh committed Jan 22, 2024
1 parent 06709e6 commit 0be5e0e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
2 changes: 0 additions & 2 deletions group/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ type Group interface {
Identity() Element
// Creates an element of the group set to the generator of the group.
Generator() Element
// Returns a scalar set to the group order.
Order() Scalar
// RandomElement creates an element chosen at random (using randomness
// from rnd) from the set of group elements. Use crypto/rand.Reader as
// a cryptographically secure random number generator
Expand Down
12 changes: 7 additions & 5 deletions group/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,17 @@ func testCSelect(t *testing.T, testTimes int, g group.Group) {
}

func testOrder(t *testing.T, testTimes int, g group.Group) {
I := g.Identity()
Q := g.NewElement()
order := g.Order()
minusOne := g.NewScalar().SetUint64(1)
minusOne.Neg(minusOne)
for i := 0; i < testTimes; i++ {
P := g.RandomElement(rand.Reader)

Q.Mul(P, order)
got := Q.IsIdentity()
want := true
if got != want {
Q.Mul(P, minusOne)
got := Q.Add(Q, P)
want := I
if !got.IsEqual(want) {
test.ReportError(t, got, want, P)
}
}
Expand Down
10 changes: 0 additions & 10 deletions group/ristretto255.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ func (g ristrettoGroup) Generator() Element {
}
}

func (g ristrettoGroup) Order() Scalar {
q := r255.Scalar{
0x5cf5d3ed, 0x5812631a, 0xa2f79cd6, 0x14def9de,
0x00000000, 0x00000000, 0x00000000, 0x10000000,
}
return &ristrettoScalar{
s: q,
}
}

func (g ristrettoGroup) RandomElement(r io.Reader) Element {
var x r255.Point
x.Rand()
Expand Down
1 change: 0 additions & 1 deletion group/short.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func (g wG) Identity() Element { return g.zeroElement() }
func (g wG) zeroScalar() *wScl { return &wScl{g, make([]byte, (g.c.Params().BitSize+7)/8)} }
func (g wG) zeroElement() *wElt { return &wElt{g, new(big.Int), new(big.Int)} }
func (g wG) Generator() Element { return &wElt{g, g.c.Params().Gx, g.c.Params().Gy} }
func (g wG) Order() Scalar { s := &wScl{g, nil}; s.fromBig(g.c.Params().N); return s }
func (g wG) RandomElement(rd io.Reader) Element {
b := make([]byte, (g.c.Params().BitSize+7)/8)
if n, err := io.ReadFull(rd, b); err != nil || n != len(b) {
Expand Down

0 comments on commit 0be5e0e

Please sign in to comment.