Documentation
¶
Overview ¶
パッケージellipticは、素数体上の標準的なNIST P-224、P-256、P-384、およびP-521楕円曲線を実装しています。
このパッケージの直接使用は非推奨であり、P224、P256、P384、[P521]の値は[crypto/ecdsa]を使用するために必要です。その他のほとんどの用途は、効率的かつ安全な[crypto/ecdh]または低レベルな機能のためのサードパーティのモジュールに移行する必要があります。
Index ¶
- func GenerateKey(curve Curve, rand io.Reader) (priv []byte, x, y *big.Int, err error)
- func Marshal(curve Curve, x, y *big.Int) []byte
- func MarshalCompressed(curve Curve, x, y *big.Int) []byte
- func Unmarshal(curve Curve, data []byte) (x, y *big.Int)
- 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)
- func (curve *CurveParams) Double(x1, y1 *big.Int) (*big.Int, *big.Int)
- func (curve *CurveParams) IsOnCurve(x, y *big.Int) booldeprecated
- func (curve *CurveParams) Params() *CurveParams
- func (curve *CurveParams) ScalarBaseMult(k []byte) (*big.Int, *big.Int)
- 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 ¶
func GenerateKey ¶
GenerateKeyは公開鍵と秘密鍵のペアを生成します。秘密鍵は与えられたリーダーを使用して生成されますが、ランダムデータを返す必要があります。 廃止予定: ECDHの場合はcrypto/ecdhパッケージのGenerateKeyメソッドを使用してください。 ECDSAの場合はcrypto/ecdsaパッケージのGenerateKey関数を使用してください。
func Marshal ¶
Marshalは、曲線上の点を、SEC 1、バージョン2.0、セクション2.3.3で指定された非圧縮形式に変換します。もし点が曲線上にない場合(または通常の無限遠点の場合)、動作は未定義です。
廃止されました:ECDHには、crypto/ecdhパッケージを使用してください。この関数は、crypto/ecdhのPublicKey.Bytesと同等のエンコーディングを返します。
func MarshalCompressed ¶ added in v1.15.0
MarshalCompressedは、曲線上の点をSEC 1、バージョン2.0、セクション2.3.3で指定された圧縮形式に変換します。点が曲線上にない場合(または無限遠点である場合)、動作は未定義です。
Types ¶
type Curve ¶
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) }
Curveはa=-3の短形式Weierstrass曲線を表します。
入力が曲線上の点でない場合、Add、Double、およびScalarMultの動作は未定義です。
0, 0のような通常の無限遠点は、曲線上には考慮されていませんが、Add、Double、 ScalarMult、またはScalarBaseMultで返される場合があります (ただし、UnmarshalまたはUnmarshalCompressed関数では返されません)。
P224()、P256()、P384()、およびP521()以外のCurve実装を使用することは非推奨です。
func P224 ¶
func P224() Curve
P224は、NIST P-224(FIPS 186-3、セクションD.2.2)で実装された曲線、またはsecp224r1としても知られています。この曲線のCurveParams.Nameは「P-224」です。
この関数の複数の呼び出しは同じ値を返すため、等価性のチェックやスイッチ文に使用することができます。
暗号操作は一定の時間で実装されています。
func P256 ¶
func P256() Curve
P256は、NIST P-256(FIPS 186-3、セクション D.2.3)またはsecp256r1またはprime256v1としても知られる、 "P-256"という名前のCurveParams.Nameを実装したCurveを返します。
この関数を複数回呼び出しても同じ値が返されるため、等値チェックやswitch文で使用することができます。
暗号操作は定数時間アルゴリズムを使用して実装されています。
type CurveParams ¶
type CurveParams struct { P *big.Int N *big.Int B *big.Int Gx, Gy *big.Int BitSize int Name string }
CurveParamsは楕円曲線のパラメータを含み、Curveの汎用で非定数時間の実装も提供します。
汎用のCurve実装は非推奨であり、カスタム曲線(P224()、P256()、P384()、P521()によって返されない曲線)を使用することは、 いかなるセキュリティプロパティも保証しないことに注意してください。
func (*CurveParams) Add ¶
AddはCurve.Addを実装します。
廃止予定: CurveParamsのメソッドは廃止予定であり、何のセキュリティプロパティも保証されません。 ECDHについては、crypto/ecdhパッケージを使用してください。 ECDSAについては、直接P224()、P256()、P384()、またはP521()から返されるCurve値と一緒にcrypto/ecdsaパッケージを使用してください。
func (*CurveParams) Double ¶
DoubleはCurve.Doubleを実装します。
廃止予定: CurveParamsメソッドは廃止予定であり、セキュリティプロパティを提供することを保証しません。 ECDHにはcrypto/ecdhパッケージを使用してください。 ECDSAには、直接P224()、P256()、P384()、またはP521()から返されるCurveの値を使用してcrypto/ecdsaパッケージを使用してください。
func (*CurveParams) IsOnCurve
deprecated
func (curve *CurveParams) IsOnCurve(x, y *big.Int) bool
IsOnCurveはCurve.IsOnCurveを実装します。
Deprecated: CurveParamsのメソッドは非推奨であり、任意のセキュリティプロパティを提供することは保証されていません。 ECDHにはcrypto/ecdhパッケージを使用してください。 ECDSAには、P224()、P256()、P384()、またはP521()から直接返されるCurve値を使用して、crypto/ecdsaパッケージを使用してください。
func (*CurveParams) Params ¶
func (curve *CurveParams) Params() *CurveParams
func (*CurveParams) ScalarBaseMult ¶
ScalarBaseMultはCurve.ScalarBaseMultを実装します。
廃止予定: CurveParamsメソッドは廃止されており、安全性を保証するものではありません。 ECDHにはcrypto/ecdhパッケージを使用してください。 ECDSAにはP224()、P256()、P384()またはP521()から直接返されるCurve値を使用して、crypto/ecdsaパッケージを使用してください。