# package ecdsa
`import "crypto/ecdsa"`
ecdsa包实现了椭圆曲线数字签名算法,参见FIPS 186-3。
## Index
* [type PublicKey](#PublicKey)
* [type PrivateKey](#PrivateKey)
* [func GenerateKey(c elliptic.Curve, rand io.Reader) (priv \*PrivateKey, err error)](#GenerateKey)
* [func Sign(rand io.Reader, priv \*PrivateKey, hash []byte) (r, s \*big.Int, err error)](#Sign)
* [func Verify(pub \*PublicKey, hash []byte, r, s \*big.Int) bool](#Verify)
## type [PublicKey](https://github.com/golang/go/blob/master/src/crypto/ecdsa/ecdsa.go#L22 "View Source")
```
type PublicKey struct {
elliptic.Curve
X, Y *big.Int
}
```
PrivateKey代表一个ECDSA公钥。
## type [PrivateKey](https://github.com/golang/go/blob/master/src/crypto/ecdsa/ecdsa.go#L28 "View Source")
```
type PrivateKey struct {
PublicKey
D *big.Int
}
```
PrivateKey代表一个ECDSA私钥。
### func [GenerateKey](https://github.com/golang/go/blob/master/src/crypto/ecdsa/ecdsa.go#L53 "View Source")
GenerateKey函数生成一对
```
func GenerateKey(c elliptic.Curve, rand io.Reader) (priv *PrivateKey, err error)
```
公钥/私钥。
## func [Sign](https://github.com/golang/go/blob/master/src/crypto/ecdsa/ecdsa.go#L101 "View Source")
```
func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err error)
```
使用私钥对任意长度的hash值(必须是较大信息的hash结果)进行签名,返回签名结果(一对大整数)。私钥的安全性取决于密码读取器的熵度(随机程度)。
## func [Verify](https://github.com/golang/go/blob/master/src/crypto/ecdsa/ecdsa.go#L138 "View Source")
```
func Verify(pub *PublicKey, hash []byte, r, s *big.Int) bool
```
使用公钥验证hash值和两个大整数r、s构成的签名,并返回签名是否合法。
- 库
- package achive
- package tar
- package zip
- package bufio
- package builtin
- package bytes
- package compress
- package bzip2
- package flate
- package gzip
- package lzw
- package zlib
- package container
- package heap
- package list
- package ring
- package crypto
- package aes
- package cipher
- package des
- package dsa
- package ecdsa
- package elliptic
- package hmac
- package md5
- package rand
- package rc4
- package rsa
- package sha1
- package sha256
- package sha512
- package subtle
- package tls
- package x509
- package pkix
- package database
- package sql
- package driver
- package encoding
- package ascii85
- package asn1
- package base32
- package base64
- package binary
- package csv
- package gob
- package hex
- package json
- package pem
- package xml
- package errors
- package expvar
- package flag
- package fmt
- package go
- package doc
- package format
- package parser
- package printer
- package hash
- package adler32
- package crc32
- package crc64
- package fnv
- package html
- package template
- package image
- package color
- package palette
- package draw
- package gif
- package jpeg
- package png
- package index
- package suffixarray
- package io
- package ioutil
- package log
- package syslog
- package math
- package big
- package cmplx
- package rand
- package mime
- package multipart
- package net
- package http
- package cgi
- package cookiejar
- package fcgi
- package httptest
- package httputil
- package pprof
- package mail
- package rpc
- package jsonrpc
- package smtp
- package textproto
- package url
- package os
- package exec
- package signal
- package user
- package path
- package filepath
- package reflect
- package regexp
- package runtime
- package cgo
- package debug
- package pprof
- package race
- package sort
- package strconv
- package strings
- package sync
- package atomic
- package text
- package scanner
- package tabwriter
- package template
- package time
- package unicode
- package utf16
- package utf8
- package unsafe