ecc

package module
v2.0.0-...-74eeffd Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "ecc"

Variables

This section is empty.

Functions

This section is empty.

Types

type Curve

type Curve int
const (
	P224 Curve = iota
	P256
	P384
	P521
)

func (Curve) New

func (c Curve) New() elliptic.Curve

type Encryptor

type Encryptor struct {
	// contains filtered or unexported fields
}

func NewEncryptor

func NewEncryptor(opts ...EncryptorOption) *Encryptor

func (*Encryptor) Decrypt

func (e *Encryptor) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt 解密

func (*Encryptor) Encrypt

func (e *Encryptor) Encrypt(data []byte) ([]byte, error)

Encrypt 加密

func (*Encryptor) Name

func (e *Encryptor) Name() string

Name 名称

type EncryptorOption

type EncryptorOption func(o *encryptorOptions)

func WithEncryptorPrivateKey

func WithEncryptorPrivateKey(privateKey string) EncryptorOption

WithEncryptorPrivateKey 设置解密私钥

func WithEncryptorPublicKey

func WithEncryptorPublicKey(publicKey string) EncryptorOption

WithEncryptorPublicKey 设置加密公钥

func WithEncryptorShareInfo

func WithEncryptorShareInfo(s1, s2 string) EncryptorOption

WithEncryptorShareInfo 设置共享信息

type Key

type Key struct {
	// contains filtered or unexported fields
}

func GenerateKey

func GenerateKey(curve Curve) (*Key, error)

GenerateKey 生成秘钥

func (*Key) MarshalPrivateKey

func (k *Key) MarshalPrivateKey() ([]byte, error)

MarshalPrivateKey 编码私钥

func (*Key) MarshalPublicKey

func (k *Key) MarshalPublicKey() ([]byte, error)

MarshalPublicKey 编码公钥

func (*Key) PrivateKey

func (k *Key) PrivateKey() *ecdsa.PrivateKey

PrivateKey 获取私钥

func (*Key) PublicKey

func (k *Key) PublicKey() *ecdsa.PublicKey

PublicKey 获取公钥

func (*Key) SaveKeyPair

func (k *Key) SaveKeyPair(dir string, file string) (err error)

SaveKeyPair 保存秘钥对

type Signer

type Signer struct {
	// contains filtered or unexported fields
}

func NewSigner

func NewSigner(opts ...SignerOption) *Signer

func (*Signer) Name

func (s *Signer) Name() string

Name 名称

func (*Signer) Sign

func (s *Signer) Sign(data []byte) ([]byte, error)

Sign 签名

func (*Signer) Verify

func (s *Signer) Verify(data []byte, signature []byte) (bool, error)

Verify 验签

type SignerOption

type SignerOption func(o *signerOptions)

func WithSignerDelimiter

func WithSignerDelimiter(delimiter string) SignerOption

WithSignerDelimiter 设置签名分割符

func WithSignerHash

func WithSignerHash(hash hash.Hash) SignerOption

WithSignerHash 设置加密hash算法

func WithSignerPrivateKey

func WithSignerPrivateKey(privateKey string) SignerOption

WithSignerPrivateKey 设置解密私钥

func WithSignerPublicKey

func WithSignerPublicKey(publicKey string) SignerOption

WithSignerPublicKey 设置验签公钥

Jump to

Keyboard shortcuts

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