New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/bytemare/cryptotools

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/bytemare/cryptotools

  • v0.7.5
  • Source
  • Go
  • Socket score

Version published
Created
Source

Prime-order Elliptic Curve Groups

CI Go Reference codecov

  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:

IDNameBackend
1Ristretto255github.com/gtank/ristretto255
2Decaf448not supported
3P-256filippo.io/nistec
4P-384filippo.io/nistec
5P-521filippo.io/nistec
6Edwards25519filippo.io/edwards25519
7Secp256k1github.com/bytemare/secp256k1
8Double-Oddnot 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

// Group abstracts operations in a prime-order group.
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

// 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
	Hex() string
	HexDecode([]byte) error
    encoding.BinaryMarshaler
    encoding.BinaryUnmarshaler
}

Element interface

// 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
}

Documentation Go Reference

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.

FAQs

Package last updated on 07 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc