identity

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 11 Imported by: 32

Documentation

Overview

Package identity defines a client identity and signing implementation used to interact with a Fabric network.

This package provides utilities to aid creation of client identities and accompanying signing implementations from various types of credentials.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CertificateFromPEM

func CertificateFromPEM(certificatePEM []byte) (*x509.Certificate, error)

CertificateFromPEM creates an X.509 certificate from PEM encoded data.

func CertificateToPEM

func CertificateToPEM(certificate *x509.Certificate) ([]byte, error)

CertificateToPEM converts an X.509 certificate to PEM encoded ASN.1 DER data.

func PrivateKeyFromPEM

func PrivateKeyFromPEM(privateKeyPEM []byte) (crypto.PrivateKey, error)

PrivateKeyFromPEM creates a private key from PEM encoded data.

func PrivateKeyToPEM

func PrivateKeyToPEM(privateKey crypto.PrivateKey) ([]byte, error)

PrivateKeyToPEM converts a private key to PEM encoded PKCS #8 data.

Types

type Identity

type Identity interface {
	MspID() string       // ID of the Membership Service Provider to which this identity belongs.
	Credentials() []byte // Implementation-specific credentials.
}

Identity represents a client identity used to interact with a Fabric network.

type Sign

type Sign = func(digest []byte) ([]byte, error)

Sign function generates a digital signature of the supplied digest.

func NewPrivateKeySign

func NewPrivateKeySign(privateKey crypto.PrivateKey) (Sign, error)

NewPrivateKeySign returns a Sign function that uses the supplied private key.

Currently supported private key types are: - ECDSA. - Ed25519.

Note that the Sign implementations have different expectations on the input data supplied to them.

The ECDSA signers operate on a pre-computed message digest, and should be combined with an appropriate hash algorithm. P-256 is typically used with a SHA-256 hash, and P-384 is typically used with a SHA-384 hash.

The Ed25519 signer operates on the full message content, and should be combined with a NONE (or no-op) hash implementation to ensure the complete message is passed to the signer.

type X509Identity

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

X509Identity represents a client identity backed by an X.509 certificate.

func NewX509Identity

func NewX509Identity(mspID string, certificate *x509.Certificate) (*X509Identity, error)

NewX509Identity creates a new Identity from an X.509 certificate.

func (*X509Identity) Credentials

func (id *X509Identity) Credentials() []byte

Credentials as an X.509 certificate in PEM encoded ASN.1 DER format.

func (*X509Identity) MspID

func (id *X509Identity) MspID() string

MspID returns the ID of the Membership Service Provider to which this identity belongs.

Jump to

Keyboard shortcuts

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