Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
update go and change group membership check
Browse files Browse the repository at this point in the history
Signed-off-by: bytemare <[email protected]>
  • Loading branch information
bytemare committed Oct 1, 2024
1 parent f718815 commit e91a91b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/bytemare/crypto

go 1.22.2
go 1.23.1

require (
filippo.io/edwards25519 v1.1.0
Expand Down
9 changes: 2 additions & 7 deletions internal/nist/element.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ func (e *Element[Point]) Group() byte {
return IdentifierP521
}

panic(
fmt.Sprintf(
"invalid group type, expected *nistec.P256Point/P384Point/P521Point, got %v",
reflect.TypeFor[Point](),
),
)
panic(fmt.Sprintf("invalid point type %v", reflect.TypeFor[Point]()))

Check warning on line 58 in internal/nist/element.go

View check run for this annotation

Codecov / codecov/patch

internal/nist/element.go#L58

Added line #L58 was not covered by tests
}

// Base sets the element to the group's base point a.k.a. canonical generator.
Expand Down Expand Up @@ -89,7 +84,7 @@ func (e *Element[Point]) Double() internal.Element {
return e
}

// negateSmall returns the compressed byte encoding of the negated element e with 5 allocs in 13000 ns/op.
// negateSmall returns the compressed byte encoding of the negated element e with 5 allocations in 13000 ns/op.
func (e *Element[Point]) negateSmall() []byte {
enc := e.p.BytesCompressed()

Expand Down
10 changes: 5 additions & 5 deletions internal/nist/scalar.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ func (s *Scalar) assert(scalar internal.Scalar) *Scalar {

// Group returns the group's Identifier.
func (s *Scalar) Group() byte {
switch s.field.ByteLen() {
case 32:
switch *s.field {
case p256.scalarField:
return IdentifierP256
case 48:
case p384.scalarField:
return IdentifierP384
case 66:
case p521.scalarField:
return IdentifierP521
}

panic("invalid group type, expected nistec.P256Point/P384Point/P521Point")
panic(fmt.Sprintf("invalid field order for scalar %s", s.field.Order().String()))

Check warning on line 62 in internal/nist/scalar.go

View check run for this annotation

Codecov / codecov/patch

internal/nist/scalar.go#L62

Added line #L62 was not covered by tests
}

// Zero sets s to 0, and returns it.
Expand Down

0 comments on commit e91a91b

Please sign in to comment.