Documentation ¶
Index ¶
- func GetDefaultParamSizes() *pb.Params
- func ReadGob(filePath string, object interface{}) error
- func WriteGob(filePath string, object interface{}) error
- type Attr
- type AttrCond
- type AttrCount
- type AttrDataFetcher
- type Attrs
- type Client
- func (c *Client) GetAcceptableCreds() (map[string][]string, error)
- func (c *Client) GetPublicParams() (*PubParams, error)
- func (c *Client) IssueCredential(cm *CredManager, regKey string) (*Cred, error)
- func (c *Client) ProveCredential(cm *CredManager, cred *Cred, revealedAttrs []string) (*string, error)
- func (c *Client) UpdateCredential(cm *CredManager, rawCred *RawCred) (*Cred, error)
- 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) GetContext() *CredManagerCtx
- 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 CredManagerCtx
- type CredRequest
- type CredResult
- type Int64Attr
- 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 PubKey
- type PubParams
- type RawCred
- type ReceiverRecord
- type ReceiverRecordManager
- type RedisClient
- type RedisDataFetcher
- type SecKey
- type Server
- func (s *Server) GetAcceptableCreds(ctx context.Context, msg *pb.Empty) (*pb.AcceptableCreds, error)
- func (s *Server) GetPublicParams(ctx context.Context, msg *pb.Empty) (*pb.PublicParams, error)
- func (s *Server) Issue(stream pb.AnonCreds_IssueServer) error
- func (s *Server) Prove(stream pb.AnonCreds_ProveServer) error
- func (s *Server) RegisterTo(grpcSrv *grpc.Server)
- func (s *Server) Update(ctx context.Context, req *pb.CredUpdateRequest) (*pb.IssuedCred, error)
- type StrAttr
- type Validatable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultParamSizes ¶
TODO: add method to load params from file or blockchain or wherever they will be stored.
Types ¶
type Attr ¶
type Attr struct { Known bool ValSet bool Val *big.Int Index int // contains filtered or unexported fields }
Attr is part of a credential (RawCredential). In the case of digital identity credential, attributes could be for example name, Gender, Date of Birth. In the case of a credential allowing access to some internet service (like electronic newspaper), attributes could be Type (for example only news related to politics) of the service and Date of Expiration.
type AttrCount ¶
AttrCount holds the number of Known, Committed and Hidden parameters.
func NewAttrCount ¶
type AttrDataFetcher ¶
type Attrs ¶
type Client ¶
type Client struct {
pb.AnonCredsClient // TODO fix my name
}
func NewClient ¶
func NewClient(conn *grpc.ClientConn) *Client
func (*Client) GetAcceptableCreds ¶
func (*Client) GetPublicParams ¶
func (*Client) IssueCredential ¶
func (c *Client) IssueCredential(cm *CredManager, regKey string) (*Cred, error)
func (*Client) ProveCredential ¶
func (c *Client) ProveCredential(cm *CredManager, cred *Cred, revealedAttrs []string) (*string, 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. All knownAttrs and commitmentsOfAttrs should be passed into ProveCred - only those which are revealed are then passed to the server.
func (*Client) UpdateCredential ¶
func (c *Client) UpdateCredential(cm *CredManager, rawCred *RawCred) (*Cred, error)
type CredAttr ¶
type CredAttr interface { UpdateValue(interface{}) error Name() string String() string Validatable // contains filtered or unexported methods }
CredAttr represents an attribute for the CL scheme.
type CredManager ¶
type CredManager struct { Params *clpb.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 RestoreCredManager ¶
func RestoreCredManager(ctx *CredManagerCtx, secret *big.Int, rc *RawCred) (*CredManager, error)
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) GetContext ¶
func (m *CredManager) GetContext() *CredManagerCtx
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 CredManagerCtx ¶
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 ¶
func NewEmptyInt64Attr ¶
func (*Int64Attr) UpdateValue ¶
func (*Int64Attr) ValidateAgainst ¶
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 *pb.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, attrs []CredAttr, actual map[string]interface{}) (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 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 ¶
func NewPubKey(g *qr.RSASpecial, p *pb.Params, attrs *AttrCount, recv *df.Receiver) (*PubKey, error)
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 PubParams ¶
type PubParams struct { PubKey *PubKey RawCred *RawCred // contains credential structure Config *pb.Params }
PubParams keeps all the public parameters for the scheme. These can be propagated from the server to the client.
type RawCred ¶
RawCred represents a credential to be used by application that executes the scheme to prove possesion of an anonymous credential.
func NewRawCred ¶
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.
func (*RawCred) UpdateAttr ¶
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 RedisDataFetcher ¶
func NewRedisDataFetcher ¶
func NewRedisDataFetcher(c *redis.Client) *RedisDataFetcher
func (*RedisDataFetcher) FetchAttrData ¶
func (f *RedisDataFetcher) FetchAttrData() (map[string]interface{}, error)
type SecKey ¶
type SecKey struct { RsaPrimes *qr.RSASpecialPrimes AttributesSpecialRSAPrimes *qr.RSASpecialPrimes }
SecKey is a secret key for the CL scheme.
type Server ¶
type Server struct { ReceiverRecordManager *Org SessMgr anauth.SessManager SessStorer anauth.SessStorer RegMgr anauth.RegManager DataFetcher AttrDataFetcher // contains filtered or unexported fields }
func (*Server) GetAcceptableCreds ¶
func (*Server) GetPublicParams ¶
func (*Server) RegisterTo ¶
func (*Server) Update ¶
func (s *Server) Update(ctx context.Context, req *pb.CredUpdateRequest) (*pb.IssuedCred, error)
type StrAttr ¶
func NewEmptyStrAttr ¶
func (*StrAttr) UpdateValue ¶
func (*StrAttr) ValidateAgainst ¶
type Validatable ¶
Validatable validates against a credential attribute.