Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use int instead of uint #32

Merged
merged 3 commits into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ type Group interface {
HashToGroup(input, dst []byte) Element
EncodeToGroup(input, dst []byte) Element
Ciphersuite() string
ScalarLength() uint
ElementLength() uint
ScalarLength() int
ElementLength() int
Order() string
}
```
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ require (

require (
github.com/bytemare/hash v0.1.3 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/sys v0.5.0 // indirect
)
14 changes: 4 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek=
filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
filippo.io/nistec v0.0.0-20220513155737-c4b6d02e738c h1:x4epP2lA8b5UYoIFjcVpN+MfJQeX5M5Yilmc1VH0YDw=
filippo.io/nistec v0.0.0-20220513155737-c4b6d02e738c/go.mod h1:84fxC9mi+MhC2AERXI4LSa8cmSVOzrFikg6hZ4IfCyw=
filippo.io/nistec v0.0.0-20220825075812-a82cab4ea6f0 h1:infQBtlEPAdRCqMIoddLS8K27zaaz05FLnrXskk0TtE=
filippo.io/nistec v0.0.0-20220825075812-a82cab4ea6f0/go.mod h1:84fxC9mi+MhC2AERXI4LSa8cmSVOzrFikg6hZ4IfCyw=
github.com/bytemare/hash v0.1.3 h1:E2v/+gqvLTjaR8W2JdhqaB2L9161yFBlSXDnYEyMt94=
Expand All @@ -10,11 +8,7 @@ github.com/bytemare/hash2curve v0.1.2 h1:V/TSdU/WsfYS3Bk73ap+odLCOOm2/B02rKE8lb9
github.com/bytemare/hash2curve v0.1.2/go.mod h1:S+OcM3nIREThTmjkFa+nX6vqGH11nEzefaIYq7MVAp4=
github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc=
github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
golang.org/x/sys v0.0.0-20220803195053-6e608f9ce704 h1:Y7NOhdqIOU8kYI7BxsgL38d0ot0raxvcW+EMQU2QrT4=
golang.org/x/sys v0.0.0-20220803195053-6e608f9ce704/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
4 changes: 2 additions & 2 deletions groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ func (g Group) EncodeToGroup(input, dst []byte) *Element {
}

// ScalarLength returns the byte size of an encoded scalar.
func (g Group) ScalarLength() uint {
func (g Group) ScalarLength() int {
return g.get().ScalarLength()
}

// ElementLength returns the byte size of an encoded element.
func (g Group) ElementLength() uint {
func (g Group) ElementLength() int {
return g.get().ElementLength()
}

Expand Down
4 changes: 2 additions & 2 deletions internal/edwards25519/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ func (g Group) Ciphersuite() string {
}

// ScalarLength returns the byte size of an encoded element.
func (g Group) ScalarLength() uint {
func (g Group) ScalarLength() int {
return canonicalEncodingLength
}

// ElementLength returns the byte size of an encoded element.
func (g Group) ElementLength() uint {
func (g Group) ElementLength() int {
return canonicalEncodingLength
}

Expand Down
4 changes: 2 additions & 2 deletions internal/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ type Group interface {
Ciphersuite() string

// ScalarLength returns the byte size of an encoded scalar.
ScalarLength() uint
ScalarLength() int

// ElementLength returns the byte size of an encoded element.
ElementLength() uint
ElementLength() int

// Order returns the order of the canonical group of scalars.
Order() string
Expand Down
8 changes: 4 additions & 4 deletions internal/nist/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ func (g Group[P]) Ciphersuite() string {
}

// ScalarLength returns the byte size of an encoded element.
func (g Group[P]) ScalarLength() uint {
func (g Group[P]) ScalarLength() int {
byteLen := (g.scalarField.bitLen() + 7) / 8
return uint(byteLen)
return byteLen
}

// ElementLength returns the byte size of an encoded element.
func (g Group[P]) ElementLength() uint {
func (g Group[P]) ElementLength() int {
byteLen := (g.curve.field.bitLen() + 7) / 8
return uint(1 + byteLen)
return 1 + byteLen
}

// Order returns the order of the canonical group of scalars.
Expand Down
4 changes: 2 additions & 2 deletions internal/ristretto/ristretto.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ func (g Group) Ciphersuite() string {
}

// ScalarLength returns the byte size of an encoded element.
func (g Group) ScalarLength() uint {
func (g Group) ScalarLength() int {
return canonicalEncodingLength
}

// ElementLength returns the byte size of an encoded element.
func (g Group) ElementLength() uint {
func (g Group) ElementLength() int {
return canonicalEncodingLength
}

Expand Down