p521

package
v1.0.0-pre1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: Apache-2.0, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PublicKeyBytesSize is the size, in bytes, of public keys in raw bytes.
	PublicKeyBytesSize = 1 + coordinateSize
	// PrivateKeyBytesSize is the size, in bytes, of private keys in raw bytes.
	PrivateKeyBytesSize = coordinateSize
	// SignatureBytesSize is the size, in bytes, of signatures in raw bytes.
	SignatureBytesSize = 2 * coordinateSize

	MultibaseCode = uint64(0x1202)
)

Variables

This section is empty.

Functions

func GenerateKeyPair

func GenerateKeyPair() (*PublicKey, *PrivateKey, error)

Types

type PrivateKey

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

func PrivateKeyFromBytes

func PrivateKeyFromBytes(b []byte) (*PrivateKey, error)

PrivateKeyFromBytes converts a serialized public key to a PrivateKey. This compact serialization format is the raw key material, without metadata or structure. It errors if the slice is not the right size.

func PrivateKeyFromPKCS8DER

func PrivateKeyFromPKCS8DER(bytes []byte) (*PrivateKey, error)

PrivateKeyFromPKCS8DER decodes a PKCS#8 DER (binary) encoded private key.

func PrivateKeyFromPKCS8PEM

func PrivateKeyFromPKCS8PEM(str string) (*PrivateKey, error)

PrivateKeyFromPKCS8PEM decodes an PKCS#8 PEM (string) encoded private key.

func (*PrivateKey) Equal

func (p *PrivateKey) Equal(other crypto.PrivateKey) bool

func (*PrivateKey) KeyExchange

func (p *PrivateKey) KeyExchange(remote crypto.PublicKey) ([]byte, error)

func (*PrivateKey) Public

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

func (*PrivateKey) PublicKeyIsCompatible

func (p *PrivateKey) PublicKeyIsCompatible(remote crypto.PublicKey) bool

func (*PrivateKey) SignToASN1

func (p *PrivateKey) SignToASN1(message []byte, opts ...crypto.SigningOption) ([]byte, error)

The default signing hash is SHA-512.

func (*PrivateKey) SignToBytes

func (p *PrivateKey) SignToBytes(message []byte, opts ...crypto.SigningOption) ([]byte, error)

The default signing hash is SHA-512.

func (*PrivateKey) ToBytes

func (p *PrivateKey) ToBytes() []byte

func (*PrivateKey) ToPKCS8DER

func (p *PrivateKey) ToPKCS8DER() []byte

func (*PrivateKey) ToPKCS8PEM

func (p *PrivateKey) ToPKCS8PEM() string

func (*PrivateKey) Varsig

func (p *PrivateKey) Varsig(opts ...crypto.SigningOption) varsig.Varsig

The default signing hash is SHA-512.

type PublicKey

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

func PublicKeyFromBytes

func PublicKeyFromBytes(b []byte) (*PublicKey, error)

PublicKeyFromBytes converts a serialized public key to a PublicKey. This compact serialization format is the raw key material, without metadata or structure. It errors if the slice is not the right size.

func PublicKeyFromPublicKeyMultibase

func PublicKeyFromPublicKeyMultibase(multibase string) (*PublicKey, error)

PublicKeyFromPublicKeyMultibase decodes the public key from its Multibase form

func PublicKeyFromX509DER

func PublicKeyFromX509DER(bytes []byte) (*PublicKey, error)

PublicKeyFromX509DER decodes an X.509 DER (binary) encoded public key.

func PublicKeyFromX509PEM

func PublicKeyFromX509PEM(str string) (*PublicKey, error)

PublicKeyFromX509PEM decodes an X.509 PEM (string) encoded public key.

func PublicKeyFromXY

func PublicKeyFromXY(x, y []byte) (*PublicKey, error)

PublicKeyFromXY converts x and y coordinates into a PublicKey.

func (*PublicKey) Equal

func (p *PublicKey) Equal(other crypto.PublicKey) bool

func (*PublicKey) ToBytes

func (p *PublicKey) ToBytes() []byte

func (*PublicKey) ToPublicKeyMultibase

func (p *PublicKey) ToPublicKeyMultibase() string

func (*PublicKey) ToX509DER

func (p *PublicKey) ToX509DER() []byte

func (*PublicKey) ToX509PEM

func (p *PublicKey) ToX509PEM() string

func (*PublicKey) VerifyASN1

func (p *PublicKey) VerifyASN1(message, signature []byte, opts ...crypto.SigningOption) bool

The default signing hash is SHA-512.

func (*PublicKey) VerifyBytes

func (p *PublicKey) VerifyBytes(message, signature []byte, opts ...crypto.SigningOption) bool

The default signing hash is SHA-512.

func (*PublicKey) XBytes

func (p *PublicKey) XBytes() []byte

func (*PublicKey) YBytes

func (p *PublicKey) YBytes() []byte

Jump to

Keyboard shortcuts

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