bbs

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 14 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKeyPair

func GenerateKeyPair(h func() hash.Hash, seed []byte) (*PublicKey, *PrivateKey, error)

GenerateKeyPair generates BBS+ PublicKey and PrivateKey pair.

func NewBlindSignatureContext

func NewBlindSignatureContext(msgs map[int][]byte, generators *PublicKeyWithGenerators, nonce *ProofNonce) (*BlindSignatureContext, *SignatureBliding, error)

Types

type Bbs

type Bbs struct{}

func NewBbs

func NewBbs() *Bbs

func (*Bbs) DeriveProof

func (bbs *Bbs) DeriveProof(messages [][]byte, sigBytes, nonce, pubKeyBytes []byte,
	revealedIndexes []int) ([]byte, error)

DeriveProof derives a proof of BBS+ signature with some messages disclosed.

func (*Bbs) Sign

func (bbs *Bbs) Sign(messages [][]byte, privKeyBytes []byte) ([]byte, error)

Sign signs the one or more messages using private key in compressed form.

func (*Bbs) SignWithKey

func (bbs *Bbs) SignWithKey(messages [][]byte, privKey *PrivateKey) ([]byte, error)

SignWithKey signs the one or more messages using BBS+ key pair.

func (*Bbs) Verify

func (bbs *Bbs) Verify(messages [][]byte, sigBytes, pubKeyBytes []byte) error

Verify makes BLS BBS12-381 signature verification.

func (*Bbs) VerifyProof

func (bbs *Bbs) VerifyProof(messagesBytes [][]byte, proof, nonce, pubKeyBytes []byte) error

VerifyProof verifies BBS+ signature proof for one or more revealed messages.

type BlindSignature

type BlindSignature struct {
	A *bls12381.PointG1
	E *bls12381.Fr
	S *bls12381.Fr
}

func NewBlindSignature

func NewBlindSignature(commiment *bls12381.PointG1, msgs map[int]*SignatureMessage, priv *PrivateKey, generotors *PublicKeyWithGenerators) *BlindSignature

func ParseBlindSignature

func ParseBlindSignature(sigBytes []byte) (*BlindSignature, error)

func (*BlindSignature) MarshalJSON

func (bs *BlindSignature) MarshalJSON() ([]byte, error)

func (*BlindSignature) ToBytes

func (bs *BlindSignature) ToBytes() ([]byte, error)

ToBytes converts signature to bytes using compression of G1 point and E, S FR points.

func (*BlindSignature) ToUnblinded

func (bs *BlindSignature) ToUnblinded(blinder *SignatureBliding) *Signature

func (*BlindSignature) UnmarshalJSON

func (bs *BlindSignature) UnmarshalJSON(input []byte) error

type BlindSignatureContext

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

func (*BlindSignatureContext) FromBytes

func (bsc *BlindSignatureContext) FromBytes(input []byte) error

func (*BlindSignatureContext) MarshalJSON

func (bsc *BlindSignatureContext) MarshalJSON() ([]byte, error)

func (*BlindSignatureContext) ToBlindSignature

func (bsc *BlindSignatureContext) ToBlindSignature(msgs map[int][]byte, privKey *PrivateKey, generators *PublicKeyWithGenerators, nonce *ProofNonce) (*BlindSignature, error)

func (*BlindSignatureContext) ToBytes

func (bsc *BlindSignatureContext) ToBytes() []byte

func (*BlindSignatureContext) UnmarshalJSON

func (bsc *BlindSignatureContext) UnmarshalJSON(input []byte) error

func (*BlindSignatureContext) Verify

func (bsc *BlindSignatureContext) Verify(revealedMsg map[int]*SignatureMessage, generators *PublicKeyWithGenerators, nonce *ProofNonce) error

type PoKOfSignature

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

PoKOfSignature is Proof of Knowledge of a Signature that is used by the prover to construct PoKOfSignatureProof.

func NewPoKOfSignature

func NewPoKOfSignature(signature *Signature, messages []*SignatureMessage, revealedIndexes []int,
	pubKey *PublicKeyWithGenerators) (*PoKOfSignature, error)

NewPoKOfSignature creates a new PoKOfSignature.

func (*PoKOfSignature) GenerateProof

func (pos *PoKOfSignature) GenerateProof(challengeHash *bls12381.Fr) *PoKOfSignatureProof

GenerateProof generates PoKOfSignatureProof proof from PoKOfSignature signature.

func (*PoKOfSignature) ToBytes

func (pos *PoKOfSignature) ToBytes() []byte

ToBytes converts PoKOfSignature to bytes.

type PoKOfSignatureProof

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

PoKOfSignatureProof defines BLS signature proof. It is the actual proof that is sent from prover to verifier.

func ParseSignatureProof

func ParseSignatureProof(sigProofBytes []byte) (*PoKOfSignatureProof, error)

ParseSignatureProof parses a signature proof.

func (*PoKOfSignatureProof) GetBytesForChallenge

func (sp *PoKOfSignatureProof) GetBytesForChallenge(revealedMessages map[int]*SignatureMessage,
	pubKey *PublicKeyWithGenerators) []byte

GetBytesForChallenge creates bytes for proof challenge.

func (*PoKOfSignatureProof) ToBytes

func (sp *PoKOfSignatureProof) ToBytes() []byte

ToBytes converts PoKOfSignatureProof to bytes.

func (*PoKOfSignatureProof) Verify

func (sp *PoKOfSignatureProof) Verify(challenge *bls12381.Fr, pubKey *PublicKeyWithGenerators,
	revealedMessages map[int]*SignatureMessage, messages []*SignatureMessage) error

Verify verifies PoKOfSignatureProof.

type PrivateKey

type PrivateKey struct {
	FR *bls12381.Fr
}

PrivateKey defines BLS Public Key.

func UnmarshalPrivateKey

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

UnmarshalPrivateKey unmarshals PrivateKey.

func (*PrivateKey) Marshal

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

Marshal marshals PrivateKey.

func (*PrivateKey) PublicKey

func (k *PrivateKey) PublicKey() *PublicKey

PublicKey returns a Public Key as G2 point generated from the Private Key.

type ProofG1

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

ProofG1 is a proof of knowledge of a signature and hidden messages.

func NewProofG1

func NewProofG1(commitment *bls12381.PointG1, responses []*bls12381.Fr) *ProofG1

NewProofG1 creates a new ProofG1.

func ParseProofG1

func ParseProofG1(bytes []byte) (*ProofG1, error)

ParseProofG1 parses ProofG1 from bytes.

func (*ProofG1) ToBytes

func (pg1 *ProofG1) ToBytes() []byte

ToBytes converts ProofG1 to bytes.

func (*ProofG1) Verify

func (pg1 *ProofG1) Verify(bases []*bls12381.PointG1, commitment *bls12381.PointG1, challenge *bls12381.Fr) error

Verify verifies the ProofG1.

type ProofNonce

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

ProofNonce is a nonce for Proof of Knowledge proof.

func NewProofNonce

func NewProofNonce() *ProofNonce

func ParseProofNonce

func ParseProofNonce(proofNonceBytes []byte) *ProofNonce

ParseProofNonce creates a new ProofNonce from bytes.

func (*ProofNonce) ToBytes

func (pn *ProofNonce) ToBytes() []byte

ToBytes converts ProofNonce into bytes.

type ProverCommittedG1

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

ProverCommittedG1 helps to generate a ProofG1.

func (*ProverCommittedG1) GenerateProof

func (g *ProverCommittedG1) GenerateProof(challenge *bls12381.Fr, secrets []*bls12381.Fr) *ProofG1

GenerateProof generates proof ProofG1 for all secrets.

func (*ProverCommittedG1) ToBytes

func (g *ProverCommittedG1) ToBytes() []byte

ToBytes converts ProverCommittedG1 to bytes.

type ProverCommittingG1

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

ProverCommittingG1 is a proof of knowledge of messages in a vector commitment.

func NewProverCommittingG1

func NewProverCommittingG1() *ProverCommittingG1

NewProverCommittingG1 creates a new ProverCommittingG1.

func (*ProverCommittingG1) Commit

func (pc *ProverCommittingG1) Commit(base *bls12381.PointG1)

Commit append a base point and randomly generated blinding factor.

func (*ProverCommittingG1) Finish

func (pc *ProverCommittingG1) Finish() *ProverCommittedG1

Finish helps to generate ProverCommittedG1 after commitment of all base points.

type PublicKey

type PublicKey struct {
	PointG2 *bls12381.PointG2
}

PublicKey defines BLS Public Key.

func UnmarshalPublicKey

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

UnmarshalPublicKey parses a PublicKey from bytes.

func (*PublicKey) Equal

func (pk *PublicKey) Equal(x crypto.PublicKey) bool

func (*PublicKey) Marshal

func (pk *PublicKey) Marshal() ([]byte, error)

Marshal marshals PublicKey.

func (*PublicKey) ToJWK

func (pbk *PublicKey) ToJWK() *PublicKeyJWK

func (*PublicKey) ToPublicKeyWithGenerators

func (pk *PublicKey) ToPublicKeyWithGenerators(messagesCount int) (*PublicKeyWithGenerators, error)

ToPublicKeyWithGenerators creates PublicKeyWithGenerators from the PublicKey.

type PublicKeyJWK

type PublicKeyJWK struct {
	Kty string `json:"kty"`
	Crv string `json:"crv"`
	X   string `json:"x"`
}

func (*PublicKeyJWK) ToPublicKey

func (jwk *PublicKeyJWK) ToPublicKey() *PublicKey

type PublicKeyWithGenerators

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

PublicKeyWithGenerators extends PublicKey with a blinding generator h0, a commitment to the secret key w, and a generator for each message h.

type Signature

type Signature struct {
	A *bls12381.PointG1
	E *bls12381.Fr
	S *bls12381.Fr
}

Signature defines BLS signature.

func ParseSignature

func ParseSignature(sigBytes []byte) (*Signature, error)

ParseSignature parses a Signature from bytes.

func (*Signature) ToBytes

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

ToBytes converts signature to bytes using compression of G1 point and E, S FR points.

func (*Signature) Verify

func (s *Signature) Verify(messages []*SignatureMessage, pubKey *PublicKeyWithGenerators) error

Verify is used for signature verification.

type SignatureBliding

type SignatureBliding struct {
	*bls12381.Fr
}

func NewSignatureBliding

func NewSignatureBliding() *SignatureBliding

func (*SignatureBliding) ToFr

func (sb *SignatureBliding) ToFr() *bls12381.Fr

type SignatureMessage

type SignatureMessage struct {
	FR *bls12381.Fr
}

SignatureMessage defines a message to be used for a signature check.

func ParseSignatureMessage

func ParseSignatureMessage(message []byte) *SignatureMessage

ParseSignatureMessage parses SignatureMessage from bytes.

Jump to

Keyboard shortcuts

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