GithubHelp home page GithubHelp logo

kklash / ekliptic Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 416 KB

Primitives for cryptographic operations on the secp256k1 curve, with zero dependencies and excellent performance.

License: MIT License

Go 97.43% Rust 1.90% Python 0.68%

ekliptic's People

Contributors

kklash avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

ekliptic's Issues

feat: satisfy elliptic.Curve interface

Golang's standard library provides an elliptic curve crypto utility:

$ go doc elliptic.curve
package elliptic // import "crypto/elliptic"

type Curve interface {
	// Params returns the parameters for the curve.
	Params() *CurveParams
	// IsOnCurve reports whether the given (x,y) lies on the curve.
	IsOnCurve(x, y *big.Int) bool
	// Add returns the sum of (x1,y1) and (x2,y2)
	Add(x1, y1, x2, y2 *big.Int) (x, y *big.Int)
	// Double returns 2*(x,y)
	Double(x1, y1 *big.Int) (x, y *big.Int)
	// ScalarMult returns k*(Bx,By) where k is a number in big-endian form.
	ScalarMult(x1, y1 *big.Int, k []byte) (x, y *big.Int)
	// ScalarBaseMult returns k*G, where G is the base point of the group
	// and k is an integer in big-endian form.
	ScalarBaseMult(k []byte) (x, y *big.Int)
}
    A Curve represents a short-form Weierstrass curve with a=-3.

    The output of Add, Double, and ScalarMult when the input is not a point on
    the curve is undefined.

    Note that the conventional point at infinity (0, 0) is not considered on the
    curve, although it can be returned by Add, Double, ScalarMult, or
    ScalarBaseMult (but not Unmarshal or UnmarshalCompressed).

We should provide a struct which fulfills this interface, so callers can use it in golang standard library APIs.

Possibly related: if we have an elliptic.Curve, we can get rid of ekliptic.NewPrivateKey, because callers could just use crypto/elliptic.GenerateKey instead:

package elliptic // import "crypto/elliptic"

func GenerateKey(curve Curve, rand io.Reader) (priv []byte, x, y *big.Int, err error)
    GenerateKey returns a public/private key pair. The private key is generated
    using the given reader, which must return random data.

Documentation improvements

  • More examples of how to use this code, in human readable terms (#11)
  • Add custom artwork for the library
  • Publish a link to pkg.go.dev in readme (9e6b550)

feat: improve quality and reproducability of test vectors

Test vectors are rather opaque right now as to where they came from and how I got them. We could write scripts to re-derive (thus validating) our test vectors using other stable secp256k1 implementations.

Potential side-quest related to this issue: in EC math unit tests, we should check affine equality against vectors rather than jacobian equality. It doesn't matter in the end what the exact (x,y,z) pair is, as long as the jacobian ratio is equivalent to the desired affine point. Testing affine equality will make it easier to consume the test vectors of other implementations, because they may use different jacobian math than us.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.