Movatterモバイル変換


[0]ホーム

URL:


elliptic

packagestandard library
go1.25.5Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License:BSD-3-ClauseImports:5Imported by:32,487

Details

Repository

cs.opensource.google/go/go

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

Constants

This section is empty.

Variables

This section is empty.

Functions

funcGenerateKeydeprecated

func GenerateKey(curveCurve, randio.Reader) (priv []byte, x, y *big.Int, errerror)

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

func Marshal(curveCurve, x, y *big.Int) []byte

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.

funcMarshalCompressedadded ingo1.15

func MarshalCompressed(curveCurve, x, y *big.Int) []byte

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

func Unmarshal(curveCurve, data []byte) (x, y *big.Int)

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.

funcUnmarshalCompressedadded ingo1.15

func UnmarshalCompressed(curveCurve, data []byte) (x, y *big.Int)

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

func (curve *CurveParams) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)

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

func (curve *CurveParams) Double(x1, y1 *big.Int) (*big.Int, *big.Int)

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

func (curve *CurveParams) ScalarBaseMult(k []byte) (*big.Int, *big.Int)

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

func (curve *CurveParams) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int)

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.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp