Skip to content

Commit

Permalink
some clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
dbourdrez committed Jun 6, 2024
1 parent 2b76b0e commit f3dda16
Show file tree
Hide file tree
Showing 24 changed files with 932 additions and 1,788 deletions.
113 changes: 63 additions & 50 deletions .github/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,78 +5,95 @@ linters:
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- containedctx
- contextcheck
- copyloopvar
- cyclop
- decorder
#- depguard
- dogsled
- dupl
- dupword
- durationcheck
- err113
- errcheck
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
#- exhaustive
- exhaustruct
- exportloopref
- fatcontext
- forbidigo
- forcetypeassert
- funlen
- gci
- ginkgolinter
- gocheckcompilerdirectives
#- gochecknoglobals
#- gochecknoinits
- gochecknoinits
- gochecksumtype
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
- goerr113
- gofmt
- gofumpt
- goheader
- goimports
#- gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- gosmopolitan
- govet
- grouper
- importas
- inamedparam
- ineffassign
- interfacebloat
- intrange
- ireturn
- lll
- logrlint
- loggercheck
- maintidx
- makezero
- mirror
- misspell
#- mnd
- musttag
- nakedret
- nestif
- nilerr
- nilnil
- nlreturn
- noctx
- nolintlint
#- nonamedreturns
- nonamedreturns
- nosprintfhostport
- paralleltest
- perfsprint
- prealloc
- predeclared
- promlinter
- protogetter
- reassign
- revive
- rowserrcheck
- sloglint
- spancheck
- sqlclosecheck
- staticcheck
- stylecheck
- tagalign
- tagliatelle
- tenv
#- testableexamples
- testableexamples
- testifylint
- testpackage
- thelper
- tparallel
Expand All @@ -88,19 +105,11 @@ linters:
#- varnamelen
- wastedassign
- whitespace
- wrapcheck
#- wrapcheck
- wsl
presets:
- bugs
- unused
fast: false
- zerologlint

linters-settings:
cyclop:
# The maximal code complexity to report.
# Default: 10
max-complexity: 12
skip-tests: true
dupl:
threshold: 100
errcheck:
Expand All @@ -117,7 +126,7 @@ linters-settings:
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/bytemare/old_voprf) # Custom section: groups all imports with the specified Prefix.
- prefix(github.com/bytemare/voprf) # Custom section: groups all imports with the specified Prefix.
skip-generated: true
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
Expand All @@ -135,6 +144,8 @@ linters-settings:
- opinionated
- performance
- style
disabled-checks:
- unnamedResult
gocyclo:
min-complexity: 15
godox:
Expand All @@ -147,24 +158,13 @@ linters-settings:
gofmt:
simplify: true
goimports:
local-prefixes: github.com/bytemare/old_voprf
golint:
min-confidence: 0
gomnd:
checks:
- argument
- case
- condition
- operation
- return
- assign
ignored-functions:
- 'Import'
- 'Deserialize'
- 'DeriveKeyPair'
- 'i2osp2'
local-prefixes: github.com/bytemare/voprf
gosimple:
checks: [ "all" ]
govet:
check-shadowing: true
settings:
shadow:
strict: true
disable-all: true
enable:
- asmdecl
Expand Down Expand Up @@ -209,13 +209,23 @@ linters-settings:
tab-width: 4
misspell:
locale: US
mnd:
checks:
- argument
- case
- condition
- operation
- return
- assign
#ignored-functions:
# - 'nist.setMapping'
# - 'big.NewInt'
# - 'hash2curve.HashToFieldXMD'
nlreturn:
block-size: 2
prealloc:
simple: false
for-loops: true
unused:
check-exported: false
whitespace:
multi-if: false
multi-func: false
Expand All @@ -236,17 +246,18 @@ issues:
# But independently from this option we use default exclude patterns,
# it can be disabled by `exclude-use-default: false`. To list all
# excluded by default patterns execute `golangci-lint run --help`
exclude:
- "should have a package comment, unless it's in another file for this package"
#exclude:
#- "should have a package comment, unless it's in another file for this package"
#- "do not define dynamic errors, use wrapped static errors instead"
#- "missing cases in switch of type Group: maxID"

exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec
#exclude-rules:
# - path: internal/hash.go
# linters:
# - errcheck
# - path: internal/tag/strings.go
# linters:
# - gosec

max-issues-per-linter: 0
max-same-issues: 0
Expand All @@ -260,5 +271,7 @@ issues:
run:
tests: false

output:
format: github-actions
#output:
# formats:
# - format: github-actions
# show-stats: true
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
[![Go Reference](https://pkg.go.dev/badge/github.com/bytemare/voprf.svg)](https://pkg.go.dev/github.com/bytemare/voprf)
[![codecov](https://codecov.io/gh/bytemare/voprf/branch/main/graph/badge.svg?token=5bQfB0OctA)](https://codecov.io/gh/bytemare/voprf)

Package voprf provides abstracted access to Oblivious Pseudorandom Functions (OPRF) over Elliptic Curves as specified in
[RFC9497](https://datatracker.ietf.org/doc/rfc9497) and fully supports the OPRF, VOPRF, and POPRF protocols.
Package voprf implements [RFC9497](https://datatracker.ietf.org/doc/rfc9497) and provides Oblivious Pseudorandom Functions
(OPRF) over Elliptic Curves, and fully supports the OPRF, VOPRF, and POPRF protocols.

## Versioning

Expand Down
13 changes: 0 additions & 13 deletions doc.go

This file was deleted.

36 changes: 36 additions & 0 deletions encoding.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: MIT
//
// 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
// https://spdx.org/licenses/MIT.html

// Package voprf implements RFC9497 and provides abstracted access to Oblivious Pseudorandom Functions (OPRF) and
// Threshold Oblivious Pseudorandom Functions (TOPRF) using Elliptic Curve Prime Order Groups (EC-OPRF).
// For VOPRF and POPRF use the github.com/bytemare/oprf/voprf package.
package voprf

import group "github.com/bytemare/crypto"

// DecodeElement decodes e to an element in the group.
func (c Ciphersuite) DecodeElement(e []byte) (*group.Element, error) {
result := group.Group(c).NewElement()

Check warning on line 18 in encoding.go

View check run for this annotation

Codecov / codecov/patch

encoding.go#L17-L18

Added lines #L17 - L18 were not covered by tests

if err := result.Decode(e); err != nil {
return nil, err

Check warning on line 21 in encoding.go

View check run for this annotation

Codecov / codecov/patch

encoding.go#L20-L21

Added lines #L20 - L21 were not covered by tests
}

return result, nil

Check warning on line 24 in encoding.go

View check run for this annotation

Codecov / codecov/patch

encoding.go#L24

Added line #L24 was not covered by tests
}

// DecodeScalar decodes s to a scalar in the group.
func (c Ciphersuite) DecodeScalar(s []byte) (*group.Scalar, error) {
result := group.Group(c).NewScalar()

Check warning on line 29 in encoding.go

View check run for this annotation

Codecov / codecov/patch

encoding.go#L28-L29

Added lines #L28 - L29 were not covered by tests

if err := result.Decode(s); err != nil {
return nil, err

Check warning on line 32 in encoding.go

View check run for this annotation

Codecov / codecov/patch

encoding.go#L31-L32

Added lines #L31 - L32 were not covered by tests
}

return result, nil

Check warning on line 35 in encoding.go

View check run for this annotation

Codecov / codecov/patch

encoding.go#L35

Added line #L35 was not covered by tests
}
Loading

0 comments on commit f3dda16

Please sign in to comment.