csp

package
v0.0.0-...-e3e94bd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL