cryptogen

package
v0.0.0-...-b88e555 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ECDSA   = "ecdsa"
	ED25519 = "ed25519"

	CertType       = "CERTIFICATE"
	PrivateKeyType = "PRIVATE KEY"

	PrivateKeySuffix = "_sk"
	PrivateKeyFile   = "priv" + PrivateKeySuffix
	CertFileExt      = ".pem"
	CertSuffix       = "-cert" + CertFileExt
)

Common constants.

View Source
const (
	MSPDir        = "msp"
	TLSDir        = "tls"
	CACertsDir    = "cacerts"
	TLSCaCertsDir = "tlscacerts"
	KeyStoreDir   = "keystore"
	AdminCertsDir = "admincerts"
	SignCertsDir  = "signcerts"
	KnownCertsDir = "knowncerts"
)

Directories.

View Source
const (
	ConfigFile   = "config.yaml"
	CaCertFile   = "ca.crt"
	ServerPrefix = "server"
	ClientPrefix = "client"
)

Files.

View Source
const (
	AdminOU   = "admin"
	ClientOU  = "client"
	OrdererOU = "orderer"
	PeerOU    = "peer"
)

Organizational units.

View Source
const (
	CaDir                   = "ca"
	UsersDir                = "users"
	TLSCaDir                = "tlsca"
	PeerNodesDir            = "peers"
	OrdererNodesDir         = "orderers"
	OrdererOrganizationsDir = "ordererOrganizations"
	PeerOrganizationsDir    = "peerOrganizations"
	GenericOrganizationsDir = "organizations"

	TLSCaPrefix = "tls"

	DefaultCaHostname = "ca"
)

Tree names.

Variables

This section is empty.

Functions

func CreateDefaultConfigBlockWithCrypto

func CreateDefaultConfigBlockWithCrypto(conf ConfigBlockParameters) (*common.Block, error)

CreateDefaultConfigBlockWithCrypto creates a config block with default values and a crypto material. It uses the first orderer organization as a template and creates the given organizations. It uses the same organizations for the orderer and the application.

func Extend

func Extend(rootDir string, config *Config) error

Extend extends a crypto in the given directory using the given config.

func Generate

func Generate(rootDir string, config *Config) error

Generate generates crypto in the given directory using the given config.

func LoadSampleConfig

func LoadSampleConfig(profile string) (*configtxgen.Profile, error)

LoadSampleConfig returns the orderer/application config combination that corresponds to a given profile.

Types

type Config

type Config struct {
	OrdererOrgs []OrgSpec `yaml:"OrdererOrgs"`
	PeerOrgs    []OrgSpec `yaml:"PeerOrgs"`
	GenericOrgs []OrgSpec `yaml:"GenericOrgs"`
}

Config represents the orderer/peer organization to be generated.

func ParseConfig

func ParseConfig(configData string) (*Config, error)

ParseConfig parses config data from string.

type ConfigBlockParameters

type ConfigBlockParameters struct {
	TargetPath                   string
	BaseProfile                  string
	ChannelID                    string
	Organizations                []OrganizationParameters
	MetaNamespaceVerificationKey []byte
	ArmaMetaBytes                []byte
}

ConfigBlockParameters represents the configuration of the config block.

type ECDSASignature

type ECDSASignature struct {
	R, S *big.Int
}

ECDSASignature represents a signature.

type ECDSASigner

type ECDSASigner struct {
	PrivateKey *ecdsa.PrivateKey
}

ECDSASigner ECDSA signer implements the crypto.Signer interface for ECDSA keys. The Sign method ensures signatures are created with Low S values since Fabric normalizes all signatures to Low S. See https://github.com/bitcoin/bips/blob/master/bip-0146.mediawiki#low_s for more detail.

func (*ECDSASigner) Public

func (e *ECDSASigner) Public() crypto.PublicKey

Public returns the ecdsa.PublicKey associated with PrivateKey.

func (*ECDSASigner) Sign

func (e *ECDSASigner) Sign(randReader io.Reader, digest []byte, _ crypto.SignerOpts) ([]byte, error)

Sign signs the digest and ensures that signatures use the Low S value.

type ED25519Signer

type ED25519Signer struct {
	PrivateKey ed25519.PrivateKey
}

ED25519Signer represents the signer.

func (*ED25519Signer) Public

func (e *ED25519Signer) Public() crypto.PublicKey

Public returns the ed25519.PublicKey associated with PrivateKey.

func (*ED25519Signer) Sign

func (e *ED25519Signer) Sign(_ io.Reader, msg []byte, _ crypto.SignerOpts) ([]byte, error)

Sign signs the digest.

type Node

type Node struct {
	CommonName string
	Hostname   string
	Party      string
	SANS       []string
}

Node describe an organization node.

type NodeSpec

type NodeSpec struct {
	Hostname           string   `yaml:"Hostname"`
	CommonName         string   `yaml:"CommonName"`
	Country            string   `yaml:"Country"`
	Province           string   `yaml:"Province"`
	Locality           string   `yaml:"Locality"`
	OrganizationalUnit string   `yaml:"OrganizationalUnit"`
	StreetAddress      string   `yaml:"StreetAddress"`
	PostalCode         string   `yaml:"PostalCode"`
	SANS               []string `yaml:"SANS"`
	PublicKeyAlgorithm string   `yaml:"PublicKeyAlgorithm"`
	Party              string   `yaml:"Party"`
}

NodeSpec represents a certificate specification for a node.

type NodeTemplate

type NodeTemplate struct {
	Count              int      `yaml:"Count"`
	Start              int      `yaml:"Start"`
	Hostname           string   `yaml:"Hostname"`
	SANS               []string `yaml:"SANS"`
	PublicKeyAlgorithm string   `yaml:"PublicKeyAlgorithm"`
}

NodeTemplate represents a template to generate node(s).

type OrdererEndpoint

type OrdererEndpoint struct {
	Address string
	API     []string
}

OrdererEndpoint address should be in the format of <host>:<port>, not the full types.OrdererEndpoint format.

type OrgSpec

type OrgSpec struct {
	Name          string       `yaml:"Name"`
	Domain        string       `yaml:"Domain"`
	EnableNodeOUs bool         `yaml:"EnableNodeOUs"`
	CA            NodeSpec     `yaml:"CA"`
	Template      NodeTemplate `yaml:"Template"`
	Specs         []NodeSpec   `yaml:"Specs"`
	Users         UsersSpec    `yaml:"Users"`
}

OrgSpec represents the organization specification.

type OrganizationParameters

type OrganizationParameters struct {
	Name             string
	Domain           string
	OrdererEndpoints []OrdererEndpoint
	ConsenterNodes   []Node
	OrdererNodes     []Node
	PeerNodes        []Node
}

OrganizationParameters represents the properties of an organization. The Name field will also be used for MspID and organization ID.

type UserSpec

type UserSpec struct {
	Name               string `yaml:"Name"`
	PublicKeyAlgorithm string `yaml:"PublicKeyAlgorithm"`
}

UserSpec Contains User specifications needed to customize the crypto material generation.

type UsersSpec

type UsersSpec struct {
	Count              int        `yaml:"Count"`
	PublicKeyAlgorithm string     `yaml:"PublicKeyAlgorithm"`
	Specs              []UserSpec `yaml:"Specs"`
}

UsersSpec represents a user(s) specification.

Jump to

Keyboard shortcuts

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