elliptic
packagestandard libraryThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package elliptic implements the standard NIST P-224, P-256, P-384, and P-521elliptic curves over prime fields.
Direct use of this package is deprecated, beyond theP224,P256,P384,andP521 values necessary to usecrypto/ecdsa. Most other usesshould migrate to the more efficient and safercrypto/ecdh, or tothird-party modules for lower-level functionality.
Index¶
- func GenerateKey(curve Curve, rand io.Reader) (priv []byte, x, y *big.Int, err error)deprecated
- func Marshal(curve Curve, x, y *big.Int) []bytedeprecated
- func MarshalCompressed(curve Curve, x, y *big.Int) []byte
- func Unmarshal(curve Curve, data []byte) (x, y *big.Int)deprecated
- func UnmarshalCompressed(curve Curve, data []byte) (x, y *big.Int)
- type Curve
- type CurveParams
- func (curve *CurveParams) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)deprecated
- func (curve *CurveParams) Double(x1, y1 *big.Int) (*big.Int, *big.Int)deprecated
- func (curve *CurveParams) IsOnCurve(x, y *big.Int) booldeprecated
- func (curve *CurveParams) Params() *CurveParams
- func (curve *CurveParams) ScalarBaseMult(k []byte) (*big.Int, *big.Int)deprecated
- func (curve *CurveParams) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int)deprecated
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcGenerateKeydeprecated
GenerateKey returns a public/private key pair. The private key isgenerated using the given reader, which must return random data.
Deprecated: for ECDH, use the GenerateKey methods of thecrypto/ecdh package;for ECDSA, use the GenerateKey function of the crypto/ecdsa package.
funcMarshaldeprecated
Marshal converts a point on the curve into the uncompressed form specified inSEC 1, Version 2.0, Section 2.3.3. If the point is not on the curve (or isthe conventional point at infinity), the behavior is undefined.
Deprecated: for ECDH, use the crypto/ecdh package. This function returns anencoding equivalent to that of PublicKey.Bytes in crypto/ecdh.
funcMarshalCompressed¶added ingo1.15
MarshalCompressed converts a point on the curve into the compressed formspecified in SEC 1, Version 2.0, Section 2.3.3. If the point is not on thecurve (or is the conventional point at infinity), the behavior is undefined.
funcUnmarshaldeprecated
Unmarshal converts a point, serialized byMarshal, into an x, y pair. It isan error if the point is not in uncompressed form, is not on the curve, or isthe point at infinity. On error, x = nil.
Deprecated: for ECDH, use the crypto/ecdh package. This function accepts anencoding equivalent to that of the NewPublicKey methods in crypto/ecdh.
funcUnmarshalCompressed¶added ingo1.15
UnmarshalCompressed converts a point, serialized byMarshalCompressed, intoan x, y pair. It is an error if the point is not in compressed form, is noton the curve, or is the point at infinity. On error, x = nil.
Types¶
typeCurve¶
type Curve interface {// Params returns the parameters for the curve.Params() *CurveParams// IsOnCurve reports whether the given (x,y) lies on the curve.//// Deprecated: this is a low-level unsafe API. For ECDH, use the crypto/ecdh// package. The NewPublicKey methods of NIST curves in crypto/ecdh accept// the same encoding as the Unmarshal function, and perform on-curve checks.IsOnCurve(x, y *big.Int)bool// Add returns the sum of (x1,y1) and (x2,y2).//// Deprecated: this is a low-level unsafe API.Add(x1, y1, x2, y2 *big.Int) (x, y *big.Int)// Double returns 2*(x,y).//// Deprecated: this is a low-level unsafe API.Double(x1, y1 *big.Int) (x, y *big.Int)// ScalarMult returns k*(x,y) where k is an integer in big-endian form.//// Deprecated: this is a low-level unsafe API. For ECDH, use the crypto/ecdh// package. Most uses of ScalarMult can be replaced by a call to the ECDH// methods of NIST curves in crypto/ecdh.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.//// Deprecated: this is a low-level unsafe API. For ECDH, use the crypto/ecdh// package. Most uses of ScalarBaseMult can be replaced by a call to the// PrivateKey.PublicKey method in crypto/ecdh.ScalarBaseMult(k []byte) (x, y *big.Int)}A Curve represents a short-form Weierstrass curve with a=-3.
The behavior of Add, Double, and ScalarMult when the input is not a point onthe curve is undefined.
Note that the conventional point at infinity (0, 0) is not considered on thecurve, although it can be returned by Add, Double, ScalarMult, orScalarBaseMult (but not theUnmarshal orUnmarshalCompressed functions).
Using Curve implementations besides those returned byP224,P256,P384,andP521 is deprecated.
funcP224¶
func P224()Curve
P224 returns aCurve which implements NIST P-224 (FIPS 186-3, section D.2.2),also known as secp224r1. The CurveParams.Name of thisCurve is "P-224".
Multiple invocations of this function will return the same value, so it canbe used for equality checks and switch statements.
The cryptographic operations are implemented using constant-time algorithms.
funcP256¶
func P256()Curve
P256 returns aCurve which implements NIST P-256 (FIPS 186-3, section D.2.3),also known as secp256r1 or prime256v1. The CurveParams.Name of thisCurve is"P-256".
Multiple invocations of this function will return the same value, so it canbe used for equality checks and switch statements.
The cryptographic operations are implemented using constant-time algorithms.
funcP384¶
func P384()Curve
P384 returns aCurve which implements NIST P-384 (FIPS 186-3, section D.2.4),also known as secp384r1. The CurveParams.Name of thisCurve is "P-384".
Multiple invocations of this function will return the same value, so it canbe used for equality checks and switch statements.
The cryptographic operations are implemented using constant-time algorithms.
funcP521¶
func P521()Curve
P521 returns aCurve which implements NIST P-521 (FIPS 186-3, section D.2.5),also known as secp521r1. The CurveParams.Name of thisCurve is "P-521".
Multiple invocations of this function will return the same value, so it canbe used for equality checks and switch statements.
The cryptographic operations are implemented using constant-time algorithms.
typeCurveParams¶
type CurveParams struct {P *big.Int// the order of the underlying fieldN *big.Int// the order of the base pointB *big.Int// the constant of the curve equationGx, Gy *big.Int// (x,y) of the base pointBitSizeint// the size of the underlying fieldNamestring// the canonical name of the curve}CurveParams contains the parameters of an elliptic curve and also providesa generic, non-constant time implementation ofCurve.
The generic Curve implementation is deprecated, and using custom curves(those not returned byP224,P256,P384, andP521) is not guaranteedto provide any security property.
func (*CurveParams)Adddeprecated
Add implements [Curve.Add].
Deprecated: theCurveParams methods are deprecated and are not guaranteed toprovide any security property. For ECDH, use thecrypto/ecdh package.For ECDSA, use thecrypto/ecdsa package with aCurve value returned directlyfromP224,P256,P384, orP521.
func (*CurveParams)Doubledeprecated
Double implements [Curve.Double].
Deprecated: theCurveParams methods are deprecated and are not guaranteed toprovide any security property. For ECDH, use thecrypto/ecdh package.For ECDSA, use thecrypto/ecdsa package with aCurve value returned directlyfromP224,P256,P384, orP521.
func (*CurveParams)IsOnCurvedeprecated
func (curve *CurveParams) IsOnCurve(x, y *big.Int)bool
IsOnCurve implements [Curve.IsOnCurve].
Deprecated: theCurveParams methods are deprecated and are not guaranteed toprovide any security property. For ECDH, use thecrypto/ecdh package.For ECDSA, use thecrypto/ecdsa package with aCurve value returned directlyfromP224,P256,P384, orP521.
func (*CurveParams)Params¶
func (curve *CurveParams) Params() *CurveParams
func (*CurveParams)ScalarBaseMultdeprecated
ScalarBaseMult implements [Curve.ScalarBaseMult].
Deprecated: theCurveParams methods are deprecated and are not guaranteed toprovide any security property. For ECDH, use thecrypto/ecdh package.For ECDSA, use thecrypto/ecdsa package with aCurve value returned directlyfromP224,P256,P384, orP521.
func (*CurveParams)ScalarMultdeprecated
ScalarMult implements [Curve.ScalarMult].
Deprecated: theCurveParams methods are deprecated and are not guaranteed toprovide any security property. For ECDH, use thecrypto/ecdh package.For ECDSA, use thecrypto/ecdsa package with aCurve value returned directlyfromP224,P256,P384, orP521.