aries

package module
v0.0.0-...-b3fcea5 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Overview

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const AttributeIndexInNym = 1

AttributeIndexInNym is the index of the blinding factor of the attribute in a Nym commitment

View Source
const IndexOffsetVC2Attributes = 2

IndexOffsetVC2Attributes is the index of the attributes in VC2

View Source
const UserSecretKeyIndex = 0

UserSecretKeyIndex is the index of `sk` among the attributes

Variables

This section is empty.

Functions

func BlindSign

func BlindSign(messages []*bbs12381g2pub.SignatureMessage, msgCount int, commitment *ml.G1, privKeyBytes []byte, curve *math.Curve) ([]byte, error)

BlindSign signs disclosed and blinded messages using private key in compressed form.

func UnblindSign

func UnblindSign(sigBytes []byte, S *ml.Zr, curve *ml.Curve) ([]byte, error)

UnblindSign converts a signature over some blind messages into a standard signature.

func VerifyBlinding

func VerifyBlinding(messageBitmap []bool, msgCommit *ml.G1, bmProof *POKOfBlindedMessages, PK *bbs12381g2pub.PublicKey, nonce []byte, curve *math.Curve) error

VerifyBlinding verifies that `msgCommit` is a valid commitment of a set of messages against the appropriate bases.

Types

type BlindedMessages

type BlindedMessages struct {
	PK  *bbs12381g2pub.PublicKeyWithGenerators
	S   *ml.Zr
	C   *ml.G1
	PoK *POKOfBlindedMessages
}

BlindedMessages represents a set of messages prepared (blinded) to be submitted to a signer for a blind signature.

func BlindMessages

func BlindMessages(messages [][]byte, PK *bbs12381g2pub.PublicKey, blindedMsgCount int, nonce []byte, curve *ml.Curve) (*BlindedMessages, error)

BlindMessages constructs a commitment to a set of messages that need to be blinded before signing, and generates the corresponding ZKP.

func BlindMessagesZr

func BlindMessagesZr(zrs []*ml.Zr, PK *bbs12381g2pub.PublicKey, blindedMsgCount int, nonce []byte, curve *ml.Curve) (*BlindedMessages, error)

BlindMessagesZr constructs a commitment to a set of messages that need to be blinded before signing, and generates the corresponding ZKP.

func ParseBlindedMessages

func ParseBlindedMessages(bytes []byte, curve *ml.Curve) (*BlindedMessages, error)

func (*BlindedMessages) Bytes

func (b *BlindedMessages) Bytes() []byte

type Cred

type Cred struct {
	Bls   *bbs12381g2pub.BBSG2Pub
	Curve *math.Curve
}

func (*Cred) Sign

func (c *Cred) Sign(key types.IssuerSecretKey, credentialRequest []byte, attributes []types.IdemixAttribute) ([]byte, error)

Sign issues a new credential, which is the last step of the interactive issuance protocol All attribute values are added by the issuer at this step and then signed together with a commitment to the user's secret key from a credential request

func (*Cred) Verify

func (c *Cred) Verify(sk *math.Zr, key types.IssuerPublicKey, credBytes []byte, attributes []types.IdemixAttribute) error

Verify cryptographically verifies the credential by verifying the signature on the attribute values and user's secret key

type CredRequest

type CredRequest struct {
	Curve *math.Curve
}

func (*CredRequest) Blind

func (c *CredRequest) Blind(sk *math.Zr, key types.IssuerPublicKey, nonce []byte) ([]byte, []byte, error)

Sign creates a new Credential Request, the first message of the interactive credential issuance protocol (from user to issuer)

func (*CredRequest) BlindVerify

func (c *CredRequest) BlindVerify(credRequest []byte, key types.IssuerPublicKey, nonce []byte) error

Verify verifies the credential request

func (*CredRequest) Unblind

func (c *CredRequest) Unblind(signature, blinding []byte) ([]byte, error)

Unblind takes a blinded signature and a blinding and produces a standard signature

type Credential

type Credential struct {
	Cred                 []byte   `protobuf:"bytes,1,opt,name=cred,proto3" json:"cred,omitempty"`
	Attrs                [][]byte `protobuf:"bytes,2,rep,name=attrs,proto3" json:"attrs,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Credential specifies a credential object

func (*Credential) Descriptor

func (*Credential) Descriptor() ([]byte, []int)

func (*Credential) GetAttrs

func (m *Credential) GetAttrs() [][]byte

func (*Credential) GetCred

func (m *Credential) GetCred() []byte

func (*Credential) ProtoMessage

func (*Credential) ProtoMessage()

func (*Credential) Reset

func (m *Credential) Reset()

func (*Credential) String

func (m *Credential) String() string

func (*Credential) XXX_DiscardUnknown

func (m *Credential) XXX_DiscardUnknown()

func (*Credential) XXX_Marshal

func (m *Credential) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Credential) XXX_Merge

func (m *Credential) XXX_Merge(src proto.Message)

func (*Credential) XXX_Size

func (m *Credential) XXX_Size() int

func (*Credential) XXX_Unmarshal

func (m *Credential) XXX_Unmarshal(b []byte) error

type CredentialRevocationInformation

type CredentialRevocationInformation struct {
	// epoch contains the epoch (time window) in which this CRI is valid
	Epoch int64 `protobuf:"varint,1,opt,name=epoch,proto3" json:"epoch,omitempty"`
	// epoch_pk is the public key that is used by the revocation authority in this epoch
	EpochPk []byte `protobuf:"bytes,2,opt,name=epoch_pk,json=epochPk,proto3" json:"epoch_pk,omitempty"`
	// epoch_pk_sig is a signature on the EpochPK valid under the revocation authority's long term key
	EpochPkSig []byte `protobuf:"bytes,3,opt,name=epoch_pk_sig,json=epochPkSig,proto3" json:"epoch_pk_sig,omitempty"`
	// revocation_alg denotes which revocation algorithm is used
	RevocationAlg int32 `protobuf:"varint,4,opt,name=revocation_alg,json=revocationAlg,proto3" json:"revocation_alg,omitempty"`
	// revocation_data contains data specific to the revocation algorithm used
	RevocationData       []byte   `protobuf:"bytes,5,opt,name=revocation_data,json=revocationData,proto3" json:"revocation_data,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*CredentialRevocationInformation) Descriptor

func (*CredentialRevocationInformation) Descriptor() ([]byte, []int)

func (*CredentialRevocationInformation) GetEpoch

func (m *CredentialRevocationInformation) GetEpoch() int64

func (*CredentialRevocationInformation) GetEpochPk

func (m *CredentialRevocationInformation) GetEpochPk() []byte

func (*CredentialRevocationInformation) GetEpochPkSig

func (m *CredentialRevocationInformation) GetEpochPkSig() []byte

func (*CredentialRevocationInformation) GetRevocationAlg

func (m *CredentialRevocationInformation) GetRevocationAlg() int32

func (*CredentialRevocationInformation) GetRevocationData

func (m *CredentialRevocationInformation) GetRevocationData() []byte

func (*CredentialRevocationInformation) ProtoMessage

func (*CredentialRevocationInformation) ProtoMessage()

func (*CredentialRevocationInformation) Reset

func (*CredentialRevocationInformation) String

func (*CredentialRevocationInformation) XXX_DiscardUnknown

func (m *CredentialRevocationInformation) XXX_DiscardUnknown()

func (*CredentialRevocationInformation) XXX_Marshal

func (m *CredentialRevocationInformation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CredentialRevocationInformation) XXX_Merge

func (m *CredentialRevocationInformation) XXX_Merge(src proto.Message)

func (*CredentialRevocationInformation) XXX_Size

func (m *CredentialRevocationInformation) XXX_Size() int

func (*CredentialRevocationInformation) XXX_Unmarshal

func (m *CredentialRevocationInformation) XXX_Unmarshal(b []byte) error

type Issuer

type Issuer struct {
	Curve *math.Curve
}

Issuer is a local interface to decouple from the idemix implementation

func (*Issuer) NewKey

func (i *Issuer) NewKey(AttributeNames []string) (types.IssuerSecretKey, error)

NewKey generates a new idemix issuer key w.r.t the passed attribute names.

func (*Issuer) NewKeyFromBytes

func (i *Issuer) NewKeyFromBytes(raw []byte, attributes []string) (types.IssuerSecretKey, error)

NewPublicKeyFromBytes converts the passed bytes to an Issuer key It makes sure that the so obtained key has the passed attributes, if specified

func (*Issuer) NewPublicKeyFromBytes

func (i *Issuer) NewPublicKeyFromBytes(raw []byte, attributes []string) (types.IssuerPublicKey, error)

NewPublicKeyFromBytes converts the passed bytes to an Issuer public key It makes sure that the so obtained public key has the passed attributes, if specified

type IssuerPublicKey

type IssuerPublicKey struct {
	PK   *bbs12381g2pub.PublicKey
	PKwG *bbs12381g2pub.PublicKeyWithGenerators
	// N is the number of attributes; it *does not* include the user secret key
	N int
}

IssuerPublicKey is the issuer public key

func (*IssuerPublicKey) Bytes

func (i *IssuerPublicKey) Bytes() ([]byte, error)

Bytes returns the byte representation of this key

func (*IssuerPublicKey) Hash

func (i *IssuerPublicKey) Hash() []byte

Hash returns the hash representation of this key. The output is supposed to be collision-resistant

type IssuerSecretKey

type IssuerSecretKey struct {
	IssuerPublicKey
	SK *bbs12381g2pub.PrivateKey
}

IssuerPublicKey is the issuer secret key

func (*IssuerSecretKey) Bytes

func (i *IssuerSecretKey) Bytes() ([]byte, error)

Bytes returns the byte representation of this key

func (*IssuerSecretKey) Public

Public returns the corresponding public key

type NonRevocationProof

type NonRevocationProof struct {
	RevocationAlg        int32    `protobuf:"varint,1,opt,name=revocation_alg,json=revocationAlg,proto3" json:"revocation_alg,omitempty"`
	NonRevocationProof   []byte   `protobuf:"bytes,2,opt,name=non_revocation_proof,json=nonRevocationProof,proto3" json:"non_revocation_proof,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

NonRevocationProof contains proof that the credential is not revoked

func (*NonRevocationProof) Descriptor

func (*NonRevocationProof) Descriptor() ([]byte, []int)

func (*NonRevocationProof) GetNonRevocationProof

func (m *NonRevocationProof) GetNonRevocationProof() []byte

func (*NonRevocationProof) GetRevocationAlg

func (m *NonRevocationProof) GetRevocationAlg() int32

func (*NonRevocationProof) ProtoMessage

func (*NonRevocationProof) ProtoMessage()

func (*NonRevocationProof) Reset

func (m *NonRevocationProof) Reset()

func (*NonRevocationProof) String

func (m *NonRevocationProof) String() string

func (*NonRevocationProof) XXX_DiscardUnknown

func (m *NonRevocationProof) XXX_DiscardUnknown()

func (*NonRevocationProof) XXX_Marshal

func (m *NonRevocationProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*NonRevocationProof) XXX_Merge

func (m *NonRevocationProof) XXX_Merge(src proto.Message)

func (*NonRevocationProof) XXX_Size

func (m *NonRevocationProof) XXX_Size() int

func (*NonRevocationProof) XXX_Unmarshal

func (m *NonRevocationProof) XXX_Unmarshal(b []byte) error

type NymSignature

type NymSignature struct {
	MainSignature        []byte   `protobuf:"bytes,1,opt,name=main_signature,json=mainSignature,proto3" json:"main_signature,omitempty"`
	Nonce                []byte   `protobuf:"bytes,2,opt,name=nonce,proto3" json:"nonce,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*NymSignature) Descriptor

func (*NymSignature) Descriptor() ([]byte, []int)

func (*NymSignature) GetMainSignature

func (m *NymSignature) GetMainSignature() []byte

func (*NymSignature) GetNonce

func (m *NymSignature) GetNonce() []byte

func (*NymSignature) ProtoMessage

func (*NymSignature) ProtoMessage()

func (*NymSignature) Reset

func (m *NymSignature) Reset()

func (*NymSignature) String

func (m *NymSignature) String() string

func (*NymSignature) XXX_DiscardUnknown

func (m *NymSignature) XXX_DiscardUnknown()

func (*NymSignature) XXX_Marshal

func (m *NymSignature) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*NymSignature) XXX_Merge

func (m *NymSignature) XXX_Merge(src proto.Message)

func (*NymSignature) XXX_Size

func (m *NymSignature) XXX_Size() int

func (*NymSignature) XXX_Unmarshal

func (m *NymSignature) XXX_Unmarshal(b []byte) error

type NymSigner

type NymSigner struct {
	Curve *math.Curve
	Rng   io.Reader
}

func (*NymSigner) Sign

func (s *NymSigner) Sign(
	sk *math.Zr,
	Nym *math.G1,
	RNym *math.Zr,
	key types.IssuerPublicKey,
	digest []byte,
) ([]byte, error)

Sign creates a new idemix pseudonym signature

func (*NymSigner) Verify

func (s *NymSigner) Verify(
	key types.IssuerPublicKey,
	Nym *math.G1,
	sigBytes, digest []byte,
) error

Verify verifies an idemix NymSignature

type POKOfBlindedMessages

type POKOfBlindedMessages struct {
	C      *ml.G1
	ProofC *bbs12381g2pub.ProofG1
}

POKOfBlindedMessages is the zero-knowledge proof that the requester knows the messages they have submitted for blind signature in the form of a Pedersen commitment.

func (*POKOfBlindedMessages) VerifyProof

func (b *POKOfBlindedMessages) VerifyProof(messages []bool, commitment *ml.G1, challenge *ml.Zr, PK *bbs12381g2pub.PublicKey) error

VerifyProof verifies the correctness of the zero knowledge proof against the supplied commitment, challenge and public key.

type RevocationAuthority

type RevocationAuthority struct {
	Rng   io.Reader
	Curve *math.Curve
}

func (*RevocationAuthority) NewKey

func (r *RevocationAuthority) NewKey() (*ecdsa.PrivateKey, error)

NewKey generates a long term signing key that will be used for revocation

func (*RevocationAuthority) NewKeyFromBytes

func (r *RevocationAuthority) NewKeyFromBytes(raw []byte) (*ecdsa.PrivateKey, error)

NewKeyFromBytes generates a long term signing key that will be used for revocation from the passed bytes

func (*RevocationAuthority) Sign

func (r *RevocationAuthority) Sign(key *ecdsa.PrivateKey, _ [][]byte, epoch int, alg types.RevocationAlgorithm) ([]byte, error)

Sign creates the Credential Revocation Information for a certain time period (epoch). Users can use the CRI to prove that they are not revoked.

func (*RevocationAuthority) Verify

func (r *RevocationAuthority) Verify(pk *ecdsa.PublicKey, criRaw []byte, epoch int, alg types.RevocationAlgorithm) error

Verify verifies that the revocation PK for a certain epoch is valid, by checking that it was signed with the long term revocation key. Note that even if we use no revocation (i.e., alg = ALG_NO_REVOCATION), we need to verify the signature to make sure the issuer indeed signed that no revocation is used in this epoch.

type Signature

type Signature struct {
	MainSignature        []byte              `protobuf:"bytes,1,opt,name=main_signature,json=mainSignature,proto3" json:"main_signature,omitempty"`
	Nonce                []byte              `protobuf:"bytes,2,opt,name=nonce,proto3" json:"nonce,omitempty"`
	Nym                  []byte              `protobuf:"bytes,3,opt,name=nym,proto3" json:"nym,omitempty"`
	NymProof             []byte              `protobuf:"bytes,4,opt,name=nym_proof,json=nymProof,proto3" json:"nym_proof,omitempty"`
	NymEid               []byte              `protobuf:"bytes,5,opt,name=nym_eid,json=nymEid,proto3" json:"nym_eid,omitempty"`
	NymEidProof          []byte              `protobuf:"bytes,6,opt,name=nym_eid_proof,json=nymEidProof,proto3" json:"nym_eid_proof,omitempty"`
	NymEidIdx            int32               `protobuf:"varint,7,opt,name=nym_eid_idx,json=nymEidIdx,proto3" json:"nym_eid_idx,omitempty"`
	NymRh                []byte              `protobuf:"bytes,8,opt,name=nym_rh,json=nymRh,proto3" json:"nym_rh,omitempty"`
	NymRhProof           []byte              `protobuf:"bytes,9,opt,name=nym_rh_proof,json=nymRhProof,proto3" json:"nym_rh_proof,omitempty"`
	NymRhIdx             int32               `protobuf:"varint,10,opt,name=nym_rh_idx,json=nymRhIdx,proto3" json:"nym_rh_idx,omitempty"`
	RevocationEpochPk    []byte              `protobuf:"bytes,11,opt,name=revocation_epoch_pk,json=revocationEpochPk,proto3" json:"revocation_epoch_pk,omitempty"`
	RevocationPkSig      []byte              `protobuf:"bytes,12,opt,name=revocation_pk_sig,json=revocationPkSig,proto3" json:"revocation_pk_sig,omitempty"`
	Epoch                int64               `protobuf:"varint,13,opt,name=epoch,proto3" json:"epoch,omitempty"`
	NonRevocationProof   *NonRevocationProof `protobuf:"bytes,14,opt,name=non_revocation_proof,json=nonRevocationProof,proto3" json:"non_revocation_proof,omitempty"`
	XXX_NoUnkeyedLiteral struct{}            `json:"-"`
	XXX_unrecognized     []byte              `json:"-"`
	XXX_sizecache        int32               `json:"-"`
}

Signature is a PoK of a BBS+ signature (a credential)

func (*Signature) Descriptor

func (*Signature) Descriptor() ([]byte, []int)

func (*Signature) GetEpoch

func (m *Signature) GetEpoch() int64

func (*Signature) GetMainSignature

func (m *Signature) GetMainSignature() []byte

func (*Signature) GetNonRevocationProof

func (m *Signature) GetNonRevocationProof() *NonRevocationProof

func (*Signature) GetNonce

func (m *Signature) GetNonce() []byte

func (*Signature) GetNym

func (m *Signature) GetNym() []byte

func (*Signature) GetNymEid

func (m *Signature) GetNymEid() []byte

func (*Signature) GetNymEidIdx

func (m *Signature) GetNymEidIdx() int32

func (*Signature) GetNymEidProof

func (m *Signature) GetNymEidProof() []byte

func (*Signature) GetNymProof

func (m *Signature) GetNymProof() []byte

func (*Signature) GetNymRh

func (m *Signature) GetNymRh() []byte

func (*Signature) GetNymRhIdx

func (m *Signature) GetNymRhIdx() int32

func (*Signature) GetNymRhProof

func (m *Signature) GetNymRhProof() []byte

func (*Signature) GetRevocationEpochPk

func (m *Signature) GetRevocationEpochPk() []byte

func (*Signature) GetRevocationPkSig

func (m *Signature) GetRevocationPkSig() []byte

func (*Signature) ProtoMessage

func (*Signature) ProtoMessage()

func (*Signature) Reset

func (m *Signature) Reset()

func (*Signature) String

func (m *Signature) String() string

func (*Signature) XXX_DiscardUnknown

func (m *Signature) XXX_DiscardUnknown()

func (*Signature) XXX_Marshal

func (m *Signature) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Signature) XXX_Merge

func (m *Signature) XXX_Merge(src proto.Message)

func (*Signature) XXX_Size

func (m *Signature) XXX_Size() int

func (*Signature) XXX_Unmarshal

func (m *Signature) XXX_Unmarshal(b []byte) error

type Signer

type Signer struct {
	Curve *math.Curve
	Rng   io.Reader
}

func (*Signer) AuditNymEid

func (s *Signer) AuditNymEid(
	key types.IssuerPublicKey,
	eidIndex int,
	signature []byte,
	enrollmentID string,
	RNymEid *math.Zr,
	verType types.AuditVerificationType,
) error

AuditNymEid permits the auditing of the nym eid generated by a signer

func (*Signer) AuditNymRh

func (s *Signer) AuditNymRh(
	key types.IssuerPublicKey,
	rhIndex int,
	signature []byte,
	revocationHandle string,
	RNymRh *math.Zr,
	verType types.AuditVerificationType,
) error

AuditNymRh permits the auditing of the nym rh generated by a signer

func (*Signer) Sign

func (s *Signer) Sign(
	credBytes []byte,
	sk *math.Zr,
	Nym *math.G1,
	RNym *math.Zr,
	key types.IssuerPublicKey,
	attributes []types.IdemixAttribute,
	msg []byte,
	rhIndex, eidIndex int,
	criRaw []byte,
	sigType types.SignatureType,
	metadata *types.IdemixSignerMetadata,
) ([]byte, *types.IdemixSignerMetadata, error)

Sign creates a new idemix signature

func (*Signer) Verify

func (s *Signer) Verify(
	key types.IssuerPublicKey,
	signature, msg []byte,
	attributes []types.IdemixAttribute,
	rhIndex, eidIndex int,
	_ *ecdsa.PublicKey,
	_ int,
	verType types.VerificationType,
	meta *types.IdemixSignerMetadata,
) error

Verify verifies an idemix signature.

type User

type User struct {
	Curve *math.Curve
	Rng   io.Reader
}

func (*User) MakeNym

func (u *User) MakeNym(sk *math.Zr, key types.IssuerPublicKey) (*math.G1, *math.Zr, error)

MakeNym creates a new unlinkable pseudonym

func (*User) NewKey

func (u *User) NewKey() (*math.Zr, error)

NewKey generates a new User secret key

func (*User) NewKeyFromBytes

func (u *User) NewKeyFromBytes(raw []byte) (*math.Zr, error)

NewKeyFromBytes converts the passed bytes to a User secret key

func (*User) NewNymFromBytes

func (u *User) NewNymFromBytes(raw []byte) (*math.G1, *math.Zr, error)

func (*User) NewPublicNymFromBytes

func (u *User) NewPublicNymFromBytes(raw []byte) (*math.G1, error)

NewPublicNymFromBytes converts the passed bytes to a public nym

Jump to

Keyboard shortcuts

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