bls

package
v1.2.0-pre-fork6-fix3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregateVerify

func AggregateVerify(signature Signature, hashes [][sha256.Size]byte, keys []PublicKey) (bool, error)

Verify an aggregate signature on the message digests using the public keys of the signers.

func GenKeyShares

func GenKeyShares(t int, n int, system System) (PublicKey, []PublicKey, PrivateKey, []PrivateKey, error)

Generate a key pair from the given cryptosystem and divide each key into n shares such that t shares can combine signatures to recover a threshold signature. This function allocates C structures on the C heap using malloc. It is the responsibility of the caller to prevent memory leaks by arranging for the C structures to be freed.

func GenKeys

func GenKeys(system System) (PublicKey, PrivateKey, error)

Generate a key pair from the given cryptosystem. This function allocates C structures on the C heap using malloc. It is the responsibility of the caller to prevent memory leaks by arranging for the C structures to be freed.

func Verify

func Verify(signature Signature, hash [sha256.Size]byte, key PublicKey) bool

Verify a signature on the message digest using the public key of the signer.

Types

type Element

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

func (Element) Free

func (element Element) Free()

Free the memory occupied by the element. The element cannot be used after calling this function.

func (Element) ToString

func (temp Element) ToString() string

Below function receives Element object and formats it according to the %x format specifier and returns the resulting string.

type Hex32

type Hex32 struct {
	Input [32]byte
}

func (Hex32) ToString

func (h Hex32) ToString() string

Below function receives object of Struct Hex32 and formats it according to the %x format specifier and returns the resulting string.

type Pairing

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

func GenPairing

func GenPairing(params Params) Pairing

Generate a pairing from the given parameters. This function allocates C structures on the C heap using malloc. It is the responsibility of the caller to prevent memory leaks by arranging for the C structures to be freed.

func (Pairing) Free

func (pairing Pairing) Free()

Free the memory occupied by the pairing. The pairing cannot be used after calling this function.

type Params

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

func GenParamsTypeA

func GenParamsTypeA(rbits int, qbits int) Params

Generate type A pairing parameters. This function allocates C structures on the C heap using malloc. It is the responsibility of the caller to prevent memory leaks by arranging for the C structures to be freed. More information about type A pairing parameters can be found in the PBC library manual: https://crypto.stanford.edu/pbc/manual/ch08s03.html.

func GenParamsTypeD

func GenParamsTypeD(d uint, bitlimit uint) (Params, error)

Generate type D pairing parameters. This function allocates C structures on the C heap using malloc. It is the responsibility of the caller to prevent memory leaks by arranging for the C structures to be freed. More information about type D pairing parameters can be found in the PBC library manual: https://crypto.stanford.edu/pbc/manual/ch08s06.html.

func GenParamsTypeF

func GenParamsTypeF(bits int) Params

Generate type F pairing parameters. This function allocates C structures on the C heap using malloc. It is the responsibility of the caller to prevent memory leaks by arranging for the C structures to be freed. More information about type F pairing parameters can be found in the PBC library manual: https://crypto.stanford.edu/pbc/manual/ch08s08.html.

func ParamsFromBytes

func ParamsFromBytes(bytes []byte) (Params, error)

ParamsFromBytes imports Params from the provided byte slice. It expects the data format exported by ToBytes. An example of Type A params of this form can be found in param/a.param

This function allocates C structures on the C heap using malloc. It is the responsibility of the caller to prevent memory leaks by arranging for the C structures to be freed.

func (Params) Free

func (params Params) Free()

Free the memory occupied by the pairing parameters. The parameters cannot be used after calling this function.

func (Params) ToBytes

func (params Params) ToBytes() ([]byte, error)

ToBytes exports Params to a byte slice. The output format is a custom set of ASCII key-value pairs. Pairs are separated by the space character (` `), and delimited by a newline (`\n`).

type PrivateKey

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

func (PrivateKey) Free

func (secret PrivateKey) Free()

Free the memory occupied by the private key. The private key cannot be used after calling this function.

func (PrivateKey) ToString

func (secret PrivateKey) ToString() string

Below function receives PrivateKey object and formats it according to the %x format specifier and returns the resulting string.

type PublicKey

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

func (PublicKey) Free

func (key PublicKey) Free()

Free the memory occupied by the public key. The public key cannot be used after calling this function.

func (PublicKey) ToString

func (key PublicKey) ToString() string

Below function receives PublicKey object and formats it according to the %x format specifier and returns the resulting string.

type Signature

type Signature = Element

func Aggregate

func Aggregate(signatures []Signature, system System) (Signature, error)

Aggregate signatures using the cryptosystem. This function allocates C structures on the C heap using malloc. It is the responsibility of the caller to prevent memory leaks by arranging for the C structures to be freed.

func Sign

func Sign(hash [sha256.Size]byte, secret PrivateKey) Signature

Sign a message digest using a private key. This function allocates C structures on the C heap using malloc. It is the responsibility of the caller to prevent memory leaks by arranging for the C structures to be freed.

func Threshold

func Threshold(shares []Signature, memberIds []int, system System) (Signature, error)

Recover a threshold signature from the signature shares provided by the group members using the cryptosystem. This function allocates C structures on the C heap using malloc. It is the responsibility of the caller to prevent memory leaks by arranging for the C structures to be freed.

type System

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

func GenSystem

func GenSystem(pairing Pairing) (System, error)

Generate a cryptosystem from the given pairing. This function allocates C structures on the C heap using malloc. It is the responsibility of the caller to prevent memory leaks by arranging for the C structures to be freed.

func SystemFromBytes

func SystemFromBytes(pairing Pairing, bytes []byte) (System, error)

SystemFromBytes imports a System from the provided byte slice.

This function allocates C structures on the C heap using malloc. It is the responsibility of the caller to prevent memory leaks by arranging for the C structures to be freed.

func (System) Free

func (system System) Free()

Free the memory occupied by the cryptosystem. The cryptosystem cannot be used after calling this function.

func (System) PrivKeyFromBytes

func (system System) PrivKeyFromBytes(bytes []byte) (PrivateKey, error)

Convert a byte slice to a PivateKey.

func (System) PrivKeyToBytes

func (system System) PrivKeyToBytes(privKey PrivateKey) []byte

Convert a PrivateKey to a byte slice

func (System) PrivSigFromBytes

func (system System) PrivSigFromBytes(bytes []byte) (Signature, error)

Convert a byte slice to a signature.

func (System) PrivSigToBytes

func (system System) PrivSigToBytes(signature Signature) []byte

Convert a signature to a byte slice.

func (System) PubKeyFromBytes

func (system System) PubKeyFromBytes(bytes []byte) (PublicKey, error)

Convert a byte slice to a PublicKey.

func (System) PubKeyToBytes

func (system System) PubKeyToBytes(pubKey PublicKey) []byte

Convert a PublicKey to a byte slice.

func (System) SigFromBytes

func (system System) SigFromBytes(bytes []byte) (Signature, error)

Convert a byte slice to a signature.

func (System) SigToBytes

func (system System) SigToBytes(signature Signature) []byte

Convert a signature to a byte slice.

func (System) ToBytes

func (system System) ToBytes() []byte

ToBytes exports the System to a byte slice.

Jump to

Keyboard shortcuts

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