Documentation ¶
Index ¶
- func ParseAttrs(specs map[string]interface{}) ([]CredAttr, *AttrCount, error)
- func ReadGob(filePath string, object interface{}) error
- func WriteGob(filePath string, object interface{}) error
- type AttrCount
- type Attrs
- type Cred
- type CredAttr
- type CredManager
- func (m *CredManager) BuildProof(cred *Cred, revealedKnownAttrsIndices, revealedCommitmentsOfAttrsIndices []int, ...) (*Cred, *qr.RepresentationProof, error)
- func (m *CredManager) FilterAttributes(revealedKnownAttrsIndices, revealedCommitmentsOfAttrsIndices []int) ([]*big.Int, []*big.Int)
- func (m *CredManager) GetCredRequest(nonceOrg *big.Int) (*CredRequest, error)
- func (m *CredManager) GetProofChallenge(credProofRandomData, nonceOrg *big.Int) *big.Int
- func (m *CredManager) Update(c *RawCred)
- func (m *CredManager) Verify(cred *Cred, AProof *qr.RepresentationProof) (bool, error)
- type CredRequest
- type CredResult
- type Int64Attr
- func (a *Int64Attr) FromInternalValue(val *big.Int) (interface{}, error)
- func (a Int64Attr) GetName() string
- func (a *Int64Attr) GetValue() interface{}
- func (a Int64Attr) HasVal() bool
- func (a Int64Attr) InternalValue() *big.Int
- func (a Int64Attr) IsKnown() bool
- func (a *Int64Attr) SetInternalValue() error
- func (a *Int64Attr) String() string
- func (a *Int64Attr) UpdateValue(n interface{}) error
- type KeyPair
- type MockRecordManager
- type Org
- func (o *Org) GenNonce() *big.Int
- func (o *Org) GetCredIssueNonce() *big.Int
- func (o *Org) GetProveCredNonce() *big.Int
- func (o *Org) IssueCred(cr *CredRequest) (*CredResult, error)
- func (o *Org) ProveCred(A *big.Int, proof *qr.RepresentationProof, ...) (bool, error)
- func (o *Org) UpdateCred(nym *big.Int, rec *ReceiverRecord, nonceUser *big.Int, ...) (*CredResult, error)
- type Params
- type PubKey
- type RawCred
- func (c *RawCred) AddEmptyInt64Attr(name string, known bool) error
- func (c *RawCred) AddEmptyStrAttr(name string, known bool) error
- func (c *RawCred) AddInt64Attr(name string, val int64, known bool) error
- func (c *RawCred) AddStrAttr(name, val string, known bool) error
- func (c *RawCred) GetAttr(name string) (CredAttr, error)
- func (c *RawCred) GetAttrInternalIndex(attrName string) (int, error)
- func (c *RawCred) GetAttrs() map[int]CredAttr
- func (c *RawCred) GetCommittedVals() []*big.Int
- func (c *RawCred) GetKnownVals() []*big.Int
- type ReceiverRecord
- type ReceiverRecordManager
- type RedisClient
- type SecKey
- type StrAttr
- func (a *StrAttr) FromInternalValue(val *big.Int) (interface{}, error)
- func (a StrAttr) GetName() string
- func (a *StrAttr) GetValue() interface{}
- func (a StrAttr) HasVal() bool
- func (a StrAttr) InternalValue() *big.Int
- func (a StrAttr) IsKnown() bool
- func (a *StrAttr) SetInternalValue() error
- func (a *StrAttr) String() string
- func (a *StrAttr) UpdateValue(s interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseAttrs ¶
FIXME make nicer Hook to organization?
Types ¶
type AttrCount ¶
AttrCount holds the number of known, committed and hidden parameters.
func NewAttrCount ¶
type Attrs ¶
type CredAttr ¶
type CredAttr interface { GetValue() interface{} FromInternalValue(*big.Int) (interface{}, error) UpdateValue(interface{}) error InternalValue() *big.Int SetInternalValue() error IsKnown() bool HasVal() bool GetName() string String() string }
CredAttr represents an attribute for the CL scheme.
type CredManager ¶
type CredManager struct { Params *Params PubKey *PubKey RawCred *RawCred Nym *big.Int Attrs *Attrs CommitmentsOfAttrs []*big.Int // commitments of committedAttrs // V1 is a random element in credential - it is generated in GetCredRequest and needed when // proving the possesion of a credential - this is why it is stored in User and not in UserCredentialReceiver V1 *big.Int // v1 is random element in U; U = S^v1 * R_i^m_i where m_i are hidden attributes CredReqNonce *big.Int // contains filtered or unexported fields }
CredManager manages a single instance of anonymous credential.
An instance of this struct should be created by a user before she wants a new credential to be issued, or an existing one to be updated or proved.
When a user needs a new credential under a new nym, she also needs a new instance of CredManager.
func NewCredManager ¶
func (*CredManager) BuildProof ¶
func (m *CredManager) BuildProof(cred *Cred, revealedKnownAttrsIndices, revealedCommitmentsOfAttrsIndices []int, nonceOrg *big.Int) (*Cred, *qr.RepresentationProof, error)
BuildProof builds a proof of knowledge for the given credential.
func (*CredManager) FilterAttributes ¶
func (m *CredManager) FilterAttributes(revealedKnownAttrsIndices, revealedCommitmentsOfAttrsIndices []int) ([]*big.Int, []*big.Int)
FilterAttributes returns only attributes to be revealed to the verifier.
func (*CredManager) GetCredRequest ¶
func (m *CredManager) GetCredRequest(nonceOrg *big.Int) (*CredRequest, error)
GetCredRequest computes U and returns CredRequest which contains: - proof data for proving that nym was properly generated, - U and proof data that U was properly generated, - proof data for proving the knowledge of opening for commitments of attributes (for those attributes for which the committed value is known).
func (*CredManager) GetProofChallenge ¶
func (m *CredManager) GetProofChallenge(credProofRandomData, nonceOrg *big.Int) *big.Int
func (*CredManager) Verify ¶
func (m *CredManager) Verify(cred *Cred, AProof *qr.RepresentationProof) (bool, error)
Verify verifies anonymous credential cred, returning a boolean indicating success or failure of credential verification. When verification process fails due to misconfiguration, error is returned.
type CredRequest ¶
type CredRequest struct { Nym *big.Int KnownAttrs []*big.Int CommitmentsOfAttrs []*big.Int NymProof *schnorr.Proof U *big.Int UProof *qr.RepresentationProof CommitmentsOfAttrsProofs []*df.OpeningProof Nonce *big.Int }
func NewCredRequest ¶
func NewCredRequest(nym *big.Int, knownAttrs, commitmentsOfAttrs []*big.Int, nymProof *schnorr.Proof, U *big.Int, UProof *qr.RepresentationProof, commitmentsOfAttrsProofs []*df.OpeningProof, nonce *big.Int) *CredRequest
type CredResult ¶
type CredResult struct { Cred *Cred AProof *qr.RepresentationProof Record *ReceiverRecord }
type Int64Attr ¶
type Int64Attr struct {
// contains filtered or unexported fields
}
func NewEmptyInt64Attr ¶
func (*Int64Attr) FromInternalValue ¶
func (Int64Attr) InternalValue ¶
func (*Int64Attr) SetInternalValue ¶
func (*Int64Attr) UpdateValue ¶
type MockRecordManager ¶
type MockRecordManager struct {
// contains filtered or unexported fields
}
MockRecordManager is a mock implementation of the ReceiverRecordManager interface. It stores key-value pairs of nyms and corresponding receiver records in a map.
func NewMockRecordManager ¶
func NewMockRecordManager() *MockRecordManager
NewMockRecordManager initializes the map that will hold the data.
func (*MockRecordManager) Load ¶
func (rm *MockRecordManager) Load(nym *big.Int) (*ReceiverRecord, error)
func (*MockRecordManager) Store ¶
func (rm *MockRecordManager) Store(nym *big.Int, r *ReceiverRecord) error
type Org ¶
type Org struct { Params *Params Group *qr.RSASpecial // in this group attributes will be used as exponents (basis is PubKey.Rs...) U *big.Int UVerifier *qr.RepresentationVerifier Keys *KeyPair // contains filtered or unexported fields }
func (*Org) GetCredIssueNonce ¶
func (*Org) GetProveCredNonce ¶
func (*Org) IssueCred ¶
func (o *Org) IssueCred(cr *CredRequest) (*CredResult, error)
func (*Org) ProveCred ¶
func (o *Org) ProveCred(A *big.Int, proof *qr.RepresentationProof, revealedKnownAttrsIndices, revealedCommitmentsOfAttrsIndices []int, revealedKnownAttrs, revealedCommitmentsOfAttrs []*big.Int) (bool, error)
ProveCred proves the possession of a valid credential and reveals only the attributes the user desires to reveal. Which knownAttrs and commitmentsOfAttrs are to be revealed are given by revealedKnownAttrsIndices and revealedCommitmentsOfAttrsIndices parameters. Parameters knownAttrs and commitmentsOfAttrs must contain only known attributes and commitments of attributes (of attributes for which only commitment is known) which are to be revealed to the organization.
func (*Org) UpdateCred ¶
func (o *Org) UpdateCred(nym *big.Int, rec *ReceiverRecord, nonceUser *big.Int, newKnownAttrs []*big.Int) (*CredResult, error)
type Params ¶
type Params struct { // There are only a few possibilities for RhoBitLen. 256 implies that the modulus // bit length is 2048 RhoBitLen int // bit length of order of the commitment group NLength int // bit length of RSA modulus KnownAttrsNum int // number of attributes known to both - credential issuer and receiver CommittedAttrsNum int // number of attributes for which the issuer knows only commitments HiddenAttrsNum int // number of attributes known only to the receiver AttrBitLen int // bit length of attribute HashBitLen int // bit length of hash output used for Fiat-Shamir SecParam int // security parameter EBitLen int // size of e values of certificates E1BitLen int // size of the interval the e values are taken from VBitLen int // size of the v values of the certificates ChallengeSpace int // bit length of challenges for DF commitment proofs }
Params presents parameters that organization (which is issuing credentials) needs to set.
func GetDefaultParamSizes ¶
func GetDefaultParamSizes() *Params
TODO: add method to load params from file or blockchain or wherever they will be stored.
type PubKey ¶
type PubKey struct { N *big.Int S *big.Int Z *big.Int RsKnown []*big.Int // one R corresponds to one attribute - these attributes are known to both - receiver and issuer RsCommitted []*big.Int // issuer knows only commitments of these attributes RsHidden []*big.Int // only receiver knows these attributes PedersenParams *pedersen.Params // the fields below are for commitments of the (committed) attributes N1 *big.Int G *big.Int H *big.Int }
PubKey is a public key for the CL scheme.
func NewPubKey ¶
NewPubKey accepts group g, parameters p and commitment receiver recv, and returns a public key for the CL scheme.
func (*PubKey) GenerateUserMasterSecret ¶
GenerateUserMasterSecret generates a secret key that needs to be encoded into every user's credential as a sharing prevention mechanism.
func (*PubKey) GetContext ¶
GetContext concatenates public parameters and returns a corresponding number.
type RawCred ¶
type RawCred struct {
// contains filtered or unexported fields
}
RawCred represents a credential to be used by application that executes the scheme to prove possesion of an anonymous credential.
func NewRawCred ¶
func (*RawCred) AddEmptyInt64Attr ¶
func (*RawCred) AddInt64Attr ¶
func (*RawCred) GetAttrInternalIndex ¶
func (*RawCred) GetCommittedVals ¶
GetCommittedVals returns *big.Int values of committed attributes. The returned elements are ordered by attribute's index.
func (*RawCred) GetKnownVals ¶
GetKnownVals returns *big.Int values of known attributes. The returned elements are ordered by attribute's index.
type ReceiverRecord ¶
type ReceiverRecord struct { KnownAttrs []*big.Int CommitmentsOfAttrs []*big.Int Q *big.Int V11 *big.Int Context *big.Int }
func NewReceiverRecord ¶
func NewReceiverRecord(knownAttrs, commitmentsOfAttrs []*big.Int, Q, v11, context *big.Int) *ReceiverRecord
Returns ReceiverRecord which contains user data needed when updating the credential for this user.
func (*ReceiverRecord) MarshalBinary ¶
func (r *ReceiverRecord) MarshalBinary() ([]byte, error)
func (*ReceiverRecord) UnmarshalBinary ¶
func (r *ReceiverRecord) UnmarshalBinary(data []byte) error
type ReceiverRecordManager ¶
type ReceiverRecordManager interface { // Store stores the nym and the corresponding ReceiverRecord, // returning error in case the data was not successfully stored. Store(*big.Int, *ReceiverRecord) error // Load loads the ReceiverRecord associated with the given // nym, returning an error in case no record was found, or // in case of error in the interaction with the // storage backend. Load(*big.Int) (*ReceiverRecord, error) }
ReceiverRecordManager manages receiver records tied to particular nyms.
type RedisClient ¶
RedisClient wraps a redis client in order to interact with the redis database for management of receiver records.
func NewRedisClient ¶
func NewRedisClient(c *redis.Client) *RedisClient
NewRedisClient accepts an instance of redis.Client and returns an instance of RedisClient.
func (*RedisClient) Load ¶
func (m *RedisClient) Load(nym *big.Int) (*ReceiverRecord, error)
func (*RedisClient) Store ¶
func (m *RedisClient) Store(nym *big.Int, r *ReceiverRecord) error
type SecKey ¶
type SecKey struct { RsaPrimes *qr.RSASpecialPrimes AttributesSpecialRSAPrimes *qr.RSASpecialPrimes }
SecKey is a secret key for the CL scheme.
type StrAttr ¶
type StrAttr struct {
// contains filtered or unexported fields
}