...

Package p384

import "github.com/cloudflare/circl/ecc/p384"
Overview
Index
Examples

Overview ▾

Package p384 provides optimized elliptic curve operations on the P-384 curve.

These are some improvements over crypto/elliptic package:

  • Around 10x faster in amd64 architecture.
  • Reduced number of memory allocations.
  • Native support for arm64 architecture.
  • ScalarMult is performed using a constant-time algorithm.
  • ScalarBaseMult fallbacks into ScalarMult.
  • A new method included for double-point multiplication.

Example (P384)

Code:

// import "github.com/cloudflare/circl/ecc/p384"
// import "crypto/elliptic"
circl := p384.P384()
stdlib := elliptic.P384()

params := circl.Params()
K, _ := rand.Int(rand.Reader, params.N)
k := K.Bytes()

x1, y1 := circl.ScalarBaseMult(k)
x2, y2 := stdlib.ScalarBaseMult(k)
fmt.Printf("%v, %v", x1.Cmp(x2) == 0, y1.Cmp(y2) == 0)

Output:

true, true

type Curve

Curve is used to provide the extended functionality and performance of elliptic.Curve interface.

type Curve interface {
    elliptic.Curve
    // IsAtInfinity returns True is the point is the identity point.
    IsAtInfinity(X, Y *big.Int) bool
    // CombinedMult calculates P=mG+nQ, where G is the generator and
    // Q=(Qx,Qy). The scalars m and n are positive integers in big-endian form.
    // Runs in non-constant time to be used in signature verification.
    CombinedMult(Qx, Qy *big.Int, m, n []byte) (Px, Py *big.Int)
}

func P384

func P384() Curve

P384 returns a Curve which implements P-384 (see FIPS 186-3, section D.2.4).