bls

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyType = "bls"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type G1Point

type G1Point struct {
	*bn254.G1Affine
}

func NewG1Point

func NewG1Point(x, y *big.Int) *G1Point

func NewZeroG1Point

func NewZeroG1Point() *G1Point

func (*G1Point) Add

func (p *G1Point) Add(p2 *G1Point) *G1Point

Add another G1 point to this one

func (*G1Point) Deserialize

func (p *G1Point) Deserialize(data []byte) *G1Point

func (*G1Point) Serialize

func (p *G1Point) Serialize() []byte

func (*G1Point) Sub

func (p *G1Point) Sub(p2 *G1Point) *G1Point

Sub another G1 point from this one

func (*G1Point) VerifyEquivalence

func (p *G1Point) VerifyEquivalence(p2 *G2Point) (bool, error)

VerifyEquivalence verifies G1Point is equivalent the G2Point

type G2Point

type G2Point struct {
	*bn254.G2Affine
}

func NewG2Point

func NewG2Point(X, Y [2]*big.Int) *G2Point

func NewZeroG2Point

func NewZeroG2Point() *G2Point

func (*G2Point) Add

func (p *G2Point) Add(p2 *G2Point) *G2Point

Add another G2 point to this one

func (*G2Point) Deserialize

func (p *G2Point) Deserialize(data []byte) *G2Point

func (*G2Point) Serialize

func (p *G2Point) Serialize() []byte

func (*G2Point) Sub

func (p *G2Point) Sub(p2 *G2Point) *G2Point

Sub another G2 point from this one

type KeyPair

type KeyPair struct {
	PrivKey *PrivateKey
	PubKey  *G1Point
}

func GenRandomBlsKeys

func GenRandomBlsKeys() (*KeyPair, error)

func NewKeyPair

func NewKeyPair(sk *PrivateKey) *KeyPair

func NewKeyPairFromString

func NewKeyPairFromString(sk string) (*KeyPair, error)

func ReadPrivateKeyFromFile

func ReadPrivateKeyFromFile(path string, password string) (*KeyPair, error)

func (*KeyPair) GetPubKeyG1

func (k *KeyPair) GetPubKeyG1() *G1Point

func (*KeyPair) GetPubKeyG2

func (k *KeyPair) GetPubKeyG2() *G2Point

func (*KeyPair) SaveToFile

func (k *KeyPair) SaveToFile(path string, password string) error

SaveToFile saves the private key in an encrypted keystore file

func (*KeyPair) SignHashedToCurveMessage

func (k *KeyPair) SignHashedToCurveMessage(g1HashedMsg *bn254.G1Affine) *Signature

This signs a message on G1, and so will require a G2Pubkey to verify

func (*KeyPair) SignMessage

func (k *KeyPair) SignMessage(message [32]byte) *Signature

This signs a message on G1, and so will require a G2Pubkey to verify

type PrivateKey

type PrivateKey = fr.Element

func NewPrivateKey

func NewPrivateKey(sk string) (*PrivateKey, error)

type PubKey

type PubKey struct {
	G1Point G1Point
	G2Point G2Point
}

func NewBlsPubKeyFromProto

func NewBlsPubKeyFromProto(pubkeys avsiTypes.OperatorPubkeys) *PubKey

func (PubKey) Address

func (p PubKey) Address() crypto.Address

Address returns the address derived from the public key

func (PubKey) Bytes

func (p PubKey) Bytes() []byte

Bytes returns the byte representation of the public key

func (PubKey) Equals

func (p PubKey) Equals(other crypto.PubKey) bool

Equals checks whether the G 1G2 public keys are equal

func (PubKey) Type

func (pubKey PubKey) Type() string

func (PubKey) VerifySignature

func (p PubKey) VerifySignature(msg []byte, _ []byte) bool

VerifySignature verifies the signature of a message against the public key

type Signature

type Signature struct {
	*G1Point `json:"g1_point"`
}

func NewZeroSignature

func NewZeroSignature() *Signature

func (*Signature) Add

func (s *Signature) Add(otherS *Signature) *Signature

func (*Signature) Verify

func (s *Signature) Verify(pubkey *G2Point, message [32]byte) (bool, error)

Verify a message against a public key

Jump to

Keyboard shortcuts

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