?
Dieses Dokument verwendet PHP-Handbuch für chinesische Websites Freigeben
import "crypto/ecdsa"
概述
索引
軟件包 ecdsa 使用 FIPS 186-3 中定義的橢圓曲線數字簽名算法。
此實現從由 ChopMD(256, SHA2-512(priv.D || entropy || hash)) 鍵入的 AES-CTR CSPRNG 派生 nonce。CSPRNG 的關鍵在于 Coro n 的結果是IRO;在標準假設下,AES-CTR 流是IRO。
func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err error)
func Verify(pub *PublicKey, hash []byte, r, s *big.Int) bool
type PrivateKey
func GenerateKey(c elliptic.Curve, rand io.Reader) (*PrivateKey, error)
func (priv *PrivateKey) Public() crypto.PublicKey
func (priv *PrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) ([]byte, error)
type PublicKey
ecdsa.go
func Sign(rand io.Reader, priv *PrivateKey, hash []byte) (r, s *big.Int, err error)
簽名使用私鑰 priv 來簽名散列(這應該是散列較大郵件的結果)。如果散列長度大于私鑰的曲線順序的位長度,則散列將被截斷為該長度。它將簽名作為一對整數返回。私鑰的安全性取決于 rand 的熵。
func Verify(pub *PublicKey, hash []byte, r, s *big.Int) bool
驗證使用公共密鑰 pub,驗證散列r,s中的簽名。其返回值記錄簽名是否有效。
PrivateKey 代表 ECDSA 私鑰。
type PrivateKey struct { PublicKey D *big.Int}
func GenerateKey(c elliptic.Curve, rand io.Reader) (*PrivateKey, error)
GenerateKey 生成公鑰和私鑰對。
func (priv *PrivateKey) Public() crypto.PublicKey
公共返回與 priv 相對應的公鑰。
func (priv *PrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) ([]byte, error)
用 priv 簽名 msg,從 rand 中讀取隨機數。此方法旨在支持保留私有部分的密鑰,例如,硬件模塊。常見用法應直接在此包中使用 Sign 函數。
PublicKey 表示 ECDSA 公鑰。
type PublicKey struct { elliptic.Curve X, Y *big.Int}