egdsa

package
v1.0.3028 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalXMLPrivateKey

func MarshalXMLPrivateKey(key *PrivateKey) ([]byte, error)

func MarshalXMLPublicKey

func MarshalXMLPublicKey(key *PublicKey) ([]byte, error)

func Sign

func Sign(random io.Reader, priv *PrivateKey, hash []byte) (*big.Int, *big.Int, error)

Sign hash

func SignASN1

func SignASN1(rand io.Reader, priv *PrivateKey, hash []byte) ([]byte, error)

SignASN1 signs a hash (which should be the result of hashing a larger message) using the private key, priv. If the hash is longer than the bit-length of the private key's curve order, the hash will be truncated to that length. It returns the ASN.1 encoded signature.

func Verify

func Verify(pub *PublicKey, hash []byte, r, s *big.Int) (bool, error)

Verify hash

func VerifyASN1

func VerifyASN1(pub *PublicKey, hash, sig []byte) (bool, error)

VerifyASN1 verifies the ASN.1 encoded signature, sig, of hash using the public key, pub. Its return value records whether the signature is valid.

Types

type PrivateKey

type PrivateKey struct {
	PublicKey

	X *big.Int
}

egdsa PrivateKey

func GenerateKey

func GenerateKey(random io.Reader, bitsize, probability int) (*PrivateKey, error)

GenerateKey generates egdsa private key according to given bit size and probability.

func ParseXMLPrivateKey

func ParseXMLPrivateKey(der []byte) (*PrivateKey, error)

func (*PrivateKey) Equal

func (priv *PrivateKey) Equal(x crypto.PrivateKey) bool

Equal reports whether priv and x have the same value.

func (*PrivateKey) Public

func (priv *PrivateKey) Public() crypto.PublicKey

Public returns the public key corresponding to priv.

func (*PrivateKey) Sign

func (priv *PrivateKey) Sign(random io.Reader, hash []byte, opts crypto.SignerOpts) (signature []byte, err error)

Signature generates signature over the given hash. It returns signature value consisting of two parts "r" and "s" as byte arrays.

type PublicKey

type PublicKey struct {
	P, G, Y *big.Int
}

egdsa PublicKey

func ParseXMLPublicKey

func ParseXMLPublicKey(der []byte) (*PublicKey, error)

func (*PublicKey) Equal

func (pub *PublicKey) Equal(x crypto.PublicKey) bool

Equal reports whether pub and x have the same value.

func (*PublicKey) Verify

func (pub *PublicKey) Verify(hash, sig []byte) (bool, error)

Verify verifies signature over the given hash and signature values (r & s). It returns true as a boolean value if signature is verify correctly. Otherwise it returns false along with error message.

type XMLKey

type XMLKey struct{}

*

  • egdsa xml密钥 *
  • @create 2024-8-12
  • @author deatil

func NewXMLKey

func NewXMLKey() XMLKey

构造函数

func (XMLKey) MarshalPrivateKey

func (this XMLKey) MarshalPrivateKey(key *PrivateKey) ([]byte, error)

包装私钥

func (XMLKey) MarshalPublicKey

func (this XMLKey) MarshalPublicKey(key *PublicKey) ([]byte, error)

包装公钥

func (XMLKey) ParsePrivateKey

func (this XMLKey) ParsePrivateKey(data []byte) (*PrivateKey, error)

解析私钥

func (XMLKey) ParsePublicKey

func (this XMLKey) ParsePublicKey(data []byte) (*PublicKey, error)

解析公钥

Jump to

Keyboard shortcuts

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