bls

package
v0.0.0-...-f672fcd Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DomainValidatorSetString      = "DOMAIN_CHILD_VALIDATOR_SET"
	DomainCheckpointManagerString = "DOMAIN_CHECKPOINT_MANAGER"
	DomainCommonSigningString     = "DOMAIN_COMMON_SIGNING"
	DomainStateReceiverString     = "DOMAIN_STATE_RECEIVER"
)

Variables

View Source
var (

	// domain used to map hash to G1 used by (child) validator set
	DomainValidatorSet = pcrypto.Keccak256([]byte(DomainValidatorSetString))

	// domain used to map hash to G1 used by child checkpoint manager
	DomainCheckpointManager = pcrypto.Keccak256([]byte(DomainCheckpointManagerString))

	DomainCommonSigning = pcrypto.Keccak256([]byte(DomainCommonSigningString))
	DomainStateReceiver = pcrypto.Keccak256([]byte(DomainStateReceiverString))
)

Functions

func MarshalMessageToBigInt

func MarshalMessageToBigInt(message, domain []byte) ([2]*big.Int, error)

MarshalMessageToBigInt marshalls message into two big ints first we must convert message bytes to point and than for each coordinate we create big int

Types

type PrivateKey

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

PrivateKey holds private key for bls implementation

func CreateRandomBlsKeys

func CreateRandomBlsKeys(total int) ([]*PrivateKey, error)

CreateRandomBlsKeys creates an array of random private and their corresponding public keys

func GenerateBlsKey

func GenerateBlsKey() (*PrivateKey, error)

GenerateBlsKey creates a random private and its corresponding public keys

func UnmarshalPrivateKey

func UnmarshalPrivateKey(data []byte) (*PrivateKey, error)

UnmarshalPrivateKey unmarshals the private key from the given byte slice

func (*PrivateKey) Marshal

func (p *PrivateKey) Marshal() ([]byte, error)

Marshal marshals private key to byte slice

func (*PrivateKey) PublicKey

func (p *PrivateKey) PublicKey() *PublicKey

PublicKey returns the public key from the PrivateKey

func (*PrivateKey) Sign

func (p *PrivateKey) Sign(message, domain []byte) (*Signature, error)

Sign generates a simple BLS signature of the given message

type PublicKey

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

PublicKey represents bls public key

func UnmarshalPublicKey

func UnmarshalPublicKey(data []byte) (*PublicKey, error)

UnmarshalPublicKey unmarshals bytes to public key

func UnmarshalPublicKeyFromBigInt

func UnmarshalPublicKeyFromBigInt(b [4]*big.Int) (*PublicKey, error)

UnmarshalPublicKeyFromBigInt unmarshals public key from 4 big ints Order of coordinates is [A.Y, A.X, B.Y, B.X]

func (*PublicKey) Marshal

func (p *PublicKey) Marshal() []byte

Marshal marshal the key to bytes.

func (*PublicKey) MarshalText

func (p *PublicKey) MarshalText() ([]byte, error)

MarshalText implements the json.Marshaler interface.

func (*PublicKey) ToBigInt

func (p *PublicKey) ToBigInt() [4]*big.Int

ToBigInt converts public key to 4 big ints

func (*PublicKey) UnmarshalText

func (p *PublicKey) UnmarshalText(buf []byte) error

UnmarshalText implements encoding.TextMarshaler interface

type PublicKeys

type PublicKeys []*PublicKey

func (PublicKeys) Aggregate

func (pks PublicKeys) Aggregate() *PublicKey

Aggregate aggregates all public keys into one

type Signature

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

Signature represents bls signature which is point on the curve

func MakeKOSKSignature

func MakeKOSKSignature(privateKey *PrivateKey, address types.Address,
	chainID int64, domain []byte, supernetManagerAddr types.Address) (*Signature, error)

MakeKOSKSignature creates KOSK signature which prevents rogue attack

func UnmarshalSignature

func UnmarshalSignature(raw []byte) (*Signature, error)

UnmarshalSignature reads the signature from the given byte array

func (*Signature) Marshal

func (s *Signature) Marshal() ([]byte, error)

Marshal the signature to bytes.

func (Signature) ToBigInt

func (s Signature) ToBigInt() ([2]*big.Int, error)

ToBigInt marshalls signature (which is point) to 2 big ints - one for each coordinate

func (*Signature) Verify

func (s *Signature) Verify(pub *PublicKey, message, domain []byte) bool

Verify checks the BLS signature of the message against the public key of its signer

func (*Signature) VerifyAggregated

func (s *Signature) VerifyAggregated(publicKeys []*PublicKey, msg, domain []byte) bool

VerifyAggregated checks the BLS signature of the message against the aggregated public keys of its signers

type Signatures

type Signatures []*Signature

Signatures is a slice of signatures

func (Signatures) Aggregate

func (sigs Signatures) Aggregate() *Signature

Aggregate aggregates all signatures into one

Jump to

Keyboard shortcuts

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