?
This document uses PHP Chinese website manual Release
import "crypto/elliptic"
概述
索引
橢圓包實(shí)現(xiàn)了在素?cái)?shù)域上的幾個(gè)標(biāo)準(zhǔn)橢圓曲線。
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 Unmarshal(curve Curve, data []byte) (x, y *big.Int)
type Curve
func P224() Curve
func P256() Curve
func P384() Curve
func P521() 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) bool
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)
包文件
elliptic.go p224.go p256_amd64.go
func GenerateKey(curve Curve, rand io.Reader) (priv []byte, x, y *big.Int, err error)
GenerateKey 返回一個(gè)公鑰/私鑰對。私鑰是使用給定的閱讀器生成的,它必須返回隨機(jī)數(shù)據(jù)。
func Marshal(curve Curve, x, y *big.Int) []byte
Marshal 將點(diǎn)轉(zhuǎn)換為 ANSI X9.62 的4.3.6節(jié)中指定的形式。
func Unmarshal(curve Curve, data []byte) (x, y *big.Int)
Unmarshal將由Marshal序列化的點(diǎn)轉(zhuǎn)換為x,y對。如果該點(diǎn)不在曲線上,這是一個(gè)錯(cuò)誤。出錯(cuò)時(shí),x =nil。
曲線代表a=-3的短型Weierstrass曲線。請參閱http://www.hyperelliptic.org/EFD/g1p/auto-shortw.html
type Curve interface { // Params返回曲線的參數(shù)。 Params() *CurveParams // IsOnCurve報(bào)告給定的(x,y)是否在曲線上。 IsOnCurve(x, y *big.Int) bool // Add返回(x1,y1)和(x2,y2)的和 Add(x1, y1, x2, y2 *big.Int) (x, y *big.Int) // Double返回 2*(x,y) Double(x1, y1 *big.Int) (x, y *big.Int) // ScalarMult返回k*(Bx,By)其中k是大端形式(big-endian)的數(shù)字。 ScalarMult(x1, y1 *big.Int, k []byte) (x, y *big.Int) // ScalarBaseMult返回 k*G, G是組的基點(diǎn)。 // k是大端形式的整數(shù)。 ScalarBaseMult(k []byte) (x, y *big.Int)}
func P224() Curve
P224返回一個(gè)實(shí)現(xiàn)P-224的曲線(參見FIPS 186-3,D.2.2節(jié))。
密碼操作使用恒定時(shí)間算法實(shí)現(xiàn)。
func P256() Curve
P256 返回一個(gè)實(shí)現(xiàn) P-256 的曲線(參見 FIPS 186-3,D.2.3節(jié))
密碼操作使用恒定時(shí)間算法實(shí)現(xiàn)。
func P384() Curve
P384 返回一個(gè)實(shí)現(xiàn) P-384 的曲線(參見 FIPS 186-3,D.2.4節(jié))
加密操作不使用恒定時(shí)間算法。
func P521() Curve
P521 返回一個(gè)實(shí)現(xiàn) P-521 的曲線(參見 FIPS 186-3,D.2.5 節(jié))
加密操作不使用恒定時(shí)間算法。
CurveParams 包含一個(gè)橢圓曲線的參數(shù),并且還提供了一個(gè)通用的,非常量的 Curve 實(shí)現(xiàn)。
type CurveParams struct { P *big.Int // 基礎(chǔ)領(lǐng)域的順序 N *big.Int // 基點(diǎn)的順序 B *big.Int // 曲線方程的常數(shù) Gx, Gy *big.Int // (x,y)的基點(diǎn) BitSize int // 底層字段的大小 Name string // 曲線的規(guī)范名稱}
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) bool
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)