Documentation
¶
Overview ¶
Package crypto exposes high-level cryptographic functionality.
Index ¶
- Variables
- func BLSPointFromHex(hexStr string) (kyber.Point, error)
- func BLSPointToHex(p kyber.Point) string
- func DerivePubkey(secret kyber.Scalar) *bls12381.KyberG1
- func NewKeyPair() (secret kyber.Scalar, pubkey *bls12381.KyberG1)
- func NewTBLSPoly(t int) (pri *share.PriPoly, pub *share.PubPoly)
- func ReadPlaintextPassword(filePath string) (string, error)
- func WritePlaintextPassword(filePath string, overwrite bool, password string) error
- type BLSPubkeyHex
- type Keystore
- func BLSKeyPairToKeystore(scalar kyber.Scalar, pubkey kyber.Point, password string) (*Keystore, error)
- func LoadKeystore(filePath string) (*Keystore, error)
- func NewBLSKeystore(password string) (*Keystore, kyber.Scalar, kyber.Point, error)
- func TBLSShareToKeystore(scheme *TBLSScheme, priPoly *share.PriShare, password string) (*Keystore, error)
- type TBLSScheme
- type TBLSSchemeEncoded
Constants ¶
This section is empty.
Variables ¶
var BLSKeyGroup = BLSPairing.G1()
BLSKeyGroup is the G1 group.
var BLSPairing = bls12381.NewBLS12381Suite()
BLSPairing is the BLS12-381 suite.
Functions ¶
func BLSPointFromHex ¶
BLSPointFromHex unwraps a hex serialization to a G1 or G2 point on the BLS12-381 curve.
func BLSPointToHex ¶
BLSPointToHex returns the hex serialization of a BLS public key (G1) or signature (G2).
func DerivePubkey ¶
DerivePubkey returns a BLS public key given a private key.
func NewKeyPair ¶
NewKeyPair creates a new random key pair.
func NewTBLSPoly ¶
NewTBLSPoly creates a new secret sharing polynomial for a BLS12-381 threshold signature scheme. Note that this function is not particularly secure as it constructs the root key in memory.
func ReadPlaintextPassword ¶
ReadPlaintextPassword reads a password as the first line from a file.
func WritePlaintextPassword ¶
WritePlaintextPassword saves a password to a file without leading or trailing whitespace.
If overwrite is set and a file already exists at the given path, the file contents will be erased.
Types ¶
type BLSPubkeyHex ¶
BLSPubkeyHex wraps a BLS public key with simplified hex serialization.
func (BLSPubkeyHex) MarshalText ¶
func (p BLSPubkeyHex) MarshalText() ([]byte, error)
MarshalText returns the hex serialization of the compressed form BLS12-381 G1 point.
func (*BLSPubkeyHex) UnmarshalText ¶
func (p *BLSPubkeyHex) UnmarshalText(b []byte) error
UnmarshalText decodes the given hex serialization of the compressed form BLS12-381 G1 point.
type Keystore ¶
type Keystore struct {
Crypto map[string]interface{} `json:"crypto"` // checksum, cipher, kdf
Description string `json:"description"` // free-form text string explaining keystore purpose
UUID string `json:"uuid"` // random UUID
Pubkey string `json:"pubkey"` // BLS12-381 hex public key
Path string `json:"path"` // EIP-2334 derivation path if hierarchical deriv, otherwise empty
Version uint `json:"version"` // must be 4
}
Keystore describes the EIP-2335 BLS12-381 keystore file format.
https://eips.ethereum.org/EIPS/eip-2335
func BLSKeyPairToKeystore ¶
func BLSKeyPairToKeystore(scalar kyber.Scalar, pubkey kyber.Point, password string) (*Keystore, error)
BLSKeyPairToKeystore creates a new EIP-2335 keystore given a BLS12-381 key pair. The provided keys should be standalone and not part of hierarchical deterministic derivation.
func LoadKeystore ¶
LoadKeystore reads and unmarshals the keystore from the given path.
func NewBLSKeystore ¶
NewBLSKeystore creates a new keystore with a random BLS12-381 private key.
func TBLSShareToKeystore ¶
func TBLSShareToKeystore(scheme *TBLSScheme, priPoly *share.PriShare, password string) (*Keystore, error)
TBLSShareToKeystore constructs a new keystore from a threshold BLS private key share.
Prints the public key as a side effect.
func (*Keystore) BLSKeyPair ¶
BLSKeyPair returns the BLS12-381 keypair stored in a keystore.
type TBLSScheme ¶
TBLSScheme wraps drand/share.PubPoly, the public commitments of a BLS secret sharing scheme required to recover BLS threshold signatures from signature shares.
func (TBLSScheme) Encode ¶
func (t TBLSScheme) Encode() (TBLSSchemeEncoded, error)
Encode serializes cryptographic data.
func (TBLSScheme) MarshalJSON ¶
func (t TBLSScheme) MarshalJSON() ([]byte, error)
MarshalJSON serializes a TBLS scheme to JSON.
func (TBLSScheme) Pubkey ¶
func (t TBLSScheme) Pubkey() kyber.Point
Pubkey returns the BLS public key.
func (*TBLSScheme) UnmarshalJSON ¶
func (t *TBLSScheme) UnmarshalJSON(data []byte) error
UnmarshalJSON deserializes a TBLS scheme from JSON.
type TBLSSchemeEncoded ¶
type TBLSSchemeEncoded []BLSPubkeyHex
TBLSSchemeEncoded is the serialized form of TBLSScheme suitable for JSON encoding.
func (TBLSSchemeEncoded) Decode ¶
func (t TBLSSchemeEncoded) Decode() *TBLSScheme
Decode reconstructs the threshold BLS commitment data.