ecc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2022 License: Apache-2.0 Imports: 19 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 Decryptor

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

func NewDecryptor

func NewDecryptor(opts ...DecryptorOption) *Decryptor

func (*Decryptor) Decrypt

func (d *Decryptor) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt 解密

func (*Decryptor) Name

func (d *Decryptor) Name() string

Name 名称

type DecryptorOption

type DecryptorOption func(o *decryptorOptions)

func WithDecryptorPrivateKey

func WithDecryptorPrivateKey(privateKey string) DecryptorOption

WithDecryptorPrivateKey 设置解密私钥

func WithDecryptorShareInfo

func WithDecryptorShareInfo(s1, s2 string) DecryptorOption

WithDecryptorShareInfo 设置共享信息

type Encryptor

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

func NewEncryptor

func NewEncryptor(opts ...EncryptorOption) *Encryptor

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 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 签名

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 设置解密私钥

type Verifier

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

func NewVerifier

func NewVerifier(opts ...VerifierOption) *Verifier

func (*Verifier) Name

func (v *Verifier) Name() string

Name 名称

func (*Verifier) Verify

func (v *Verifier) Verify(data []byte, signature []byte) (bool, error)

Verify 验签

type VerifierOption

type VerifierOption func(o *verifierOption)

func WithVerifierDelimiter

func WithVerifierDelimiter(delimiter string) VerifierOption

WithVerifierDelimiter 设置签名分割符

func WithVerifierHash

func WithVerifierHash(hash hash.Hash) VerifierOption

WithVerifierHash 设置加密hash算法

func WithVerifierPublicKey

func WithVerifierPublicKey(publicKey string) VerifierOption

WithVerifierPublicKey 设置验签公钥

Jump to

Keyboard shortcuts

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