Skip to content

Commit

Permalink
Update (#1)
Browse files Browse the repository at this point in the history
* Update package name, move to new repo, update documentation

---------

Signed-off-by: bytemare <3641580+bytemare@users.noreply.github.com>
  • Loading branch information
bytemare authored Oct 3, 2024
1 parent b2be839 commit a8c0b1c
Show file tree
Hide file tree
Showing 44 changed files with 269 additions and 261 deletions.
8 changes: 4 additions & 4 deletions .github/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ linters-settings:
check-type-assertions: true
check-blank: false
exclude-functions:
- (*crypto/Element).MarshalBinary
- (*crypto/Scalar).MarshalBinary
- (*ecc/Element).MarshalBinary
- (*ecc/Scalar).MarshalBinary
# - io/ioutil.ReadFile
# - io.Copy(*bytes.Buffer)
# - io.Copy(os.Stdout)
Expand All @@ -115,7 +115,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/crypto) # Custom section: groups all imports with the specified Prefix.
- prefix(github.com/bytemare/ecc) # 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 Down Expand Up @@ -147,7 +147,7 @@ linters-settings:
gofmt:
simplify: true
goimports:
local-prefixes: github.com/bytemare/crypto
local-prefixes: github.com/bytemare/ecc
gosimple:
checks: [ "all" ]
govet:
Expand Down
8 changes: 4 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# How to contribute to this project

* 🔎 Please ensure your findings have not already been reported by searching on the project repository under [Issues](https://github.com/bytemare/crypto).
* 🔎 Please ensure your findings have not already been reported by searching on the project repository under [Issues](https://github.com/bytemare/ecc).
* If you think your findings can be complementary to an existing issue, don't hesitate to join the conversation 😃☕
* If there's no issue addressing the problem, [open a new one](https://github.com/bytemare/crypto/issues/new). Please be clear in the title and description, and add relevant information. Bonus points if you provide a **code sample** and everything needed to reproduce the issue when expected behaviour is not occurring.
* If there's no issue addressing the problem, [open a new one](https://github.com/bytemare/ecc/issues/new). Please be clear in the title and description, and add relevant information. Bonus points if you provide a **code sample** and everything needed to reproduce the issue when expected behaviour is not occurring.
* If possible, use the relevant issue templates.

### Do you have a fix?

🎉 That's awesome! Pull requests are welcome!

* Please [open an issue](https://github.com/bytemare/crypto) beforehand, so we can discuss this.
* Please [open an issue](https://github.com/bytemare/ecc) beforehand, so we can discuss this.
* Fork this repo from `main`, and ensure your fork is up-to-date with it when submitting the PR.
* If your changes impact the documentation, please update it accordingly.
* If you added code that impact tests, please add tests with relevant coverage and test cases. Bonus points for fuzzing.
Expand All @@ -29,7 +29,7 @@ This project follows the [Benevolent Dictator Governance Model](http://oss-watch

### Licence

By contributing to this project, you agree that your contributions will be licensed under the project's [License](https://github.com/bytemare/crypto/blob/main/LICENSE).
By contributing to this project, you agree that your contributions will be licensed under the project's [License](https://github.com/bytemare/ecc/blob/main/LICENSE).

All contributions (including pull requests) must agree to the [Developer Certificate of Origin (DCO) version 1.1](https://developercertificate.org). It states that the contributor has the right to submit the patch for inclusion into the project. Simply submitting a contribution implies this agreement, however, please include the "Signed-off-by" git tag in every commit (this tag is a conventional way to confirm that you agree to the DCO).

Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Questions, feature requests, and more 💬
url: https://github.com/bytemare/crypto/discussions
about: Do you need help? Did you make something with crypto? Do you have an idea? Tell us about it!
url: https://github.com/bytemare/ecc/discussions
about: Do you need help? Did you make something with ecc? Do you have an idea? Tell us about it!
3 changes: 1 addition & 2 deletions .github/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ update:
@echo "Updating dependencies..."
@cd ../ && go get -u ./...
@go mod tidy
@echo "Updating Github Actions pins..."
@$(foreach file, $(wildcard workflows/*.yml), pin-github-action $(file);)

.PHONY: update-linters
update-linters:
@echo "Updating linters..."
@go install mvdan.cc/gofumpt@latest
@go install github.com/daixiang0/gci@latest
@go install github.com/segmentio/golines@latest
@go install github.com/google/addlicense@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/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Only the latest version will be benefit from security fixes. Maintainers of proj

## Reporting a Vulnerability

Vulnerabilities can be reported through Github issues, here: https://github.com/bytemare/crypto/issues.
Vulnerabilities can be reported through Github issues, here: https://github.com/bytemare/ecc/issues.
If the issue is sensitive enough that the reporter thinks the discussion needs more confidentiality, we can discuss options there (e.g. On a Security Advisory or per e-mail).
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) 2024 Daniel Bourdrez. All Rights Reserved.
Copyright (C) 2020-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
2 changes: 1 addition & 1 deletion .github/sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sonar.organization=bytemare
sonar.projectKey=crypto
sonar.projectKey=ecc
sonar.sources=.
sonar.tests=tests/
sonar.test.exclusions=tests/**
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2023 Bytemare
Copyright (c) 2020-2024 Daniel Bourdrez

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
161 changes: 86 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,58 @@
# Prime-order Elliptic Curve Groups
[![CI](https://github.com/bytemare/crypto/actions/workflows/code-scan.yml/badge.svg)](https://github.com/bytemare/crypto/actions/workflows/code-scan.yml)
[![Go Reference](https://pkg.go.dev/badge/github.com/bytemare/crypto.svg)](https://pkg.go.dev/github.com/bytemare/crypto)
[![codecov](https://codecov.io/gh/bytemare/crypto/branch/main/graph/badge.svg?token=5bQfB0OctA)](https://codecov.io/gh/bytemare/crypto)
# Elliptic Curve Groups
[![CI](https://github.com/bytemare/ecc/actions/workflows/code-scan.yml/badge.svg)](https://github.com/bytemare/ecc/actions/workflows/code-scan.yml)
[![Go Reference](https://pkg.go.dev/badge/github.com/bytemare/ecc.svg)](https://pkg.go.dev/github.com/bytemare/ecc)
[![codecov](https://codecov.io/gh/bytemare/ecc/branch/main/graph/badge.svg?token=5bQfB0OctA)](https://codecov.io/gh/bytemare/ecc)

```Go
import "github.com/bytemare/crypto"
import "github.com/bytemare/ecc"
```

This package exposes abstract operations over opaque prime-order elliptic curve groups and their scalars and elements,
This package exposes abstract operations over opaque (prime-order) elliptic curve groups and their scalars and elements,
and support hash-to-curve as per [RFC 9380](https://datatracker.ietf.org/doc/rfc9380).

It is made so you can swap between primitives with no code change and only the Group identifier.
The package serves as an interface to optimized and secure implementations that serve as backends, and to which you
don't need to adapt.

The following table indexes supported groups with hash-to-curve capability and links each one to the underlying implementations:

| ID | Name | Backend |
|----|--------------|-------------------------------|
| 1 | Ristretto255 | github.com/gtank/ristretto255 |
| 2 | Decaf448 | not supported |
| 3 | P-256 | filippo.io/nistec |
| 4 | P-384 | filippo.io/nistec |
| 5 | P-521 | filippo.io/nistec |
| 6 | Edwards25519 | filippo.io/edwards25519 |
| 7 | Secp256k1 | github.com/bytemare/secp256k1 |
| 8 | Double-Odd | not yet supported |

## Prime-order group interface
It makes using different elliptic curves easy, flexible, and without loosing performance or security. You don't have to
care about the parameters.
You can swap between primitives with no code change and only the Group identifier, a byte.
The package is a wrapper to optimized and secure implementations that serve as backends, and to which you
don't need to adapt and learn about.

The following table shows supported groups with hash-to-curve capability and links each one to the underlying
implementations:

| ID | Name | Prime-order | Backend |
|----|--------------|-------------------|-------------------------------|
| 1 | Ristretto255 | yes | github.com/gtank/ristretto255 |
| 2 | Decaf448 | not supported | not supported |
| 3 | P-256 | yes | filippo.io/nistec |
| 4 | P-384 | yes | filippo.io/nistec |
| 5 | P-521 | yes | filippo.io/nistec |
| 6 | Edwards25519 | no | filippo.io/edwards25519 |
| 7 | Secp256k1 | yes | github.com/bytemare/secp256k1 |
| 9 | Curve25519 | not yet supported | not yet supported |
| 8 | Double-Odd | not yet supported | not yet supported |

## Group interface

This package exposes types that can handle different implementations under the hood, internally using an interface
to the group and its scalars and elements, but you don't need to instantiate or implement anything. Just use the type in
the top package.

### Group interface
### Group

```Go
// Group abstracts operations in a prime-order group.
type Group interface {
NewScalar() Scalar
NewElement() Element
Base() Element
NewScalar() Scalar
NewElement() Element
Base() Element
HashFunc() crypto.Hash
HashToScalar(input, dst []byte) Scalar
HashToGroup(input, dst []byte) Element
EncodeToGroup(input, dst []byte) Element
Ciphersuite() string
ScalarLength() int
ElementLength() int
Order() string
HashToScalar(input, dst []byte) Scalar
HashToGroup(input, dst []byte) Element
EncodeToGroup(input, dst []byte) Element
Ciphersuite() string
ScalarLength() int
ElementLength() int
Order() []byte
}
```

Expand All @@ -57,62 +61,69 @@ type Group interface {
```Go
// Scalar interface abstracts common operations on scalars in a prime-order Group.
type Scalar interface {
Zero() Scalar
One() Scalar
Random() Scalar
Add(Scalar) Scalar
Subtract(Scalar) Scalar
Multiply(Scalar) Scalar
Pow(Scalar) Scalar
Invert() Scalar
Equal(Scalar) int
LessOrEqual(Scalar) int
IsZero() bool
Set(Scalar) Scalar
SetUInt64(uint64) Scalar
UInt64() (uint64, error)
Copy() Scalar
Encode() []byte
Decode(in []byte) error
Group() Group
Zero() Scalar
One() Scalar
MinusOne() Scalar
Random() Scalar
Add(Scalar) Scalar
Subtract(Scalar) Scalar
Multiply(Scalar) Scalar
Pow(Scalar) Scalar
Invert() Scalar
Equal(Scalar) int
LessOrEqual(Scalar) bool
IsZero() bool
Set(Scalar) Scalar
SetUInt64(uint64) Scalar
UInt64() (uint64, error)
Copy() Scalar
Encode() []byte
Decode(in []byte) error
Hex() string
HexDecode([]byte) error
encoding.BinaryMarshaler
encoding.BinaryUnmarshaler
MarshalJSON()
UnmarshalJSON()
encoding.BinaryMarshaler
encoding.BinaryUnmarshaler
}
```

### Element interface
```Go
// Element interface abstracts common operations on an Element in a prime-order Group.
type Element interface {
Base() Element
Identity() Element
Add(Element) Element
Double() Element
Negate() Element
Subtract(Element) Element
Multiply(Scalar) Element
Equal(element Element) int
IsIdentity() bool
Set(Element) Element
Copy() Element
Encode() []byte
XCoordinate() []byte
Decode(data []byte) error
Hex() string
HexDecode([]byte) error
encoding.BinaryMarshaler
encoding.BinaryUnmarshaler
Group() Group
Base() Element
Identity() Element
Add(Element) Element
Double() Element
Negate() Element
Subtract(Element) Element
Multiply(Scalar) Element
Equal(element Element) int
IsIdentity() bool
Set(Element) Element
Copy() Element
Encode() []byte
XCoordinate() []byte
Decode(data []byte) error
Hex() string
HexDecode([]byte) error
MarshalJSON() ([]byte, error)
UnmarshalJSON(data []byte) error
encoding.BinaryMarshaler
encoding.BinaryUnmarshaler
}
```

## Documentation [![Go Reference](https://pkg.go.dev/badge/github.com/bytemare/crypto.svg)](https://pkg.go.dev/github.com/bytemare/crypto)
## Documentation [![Go Reference](https://pkg.go.dev/badge/github.com/bytemare/ecc.svg)](https://pkg.go.dev/github.com/bytemare/ecc)

You can find the documentation and usage examples in [the package doc](https://pkg.go.dev/github.com/bytemare/crypto) and [the project wiki](https://github.com/bytemare/crypto/wiki) .
You can find the documentation and usage examples in [the package doc](https://pkg.go.dev/github.com/bytemare/ecc) and [the project wiki](https://github.com/bytemare/ecc/wiki) .

## Versioning

[SemVer](https://semver.org) is used for versioning. For the versions available, see the [tags on the repository](https://github.com/bytemare/crypto/tags).
[SemVer](https://semver.org) is used for versioning. For the versions available, see the [tags on the repository](https://github.com/bytemare/ecc/tags).

## Contributing

Expand Down
7 changes: 3 additions & 4 deletions element.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
// SPDX-License-Identifier: MIT
//
// Copyright (C) 2020-2023 Daniel Bourdrez. All Rights Reserved.
// Copyright (C) 2020-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 crypto exposes a prime-order elliptic curve groups with additional hash-to-curve operations.
package crypto
package ecc

import (
"fmt"
"strings"

"github.com/bytemare/crypto/internal"
"github.com/bytemare/ecc/internal"
)

// Element represents an element on the curve of the prime-order group.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/bytemare/crypto
module github.com/bytemare/ecc

go 1.23.1

Expand Down
Loading

0 comments on commit a8c0b1c

Please sign in to comment.