Package elliptic

import "crypto/elliptic"
Overview
Index

Overview ▾

包椭圆实现素数场上的多个标准椭圆曲线.

func GenerateKey

func GenerateKey(curve Curve, rand io.Reader) (priv []byte, x, y *big.Int, err error)

GenerateKey返回一个公钥/私钥对. 私钥是使用给定的读取器生成的,该读取器必须返回随机数据.

func Marshal

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

元帅将点转换为ANSI X9.62第4.3.6节中指定的未压缩形式.

func Unmarshal

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

Unmarshal将由Marshal序列化的点转换为x,y对. 如果该点不是未压缩形式或不在曲线上,则是错误的. 错误时,x =无.

type Curve

曲线代表a = -3的短形式Weierstrass曲线. 参见https://www.hyperelliptic.org/EFD/g1p/auto-shortw.html

type Curve interface {
    // Params returns the parameters for the curve.
    Params() *CurveParams
    // IsOnCurve reports whether the given (x,y) lies on the curve.
    IsOnCurve(x, y *big.Int) bool
    // Add returns the sum of (x1,y1) and (x2,y2)
    Add(x1, y1, x2, y2 *big.Int) (x, y *big.Int)
    // Double returns 2*(x,y)
    Double(x1, y1 *big.Int) (x, y *big.Int)
    // ScalarMult returns k*(Bx,By) where k is a number in big-endian form.
    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.
    ScalarBaseMult(k []byte) (x, y *big.Int)
}

func P224

func P224() Curve

P224返回实现P-224的曲线(请参阅FIPS 186-3,D.2.2节).

加密操作是使用固定时间算法实现的.

func P256

func P256() Curve

P256返回实现P-256的曲线(请参阅FIPS 186-3,D.2.3节)

加密操作是使用固定时间算法实现的.

func P384

func P384() Curve

P384返回实现P-384的曲线(请参阅FIPS 186-3,第D.2.4节)

加密操作不使用固定时间算法.

func P521

func P521() Curve

P521返回实现P-521的曲线(请参阅FIPS 186-3,第D.2.5节)

加密操作不使用固定时间算法.

type CurveParams

CurveParams包含椭圆曲线的参数,还提供Curve的通用,非恒定时间实现.

type CurveParams struct {
    P       *big.Int // the order of the underlying field
    N       *big.Int // the order of the base point
    B       *big.Int // the constant of the curve equation
    Gx, Gy  *big.Int // (x,y) of the base point
    BitSize int      // the size of the underlying field
    Name    string   // the canonical name of the curve; added in Go 1.5
}

func (*CurveParams) Add

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

func (*CurveParams) Double

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

func (*CurveParams) IsOnCurve

func (curve *CurveParams) IsOnCurve(x, y *big.Int) bool

func (*CurveParams) Params

func (curve *CurveParams) Params() *CurveParams

func (*CurveParams) ScalarBaseMult

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

func (*CurveParams) ScalarMult

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

by  ICOPY.SITE