bbs

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BBSSecurityContext                             string                    = "https://w3c.github.io/vc-di-bbs/contexts/v1"
	BBSPlusSignature2020                           cryptosuite.SignatureType = "BbsBlsSignature2020"
	BBSPlusSignatureSuiteID                        string                    = "https://w3c-ccg.github.io/ldp-bbs2020/#the-bbs-signature-suite-2020"
	BBSPlusSignatureSuiteType                                                = cryptosuite.BLS12381G2Key2020
	BBSPlusSignatureSuiteCanonicalizationAlgorithm string                    = "https://w3id.org/security#URDNA2015"
	// BBSPlusSignatureSuiteDigestAlgorithm uses https://www.rfc-editor.org/rfc/rfc4634
	BBSPlusSignatureSuiteDigestAlgorithm gocrypto.Hash = gocrypto.BLAKE2b_384
)
View Source
const (
	G1 jws2020.CRV = "BLS12381_G1"
	G2 jws2020.CRV = "BLS12381_G2"
)
View Source
const (
	BBSPlusSignatureProof2020 cryptosuite.SignatureType = "BbsBlsSignatureProof2020" //  #nosec
)

Variables

This section is empty.

Functions

func GetBBSPlusSignatureSuite

func GetBBSPlusSignatureSuite() cryptosuite.CryptoSuite

Types

type BBSPlusSignature2020Proof

type BBSPlusSignature2020Proof struct {
	Type                     cryptosuite.SignatureType `json:"type,omitempty"`
	Created                  string                    `json:"created,omitempty"`
	VerificationMethod       string                    `json:"verificationMethod,omitempty"`
	ProofPurpose             cryptosuite.ProofPurpose  `json:"proofPurpose,omitempty"`
	ProofValue               string                    `json:"proofValue,omitempty"`
	Nonce                    string                    `json:"nonce,omitempty"`
	RequiredRevealStatements []int                     `json:"requiredRevealStatements,omitempty"`
}

func BBSPlusProofFromGenericProof

func BBSPlusProofFromGenericProof(p crypto.Proof) (*BBSPlusSignature2020Proof, error)

BBSPlusProofFromGenericProof accepts either a slice with exactly one element, or a single element and creates a BBSPlusSignature2020Proof by unmarshaling the JSON marshaled representation of the element found in `p`.

func (*BBSPlusSignature2020Proof) SetProofValue

func (b *BBSPlusSignature2020Proof) SetProofValue(proofValue string)

type BBSPlusSignatureProofSuite

type BBSPlusSignatureProofSuite struct{}

func GetBBSPlusSignatureProofSuite

func GetBBSPlusSignatureProofSuite() *BBSPlusSignatureProofSuite

func (BBSPlusSignatureProofSuite) CanonicalizationAlgorithm

func (BBSPlusSignatureProofSuite) CanonicalizationAlgorithm() string

func (BBSPlusSignatureProofSuite) Canonicalize

func (BBSPlusSignatureProofSuite) Canonicalize(marshaled []byte) (*string, error)

func (BBSPlusSignatureProofSuite) CreateDeriveProof

func (b BBSPlusSignatureProofSuite) CreateDeriveProof(inputProofDocument any, revealDocument map[string]any) (*DeriveProofResult, error)

CreateDeriveProof https://w3c-ccg.github.io/vc-di-bbs/#create-derive-proof-data-algorithm

func (BBSPlusSignatureProofSuite) Digest

func (BBSPlusSignatureProofSuite) Digest(tbd []byte) ([]byte, error)

func (BBSPlusSignatureProofSuite) ID

func (BBSPlusSignatureProofSuite) Marshal

func (BBSPlusSignatureProofSuite) Marshal(data any) ([]byte, error)

func (BBSPlusSignatureProofSuite) MessageDigestAlgorithm

func (BBSPlusSignatureProofSuite) MessageDigestAlgorithm() gocrypto.Hash

func (BBSPlusSignatureProofSuite) RequiredContexts

func (BBSPlusSignatureProofSuite) RequiredContexts() []string

func (BBSPlusSignatureProofSuite) SelectivelyDisclose

func (b BBSPlusSignatureProofSuite) SelectivelyDisclose(v BBSPlusVerifier, p cryptosuite.WithEmbeddedProof, toDiscloseFrame map[string]any, nonce []byte) (map[string]any, error)

SelectivelyDisclose takes in a credential (parameter `p` that's WithEmbeddedProof) and a map of fields to disclose as an LD frame, and produces a map of the JSON representation of the derived credential. The derived credential only contains the information that was specified in the LD frame, and a proof that's derived from the original credential. Note that a requirement for `p` is that the property `"proof"` must be present when it's marshaled to JSON, and it's value MUST be an object that conforms to a `BBSPlusProof`.

func (BBSPlusSignatureProofSuite) SignatureAlgorithm

func (BBSPlusSignatureProofSuite) Type

func (BBSPlusSignatureProofSuite) Verify

Verify verifies a BBS Plus derived proof. Note that the underlying value for `v` must be of type `*BBSPlusVerifier`. Bug here: https://github.com/w3c-ccg/ldp-bbs2020/issues/62

type BBSPlusSignatureSuite

type BBSPlusSignatureSuite struct{}

func (BBSPlusSignatureSuite) CanonicalizationAlgorithm

func (BBSPlusSignatureSuite) CanonicalizationAlgorithm() string

func (BBSPlusSignatureSuite) Canonicalize

func (BBSPlusSignatureSuite) Canonicalize(marshaled []byte) (*string, error)

func (BBSPlusSignatureSuite) Digest

func (BBSPlusSignatureSuite) Digest(tbd []byte) ([]byte, error)

func (BBSPlusSignatureSuite) ID

func (BBSPlusSignatureSuite) Marshal

func (BBSPlusSignatureSuite) Marshal(data any) ([]byte, error)

func (BBSPlusSignatureSuite) MessageDigestAlgorithm

func (BBSPlusSignatureSuite) MessageDigestAlgorithm() gocrypto.Hash

func (BBSPlusSignatureSuite) RequiredContexts

func (BBSPlusSignatureSuite) RequiredContexts() []string

func (BBSPlusSignatureSuite) Sign

func (BBSPlusSignatureSuite) SignatureAlgorithm

func (BBSPlusSignatureSuite) SignatureAlgorithm() cryptosuite.SignatureType

func (BBSPlusSignatureSuite) Type

func (BBSPlusSignatureSuite) Verify

type BBSPlusSigner

type BBSPlusSigner struct {
	*crypto.BBSPlusSigner
	*crypto.BBSPlusVerifier
	// contains filtered or unexported fields
}

func NewBBSPlusSigner

func NewBBSPlusSigner(kid string, privKey *bbs.PrivateKey, purpose cryptosuite.ProofPurpose) *BBSPlusSigner

func (*BBSPlusSigner) GetKeyID

func (s *BBSPlusSigner) GetKeyID() string

func (*BBSPlusSigner) GetPayloadFormat

func (s *BBSPlusSigner) GetPayloadFormat() cryptosuite.PayloadFormat

func (*BBSPlusSigner) GetProofPurpose

func (s *BBSPlusSigner) GetProofPurpose() cryptosuite.ProofPurpose

func (*BBSPlusSigner) GetSignatureType

func (*BBSPlusSigner) GetSignatureType() cryptosuite.SignatureType

func (*BBSPlusSigner) GetSigningAlgorithm

func (*BBSPlusSigner) GetSigningAlgorithm() string

func (*BBSPlusSigner) SetPayloadFormat

func (s *BBSPlusSigner) SetPayloadFormat(format cryptosuite.PayloadFormat)

func (*BBSPlusSigner) SetProofPurpose

func (s *BBSPlusSigner) SetProofPurpose(purpose cryptosuite.ProofPurpose)

func (*BBSPlusSigner) Sign

func (s *BBSPlusSigner) Sign(tbs []byte) ([]byte, error)

type BBSPlusVerifier

type BBSPlusVerifier struct {
	*crypto.BBSPlusVerifier
}

func NewBBSPlusVerifier

func NewBBSPlusVerifier(kid string, pubKey *bbs.PublicKey) *BBSPlusVerifier

func (BBSPlusVerifier) DeriveProof

func (v BBSPlusVerifier) DeriveProof(messages [][]byte, sigBytes, nonce []byte, revealedIndexes []int) ([]byte, error)

DeriveProof derives a proof from the given signature and nonce. It is used in creating selective disclosure representations of a signed object.

func (BBSPlusVerifier) GetKeyID

func (v BBSPlusVerifier) GetKeyID() string

func (BBSPlusVerifier) Verify

func (v BBSPlusVerifier) Verify(message, signature []byte) error

Verify is used to verify a signature over a message using a BLS key.

func (BBSPlusVerifier) VerifyDerived

func (v BBSPlusVerifier) VerifyDerived(message, signature, nonce []byte) error

VerifyDerived is used to verify a derived proof over a message using a BLS key. It is used in verifying selective disclosure representations of a signed object.

type BLSKey2020

type BLSKey2020 struct {
	ID               string                `json:"id,omitempty"`
	Type             cryptosuite.LDKeyType `json:"type,omitempty"`
	Controller       string                `json:"controller,omitempty"`
	PublicKeyBase58  string                `json:"publicKeyBase58,omitempty"`
	PrivateKeyBase58 string                `json:"privateKeyBase58,omitempty"`
}

func GenerateBLSKey2020

func GenerateBLSKey2020(keyType cryptosuite.LDKeyType) (*BLSKey2020, error)

GenerateBLSKey2020 https://w3c-ccg.github.io/vc-di-bbs/#bls12-381

func (BLSKey2020) GetPrivateKey

func (b BLSKey2020) GetPrivateKey() (*bbs.PrivateKey, error)

func (BLSKey2020) GetPublicKey

func (b BLSKey2020) GetPublicKey() (*bbs.PublicKey, error)

type DeriveProofResult

type DeriveProofResult struct {
	RevealedIndicies             []int
	InputProofDocumentStatements []string
	RevealedDocument             map[string]any
}

Jump to

Keyboard shortcuts

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