目录 搜索
archive archive/tar archive/zip bufio bufio(缓存) builtin builtin(内置包) bytes bytes(包字节) compress compress/bzip2(压缩/bzip2) compress/flate(压缩/flate) compress/gzip(压缩/gzip) compress/lzw(压缩/lzw) compress/zlib(压缩/zlib) container container/heap(容器数据结构heap) container/list(容器数据结构list) container/ring(容器数据结构ring) context context(上下文) crypto crypto(加密) crypto/aes(加密/aes) crypto/cipher(加密/cipher) crypto/des(加密/des) crypto/dsa(加密/dsa) crypto/ecdsa(加密/ecdsa) crypto/elliptic(加密/elliptic) crypto/hmac(加密/hmac) crypto/md5(加密/md5) crypto/rand(加密/rand) crypto/rc4(加密/rc4) crypto/rsa(加密/rsa) crypto/sha1(加密/sha1) crypto/sha256(加密/sha256) crypto/sha512(加密/sha512) crypto/subtle(加密/subtle) crypto/tls(加密/tls) crypto/x509(加密/x509) crypto/x509/pkix(加密/x509/pkix) database database/sql(数据库/sql) database/sql/driver(数据库/sql/driver) debug debug/dwarf(调试/dwarf) debug/elf(调试/elf) debug/gosym(调试/gosym) debug/macho(调试/macho) debug/pe(调试/pe) debug/plan9obj(调试/plan9obj) encoding encoding(编码) encoding/ascii85(编码/ascii85) encoding/asn1(编码/asn1) encoding/base32(编码/base32) encoding/base64(编码/base64) encoding/binary(编码/binary) encoding/csv(编码/csv) encoding/gob(编码/gob) encoding/hex(编码/hex) encoding/json(编码/json) encoding/pem(编码/pem) encoding/xml(编码/xml) errors errors(错误) expvar expvar flag flag(命令行参数解析flag包) fmt fmt go go/ast(抽象语法树) go/build go/constant(常量) go/doc(文档) go/format(格式) go/importer go/parser go/printer go/scanner(扫描仪) go/token(令牌) go/types(类型) hash hash(散列) hash/adler32 hash/crc32 hash/crc64 hash/fnv html html html/template(模板) image image(图像) image/color(颜色) image/color/palette(调色板) image/draw(绘图) image/gif image/jpeg image/png index index/suffixarray io io io/ioutil log log log/syslog(日志系统) math math math/big math/big math/bits math/bits math/cmplx math/cmplx math/rand math/rand mime mime mime/multipart(多部分) mime/quotedprintable net net net/http net/http net/http/cgi net/http/cookiejar net/http/fcgi net/http/httptest net/http/httptrace net/http/httputil net/http/internal net/http/pprof net/mail net/mail net/rpc net/rpc net/rpc/jsonrpc net/smtp net/smtp net/textproto net/textproto net/url net/url os os os/exec os/signal os/user path path path/filepath(文件路径) plugin plugin(插件) reflect reflect(反射) regexp regexp(正则表达式) regexp/syntax runtime runtime(运行时) runtime/debug(调试) runtime/internal/sys runtime/pprof runtime/race(竞争) runtime/trace(执行追踪器) sort sort(排序算法) strconv strconv(转换) strings strings(字符串) sync sync(同步) sync/atomic(原子操作) syscall syscall(系统调用) testing testing(测试) testing/iotest testing/quick text text/scanner(扫描文本) text/tabwriter text/template(定义模板) text/template/parse time time(时间戳) unicode unicode unicode/utf16 unicode/utf8 unsafe unsafe
文字

  • import "crypto/elliptic"

  • 概述

  • 索引

概述

椭圆包实现了在素数域上的几个标准椭圆曲线。

索引

  • 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

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

Marshal 将点转换为 ANSI X9.62 的4.3.6节中指定的形式。

func Unmarshal

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

Unmarshal将由Marshal序列化的点转换为x,y对。如果该点不在曲线上,这是一个错误。出错时,x =nil。

type Curve

曲线代表a=-3的短型Weierstrass曲线。请参阅http://www.hyperelliptic.org/EFD/g1p/auto-shortw.html

type Curve interface {        // Params返回曲线的参数。        Params() *CurveParams        // IsOnCurve报告给定的(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)的数字。        ScalarMult(x1, y1 *big.Int, k []byte) (x, y *big.Int)        // ScalarBaseMult返回 k*G, G是组的基点。        // k是大端形式的整数。        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 // 基础领域的顺序
        N       *big.Int // 基点的顺序
        B       *big.Int // 曲线方程的常数
        Gx, Gy  *big.Int // (x,y)的基点
        BitSize int      // 底层字段的大小
        Name    string   // 曲线的规范名称}

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)
上一篇: 下一篇: