Prime-order Elliptic Curve Groups
import "github.com/bytemare/crypto"
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.
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
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
type Group interface {
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
}
Scalar interface
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
Hex() string
HexDecode([]byte) error
encoding.BinaryMarshaler
encoding.BinaryUnmarshaler
}
Element interface
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
}
Documentation
You can find the documentation and usage examples in the package doc and the project wiki .
Versioning
SemVer is used for versioning. For the versions available, see the tags on the repository.
Contributing
Please read CONTRIBUTING.md for details on the code of conduct, and the process for submitting pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.