Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeneratePrivateKey ¶
func GeneratePrivateKey(keystorePath string) (*ecdsa.PrivateKey, error)
GeneratePrivateKey 传入存储私钥的目录地址,利用 ecdsa.GenerateKey(elliptic.P256(), rand.Reader) 方法随机生成一个私钥, 然后将该私钥转换为 ASN.1 DER PEM 编码格式,存储到文件中,然后返回 *ecdsa.PrivateKey。
func LoadPrivateKey ¶
func LoadPrivateKey(keystorePath string) (*ecdsa.PrivateKey, error)
LoadPrivateKey 给定一个存储 ecdsa 私钥的目录路径,从中加载一个 ecdsa 私钥,返回 *ecdsa.PrivateKey。
Types ¶
type ECDSASigner ¶
type ECDSASigner struct {
PrivateKey *ecdsa.PrivateKey
}
func (*ECDSASigner) Public ¶
func (signer *ECDSASigner) Public() crypto.PublicKey
Public 返回 *ecdsa.Public。
func (*ECDSASigner) Sign ¶
func (signer *ECDSASigner) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)
Sign 执行以下步骤得到签名:
- r, s, _ := ecdsa.Sign(rand.Reader, key, digest)
- sig, err := bccsp.MarshalECDSASignature(r, s)
- return sig, err
Click to show internal directories.
Click to hide internal directories.