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

update to RFC 9380 and cleanup #11

Merged
merged 1 commit into from
Nov 28, 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
2 changes: 1 addition & 1 deletion .github/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ linters:
- contextcheck
- cyclop
- deadcode
- depguard
#- depguard
- dogsled
- dupl
- durationcheck
Expand Down
5 changes: 0 additions & 5 deletions .github/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ test:
@echo "Running all tests ..."
@go test -v -vet=all ../...

.PHONY: vectors
vectors:
@echo "Testing vectors ..."
@go test -v ../tests/vectors_test.go

.PHONY: cover
cover:
@echo "Testing with coverage ..."
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: [ '1.20', '1.19' ]
go: [ '1.21', '1.20' ]
steps:
- name: Checkout repo
uses: actions/checkout@27135e314dd1818f797af1db9dae03a9f045786b # pin@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@dc323e67f16fb5f7663d20ff7941f27f5809e9b6 # pin@v2
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # pin@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import "github.com/bytemare/hash2curve"
```

Package hash2curve provides hash-to-curve compatible hashing over arbitrary input.
It implements the expanders and hashing to a field as specified in [hash-to-curve](https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve/).
Package hash2curve implements Hashing to Elliptic Curves as specified in RFC
It implements the expanders and hashing to a field as specified in [RFC 9380](https://datatracker.ietf.org/doc/rfc9380).

#### What is hash2curve?

> Hashing to curve allows representing arbitrary byte sequences as points on a curve (or elements in a group), therefore
> benefiting from interesting mathematical properties very useful in cryptographic protocols, like CPace, VOPRF, and
> OPAQUE.
> Hashing to Elliptic Curves allows for encoding or hashing an arbitrary string to a point on an elliptic curve
> (or element in a group), therefore benefiting from interesting mathematical properties very useful in cryptographic
> protocols, like CPace, VOPRF, and OPAQUE.

#### References

Expand Down
5 changes: 1 addition & 4 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@
// LICENSE file in the root directory of this source tree or at
// https://spdx.org/licenses/MIT.html

// Package hash2curve provides hash-to-curve compatible hashing over arbitrary input.
//
// It implements the latest hash-to-curve specification to date
// (https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve/).
// Package hash2curve Hashing to Elliptic Curves as specified in RFC 9380 (https://datatracker.ietf.org/doc/rfc9380).
package hash2curve
2 changes: 0 additions & 2 deletions expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ const (

var errZeroLenDST = errors.New("zero-length DST")

// errShortDST = internal.ParameterError("DST is shorter than recommended length")

func checkDST(dst []byte) {
if len(dst) < recommendedMinLength {
if len(dst) == minLength {
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/bytemare/hash2curve

go 1.20
go 1.21

require github.com/bytemare/hash v0.1.5
require github.com/bytemare/hash v0.1.6

require (
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/sys v0.15.0 // indirect
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
github.com/bytemare/hash v0.1.5 h1:VW+X1YQ2b3chjRFHkRUnO42uclsQjXimdBCPOgIobR4=
github.com/bytemare/hash v0.1.5/go.mod h1:+QmWXTky/2b63ngqM5IYezGydn9UTFDhpX7mLYwYxCA=
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
github.com/bytemare/hash v0.1.6 h1:iUZx7gGFro9PCu4AyPGSkMHL+EHIeYzi2506/gCol2k=
github.com/bytemare/hash v0.1.6/go.mod h1:oxLKCVlyD0EEknhpD+3L6EdMRbwa9XvAhLUjN1pupaE=
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
2 changes: 1 addition & 1 deletion i2osp.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
errLengthTooBig = errors.New("requested length is > 4")
)

// i2osp 32 bit Integer to Octet Stream Primitive on maximum 4 bytes.
// i2osp 32-bit Integer to Octet Stream Primitive on maximum 4 bytes.
func i2osp(value, length int) []byte {
if length <= 0 {
panic(errLengthNegative)
Expand Down
2 changes: 1 addition & 1 deletion xmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

var errLengthTooLarge = errors.New("requested byte length is too high")

// expandXMD implements https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve#section-5.4.1.
// expandXMD implements expand_message_xmd as specified in RFC 9380 section 5.3.1.
func expandXMD(id crypto.Hash, input, dst []byte, length int) []byte {
h := id.New()
dst = vetDSTXMD(h, dst)
Expand Down
2 changes: 1 addition & 1 deletion xof.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

var errXOFHighOutput = errors.New("XOF dst hashing is too long")

// expandMessage XOF implements https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve#section-5.4.2.
// expandMessage XOF implements expand_message_xof as specified in RFC 9380 section 5.3.2.
func expandXOF(x hash.Extendable, input, dst []byte, length int) []byte {
if length > math.MaxUint16 {
panic(errLengthTooLarge)
Expand Down
Loading