Skip to content

Commit

Permalink
Add tests, update dependencies and some minor improvements (#19)
Browse files Browse the repository at this point in the history
* Add tests, update dependencies, and some minor improvements

Signed-off-by: bytemare <[email protected]>

---------

Signed-off-by: bytemare <[email protected]>
  • Loading branch information
bytemare authored Dec 25, 2023
1 parent 3b2556d commit 07922ef
Show file tree
Hide file tree
Showing 23 changed files with 653 additions and 260 deletions.
7 changes: 6 additions & 1 deletion .github/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ linters:
- contextcheck
- cyclop
- decorder
- depguard
#- depguard
- dogsled
- dupl
- durationcheck
Expand Down Expand Up @@ -96,6 +96,11 @@ linters:
fast: false

linters-settings:
cyclop:
# The maximal code complexity to report.
# Default: 10
max-complexity: 12
skip-tests: true
dupl:
threshold: 100
errcheck:
Expand Down
1 change: 1 addition & 0 deletions .github/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ update-linters:
@go install mvdan.cc/gofumpt@latest
@go install github.com/daixiang0/gci@latest
@go install github.com/segmentio/golines@latest
@go install golang.org/x/tools/cmd/goimports@latest
@go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin

Expand Down
2 changes: 1 addition & 1 deletion .github/licence-header.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SPDX-License-Identifier: MIT

Copyright (C) 2021 Daniel Bourdrez. All Rights Reserved.
Copyright (C) 2024 Daniel Bourdrez. All Rights Reserved.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree or at
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

# Linting
- name: Linting
uses: golangci/golangci-lint-action@5c56cd6c9dc07901af25baab6f2b0d9f3b7c3018 # pin@master
uses: golangci/golangci-lint-action@2e6adf08a9d304f4ac29fc9cb609dcd6a6e05c40 # pin@master
with:
version: latest
args: --config=./.github/.golangci.yml ./...
Expand All @@ -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@24cb9080177205b6e8c946b17badbe402adc938f # pin@master
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:

# Codecov
- name: Codecov
uses: codecov/codecov-action@29386c70ef20e286228c72b668a06fd0e8399192 # pin@master
uses: codecov/codecov-action@bbeaa140357942e4e8d8e15f1cd2f4e612f64c59 # pin@master
with:
file: .github/coverage.out

Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ jobs:

strategy:
fail-fast: false
matrix:
go: [ '1.21', '1.20' ]

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@231aa2c8a89117b126725a0e11897209b7118144 # pin@master
uses: github/codeql-action/init@6f5223db54afb6bccb7b88162896588caa1f611b # pin@master
with:
languages: go

- name: Autobuild
uses: github/codeql-action/autobuild@231aa2c8a89117b126725a0e11897209b7118144 # pin@master
uses: github/codeql-action/autobuild@6f5223db54afb6bccb7b88162896588caa1f611b # pin@master

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@231aa2c8a89117b126725a0e11897209b7118144 # pin@master
uses: github/codeql-action/analyze@6f5223db54afb6bccb7b88162896588caa1f611b # pin@master
4 changes: 2 additions & 2 deletions .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@99c53751e09b9529366343771cc321ec74e9bd3d # pin@master
uses: ossf/scorecard-action@342acf350cd07e41a36da9be2b107614dd1661a3 # pin@master
with:
results_file: results.sarif
results_format: sarif
Expand All @@ -50,6 +50,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@807578363a7869ca324a79039e6db9c843e0e100 # pin@master
uses: github/codeql-action/upload-sarif@6f5223db54afb6bccb7b88162896588caa1f611b # pin@master
with:
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
//
// Copyright (C) 2021 Daniel Bourdrez. All Rights Reserved.
// Copyright (C) 2024 Daniel Bourdrez. All Rights Reserved.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree or at
Expand Down
16 changes: 8 additions & 8 deletions client_state.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
//
// Copyright (C) 2021 Daniel Bourdrez. All Rights Reserved.
// Copyright (C) 2024 Daniel Bourdrez. All Rights Reserved.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree or at
Expand All @@ -16,13 +16,13 @@ import (

// State represents a client's state, allowing internal values to be exported and imported to resume a session.
type State struct {
Identifier Identifier `json:"s"`
TweakedKey []byte `json:"t,omitempty"`
ServerPublicKey []byte `json:"p,omitempty"`
Input [][]byte `json:"i"`
Blind [][]byte `json:"r"`
Blinded [][]byte `json:"d"`
Mode Mode `json:"m"`
Identifier Ciphersuite `json:"s"`
TweakedKey []byte `json:"t,omitempty"`
ServerPublicKey []byte `json:"p,omitempty"`
Input [][]byte `json:"i"`
Blind [][]byte `json:"r"`
Blinded [][]byte `json:"d"`
Mode Mode `json:"m"`
}

// Export extracts the client's internal values that can be imported in another client for session resumption.
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
//
// Copyright (C) 2021 Daniel Bourdrez. All Rights Reserved.
// Copyright (C) 2024 Daniel Bourdrez. All Rights Reserved.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree or at
Expand Down
4 changes: 2 additions & 2 deletions errors.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
//
// Copyright (C) 2021 Daniel Bourdrez. All Rights Reserved.
// Copyright (C) 2024 Daniel Bourdrez. All Rights Reserved.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree or at
Expand All @@ -12,7 +12,7 @@ import "errors"

var (
errParamInvalidMode = errors.New("invalid OPRF mode")
errParamInvalidID = errors.New("invalid Identifier")
errParamInvalidID = errors.New("invalid Ciphersuite")
errParamFinalizeLen = errors.New("invalid number of elements in evaluation")
errParamInputEqualLen = errors.New("input lengths are not equal")
errParamNoPubKey = errors.New("missing public key")
Expand Down
2 changes: 1 addition & 1 deletion evaluation.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
//
// Copyright (C) 2021 Daniel Bourdrez. All Rights Reserved.
// Copyright (C) 2024 Daniel Bourdrez. All Rights Reserved.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree or at
Expand Down
6 changes: 3 additions & 3 deletions examples_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
//
// Copyright (C) 2021 Daniel Bourdrez. All Rights Reserved.
// Copyright (C) 2024 Daniel Bourdrez. All Rights Reserved.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree or at
Expand Down Expand Up @@ -41,7 +41,7 @@ func exchangeWithServer(blinded []byte, verifiable bool) []byte {
return ev
}

func ExampleClient() {
func Example_client() {
input := []byte("input")

// Set up a new client. Not indicating a server public key indicates we don't use the verifiable mode.
Expand Down Expand Up @@ -102,7 +102,7 @@ func Example_verifiableClient() {
// Output:
}

func Example_baseServer() {
func Example_server() {
// We suppose the client sends this blinded element.
blinded, _ := hex.DecodeString("7eaf3d7cbe43d54637274342ce53578b2aba836f297f4f07997a6e1dced1c058")

Expand Down
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
module github.com/bytemare/voprf

go 1.20
go 1.21

require (
github.com/bytemare/crypto v0.4.4
github.com/bytemare/hash v0.1.5
github.com/google/go-cmp v0.5.9
github.com/bytemare/crypto v0.5.2
github.com/bytemare/hash v0.1.7
)

require (
filippo.io/edwards25519 v1.0.0 // indirect
filippo.io/nistec v0.0.2 // indirect
github.com/bytemare/hash2curve v0.1.3 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
filippo.io/nistec v0.0.3 // indirect
github.com/bytemare/hash2curve v0.2.3 // indirect
github.com/bytemare/secp256k1 v0.1.0 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/sys v0.15.0 // indirect
)
32 changes: 16 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
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.2 h1:/NIXTUimcHIh0E2DsYucHlICvUisgj28/XEnKSEptUs=
filippo.io/nistec v0.0.2/go.mod h1:84fxC9mi+MhC2AERXI4LSa8cmSVOzrFikg6hZ4IfCyw=
github.com/bytemare/crypto v0.4.4 h1:BR4j35IRJIdDQa0dyqo4OS5OZ+mLlijhUxwWvgcipG4=
github.com/bytemare/crypto v0.4.4/go.mod h1:UA6K3SBPZ0C2VHQXc/9LT93rWTBwXxXNZFNL4uwapPo=
github.com/bytemare/hash v0.1.5 h1:VW+X1YQ2b3chjRFHkRUnO42uclsQjXimdBCPOgIobR4=
github.com/bytemare/hash v0.1.5/go.mod h1:+QmWXTky/2b63ngqM5IYezGydn9UTFDhpX7mLYwYxCA=
github.com/bytemare/hash2curve v0.1.3 h1:BOqV8BF5dF+BbPZgIyoeAVTwd4m7jmw4LwacD1GFBvU=
github.com/bytemare/hash2curve v0.1.3/go.mod h1:Wma3DmJdn8kqiK9j120hkWvC3tQVKS1PyA8ZzyG23BI=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
filippo.io/nistec v0.0.3 h1:h336Je2jRDZdBCLy2fLDUd9E2unG32JLwcJi0JQE9Cw=
filippo.io/nistec v0.0.3/go.mod h1:84fxC9mi+MhC2AERXI4LSa8cmSVOzrFikg6hZ4IfCyw=
github.com/bytemare/crypto v0.5.2 h1:ogvfY5mmtrPc5Uhwq4mUEUDnTVig+UEF8gwnNAPaNbU=
github.com/bytemare/crypto v0.5.2/go.mod h1:kkx4ciRQFWcjMauezZo9SHw4YmqSTolWkfOVVTOXgAY=
github.com/bytemare/hash v0.1.7 h1:5SqO0vCqefSkbY4UVfjSmUKyadDGoWk8fiXJDpnKE7Q=
github.com/bytemare/hash v0.1.7/go.mod h1:aAUXRjcoavq+IrTSZHPY9nEy8wHmWZk8y4Sbol4XkWU=
github.com/bytemare/hash2curve v0.2.3 h1:/1fbzqtmxu2sth4CWOhQHF2IueTDeJlIPu4mFMPvKsQ=
github.com/bytemare/hash2curve v0.2.3/go.mod h1:AyhJKfHs0s8+thKO+lMKKMm1aGc26GLHNdI1sD6fCSo=
github.com/bytemare/secp256k1 v0.1.0 h1:kjVJ06GAHSa+EJ7Rz1LdVgE0DQWdvUT77tmcGf7epXQ=
github.com/bytemare/secp256k1 v0.1.0/go.mod h1:hzquMsr3GXhVcqL9qFX7GGjmcT5dlQldKrArd7tcXHE=
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.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=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.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=
Loading

0 comments on commit 07922ef

Please sign in to comment.