gabikeys

package
v0.0.0-...-202feaa Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: BSD-3-Clause Imports: 14 Imported by: 5

Documentation

Index

Constants

View Source
const (
	//XMLHeader can be a used as the XML header when writing keys in XML format.
	XMLHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
	// DefaultEpochLength is the default epoch length for public keys.
	DefaultEpochLength = 432000
)

Variables

View Source
var (

	// DefaultSystemParameters holds per key length the default parameters as are
	// currently in use at the moment. This might (and probably will) change in the
	// future.
	DefaultSystemParameters = map[int]*SystemParameters{
		1024: {defaultBaseParameters[1024], MakeDerivedParameters(defaultBaseParameters[1024])},
		2048: {defaultBaseParameters[2048], MakeDerivedParameters(defaultBaseParameters[2048])},
		4096: {defaultBaseParameters[4096], MakeDerivedParameters(defaultBaseParameters[4096])},
	}

	// DefaultKeyLengths is a slice of integers holding the key lengths for which
	// system parameters are available.
	DefaultKeyLengths = getAvailableKeyLengths(DefaultSystemParameters)
)

defaultBaseParameters holds per key length the base parameters.

Functions

func GenerateKeyPair

func GenerateKeyPair(param *SystemParameters, numAttributes int, counter uint, expiryDate time.Time) (*PrivateKey, *PublicKey, error)

GenerateKeyPair generates a private/public keypair for an Issuer

func GenerateRevocationKeypair

func GenerateRevocationKeypair(privk *PrivateKey, pubk *PublicKey) error

Types

type BaseParameters

type BaseParameters struct {
	LePrime uint
	Lh      uint
	Lm      uint
	Ln      uint
	Lstatzk uint
}

BaseParameters holds the base system parameters

type Bases

type Bases []*big.Int

func (*Bases) MarshalXML

func (bl *Bases) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML is an internal function to simplify encoding a PublicKey to XML.

func (*Bases) UnmarshalXML

func (bl *Bases) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML is an internal function to simplify decoding a PublicKey from XML.

type DerivedParameters

type DerivedParameters struct {
	Le            uint
	LeCommit      uint
	LmCommit      uint
	LRA           uint
	LsCommit      uint
	Lv            uint
	LvCommit      uint
	LvPrime       uint
	LvPrimeCommit uint
}

DerivedParameters holds system parameters that can be derived from base system parameters (BaseParameters)

func MakeDerivedParameters

func MakeDerivedParameters(base BaseParameters) DerivedParameters

MakeDerivedParameters computes the derived system parameters

type EpochLength

type EpochLength int

func (*EpochLength) MarshalXML

func (el *EpochLength) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML is an internal function to simplify encoding a PublicKey to XML.

func (*EpochLength) UnmarshalXML

func (el *EpochLength) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML is an internal function to simplify decoding a PublicKey from XML.

type PrivateKey

type PrivateKey struct {
	XMLName     xml.Name `xml:"http://www.zurich.ibm.com/security/idemix IssuerPrivateKey"`
	Counter     uint     `xml:"Counter"`
	ExpiryDate  int64    `xml:"ExpiryDate"`
	P           *big.Int `xml:"Elements>p"`
	Q           *big.Int `xml:"Elements>q"`
	PPrime      *big.Int `xml:"Elements>pPrime"`
	QPrime      *big.Int `xml:"Elements>qPrime"`
	ECDSAString string   `xml:"ECDSA,omitempty"`

	N     *big.Int          `xml:"-"`
	ECDSA *ecdsa.PrivateKey `xml:"-"`
	Order *big.Int          `xml:"-"`
}

PrivateKey represents an issuer's private key.

func NewPrivateKey

func NewPrivateKey(p, q *big.Int, ecdsa string, counter uint, expiryDate time.Time) (*PrivateKey, error)

NewPrivateKey creates a new issuer private key using the provided parameters.

func NewPrivateKeyFromFile

func NewPrivateKeyFromFile(filename string, demo bool) (*PrivateKey, error)

NewPrivateKeyFromFile creates a new issuer private key from an XML file.

func NewPrivateKeyFromXML

func NewPrivateKeyFromXML(xmlInput string, demo bool) (*PrivateKey, error)

NewPrivateKeyFromXML creates a new issuer private key using the XML data provided.

func (*PrivateKey) Print

func (privk *PrivateKey) Print() error

Print prints the key to stdout.

func (*PrivateKey) RevocationSupported

func (privk *PrivateKey) RevocationSupported() bool

func (*PrivateKey) Validate

func (privk *PrivateKey) Validate() error

func (*PrivateKey) WriteTo

func (privk *PrivateKey) WriteTo(writer io.Writer) (int64, error)

WriteTo writes the XML-serialized public key to the given writer.

func (*PrivateKey) WriteToFile

func (privk *PrivateKey) WriteToFile(filename string, forceOverwrite bool) (int64, error)

WriteToFile writes the private key to an XML file. If any existing file with the same filename should be overwritten, set forceOverwrite to true.

type PublicKey

type PublicKey struct {
	XMLName     xml.Name    `xml:"http://www.zurich.ibm.com/security/idemix IssuerPublicKey"`
	Counter     uint        `xml:"Counter"`
	ExpiryDate  int64       `xml:"ExpiryDate"`
	N           *big.Int    `xml:"Elements>n"` // Modulus n
	Z           *big.Int    `xml:"Elements>Z"` // Generator Z
	S           *big.Int    `xml:"Elements>S"` // Generator S
	G           *big.Int    `xml:"Elements>G"` // Generator G for revocation
	H           *big.Int    `xml:"Elements>H"` // Generator H for revocation
	R           Bases       `xml:"Elements>Bases"`
	EpochLength EpochLength `xml:"Features"`
	ECDSAString string      `xml:"ECDSA,omitempty"`

	ECDSA  *ecdsa.PublicKey  `xml:"-"`
	Params *SystemParameters `xml:"-"`
	Issuer string            `xml:"-"`
}

PublicKey represents an issuer's public key.

func NewPublicKey

func NewPublicKey(N, Z, S, G, H *big.Int, R []*big.Int, ecdsa string, counter uint, expiryDate time.Time) (*PublicKey, error)

NewPublicKey creates and returns a new public key based on the provided parameters.

func NewPublicKeyFromBytes

func NewPublicKeyFromBytes(bts []byte) (*PublicKey, error)

NewPublicKeyFromBytes creates a new issuer public key using the XML data provided.

func NewPublicKeyFromFile

func NewPublicKeyFromFile(filename string) (*PublicKey, error)

NewPublicKeyFromFile creates a new issuer public key from an XML file.

func NewPublicKeyFromXML

func NewPublicKeyFromXML(xmlInput string) (*PublicKey, error)

func (*PublicKey) Base

func (pubk *PublicKey) Base(name string) *big.Int

func (*PublicKey) Exp

func (pubk *PublicKey) Exp(ret *big.Int, name string, exp, n *big.Int) bool

func (*PublicKey) Names

func (pubk *PublicKey) Names() []string

func (*PublicKey) Print

func (pubk *PublicKey) Print() error

Print prints the key to stdout.

func (*PublicKey) RevocationSupported

func (pubk *PublicKey) RevocationSupported() bool

func (*PublicKey) WriteTo

func (pubk *PublicKey) WriteTo(writer io.Writer) (int64, error)

WriteTo writes the XML-serialized public key to the given writer.

func (*PublicKey) WriteToFile

func (pubk *PublicKey) WriteToFile(filename string, forceOverwrite bool) (int64, error)

WriteToFile writes the public key to an XML file. If any existing file with the same filename should be overwritten, set forceOverwrite to true.

type SystemParameters

type SystemParameters struct {
	BaseParameters
	DerivedParameters
}

SystemParameters holds the system parameters of the IRMA system.

Jump to

Keyboard shortcuts

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