diff --git a/.github/.golangci.yml b/.github/.golangci.yml index d117b04..105a21c 100644 --- a/.github/.golangci.yml +++ b/.github/.golangci.yml @@ -8,7 +8,7 @@ linters: - contextcheck - cyclop - deadcode - - depguard + #- depguard - dogsled - dupl - durationcheck diff --git a/.github/Makefile b/.github/Makefile index f29d334..eb53d90 100644 --- a/.github/Makefile +++ b/.github/Makefile @@ -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 ..." diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61ba7bd..2bc3ad1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 494b417..83d8021 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -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 diff --git a/README.md b/README.md index 7b6c3f0..f61dcd0 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/doc.go b/doc.go index a4cbc61..27710da 100644 --- a/doc.go +++ b/doc.go @@ -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 diff --git a/expand.go b/expand.go index 60a8097..393a21b 100644 --- a/expand.go +++ b/expand.go @@ -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 { diff --git a/go.mod b/go.mod index f954d99..0d870de 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index c2dd41a..50eda9f 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/i2osp.go b/i2osp.go index b3b0aa4..080b31c 100644 --- a/i2osp.go +++ b/i2osp.go @@ -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) diff --git a/xmd.go b/xmd.go index 292d591..c42a037 100644 --- a/xmd.go +++ b/xmd.go @@ -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) diff --git a/xof.go b/xof.go index 5a29dc1..e4b9fff 100644 --- a/xof.go +++ b/xof.go @@ -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)