Documentation ¶
Index ¶
- Constants
- func AddProof(cred claimtypes.Credential, signerDID *didlib.DID, pk *ecdsa.PrivateKey) error
- func CanonicalizeCredential(cred *claimtypes.ContentCredential) ([]byte, error)
- func GetIssuerDIDfromToken(token *jwt.Token) (*didlib.DID, error)
- type ECDSASigner
- type FakeRootCommitter
- type JWTService
- func (s *JWTService) AddJWTClaim(tokenString string, senderDID *didlib.DID) (*jwt.Token, error)
- func (s *JWTService) GenerateProof(tokenString string) (*MTProof, error)
- func (s *JWTService) GetJWTSforDID(userDID *didlib.DID) ([]*jwt.Token, error)
- func (s *JWTService) GetJWTSforSubjectsOrIssuers(issuers []string, subjects []string) ([]*claimsstore.JWTClaimPostgres, error)
- func (s *JWTService) RevokeJWTClaim(tokenString string) error
- type MTProof
- type ProgressUpdate
- type RootCommitter
- type RootCommitterInterface
- type RootService
- type Service
- func (s *Service) AddNewRootClaim(userDid *didlib.DID) error
- func (s *Service) BuildDIDMt(userDid *didlib.DID) (*merkletree.MerkleTree, error)
- func (s *Service) ClaimContent(cred *claimtypes.ContentCredential) error
- func (s *Service) ClaimLicense(cred *claimtypes.LicenseCredential, claimer *didlib.DID) error
- func (s *Service) ClaimsToContentCredentials(clms []merkletree.Claim) ([]*claimtypes.ContentCredential, error)
- func (s *Service) CreateTreeForDID(userDid *didlib.DID) error
- func (s *Service) CreateTreeForDIDWithPks(userDid *didlib.DID, signPks []*ecdsa.PublicKey) error
- func (s *Service) GenerateProof(claim claimtypes.Credential) (*MTProof, error)
- func (s *Service) GenerateProofRegistedDocument(rdClaim *claimtypes.ClaimRegisteredDocument, issuer *didlib.DID) (*MTProof, error)
- func (s *Service) GetDIDRoot(did *didlib.DID) (*merkletree.Hash, error)
- func (s *Service) GetMerkleTreeClaimsForDid(userDid *didlib.DID) ([]merkletree.Claim, error)
- func (s *Service) GetRootMerkleTreeClaims() ([]merkletree.Claim, error)
- func (s *Service) RevokeClaim(cred claimtypes.Credential, claimer *didlib.DID) error
- type Signer
Constants ¶
const ( // Done signifies indexing is finished or errored Done = "done" // Started signifies indexing has begun Started = "started" )
Variables ¶
This section is empty.
Functions ¶
func AddProof ¶
func AddProof(cred claimtypes.Credential, signerDID *didlib.DID, pk *ecdsa.PrivateKey) error
AddProof takes a content cred a did and a pk and adds a proof to it
func CanonicalizeCredential ¶
func CanonicalizeCredential(cred *claimtypes.ContentCredential) ([]byte, error)
CanonicalizeCredential removes the proof and returns json bytes
func GetIssuerDIDfromToken ¶
GetIssuerDIDfromToken returns the issuer did from a jwt
Types ¶
type ECDSASigner ¶
type ECDSASigner struct {
// contains filtered or unexported fields
}
ECDSASigner implements the signer interface for a given private key
func NewECDSASigner ¶
func NewECDSASigner(privKey *ecdsa.PrivateKey) *ECDSASigner
NewECDSASigner returns a new ecdsa signer
func (ECDSASigner) Sign ¶
func (s ECDSASigner) Sign(claim *claimtypes.ContentCredential, creator string) error
Sign takes a credential and a creator did and adds the proof
type FakeRootCommitter ¶
FakeRootCommitter fakes the blockchain part of the committing roots for testing
func (*FakeRootCommitter) CommitRoot ¶
func (r *FakeRootCommitter) CommitRoot(root [32]byte, c chan<- *ProgressUpdate)
CommitRoot fakely commits the root
func (*FakeRootCommitter) GetAccount ¶
func (r *FakeRootCommitter) GetAccount() common.Address
GetAccount returns an account that could have been the one used for testing
type JWTService ¶
type JWTService struct {
// contains filtered or unexported fields
}
JWTService is a service for registering JWT claims
func NewJWTService ¶
func NewJWTService(didJWTService *didjwt.Service, jwtPersister *claimsstore.JWTClaimPGPersister, claimService *Service, natsService pubsub.PublisherInterface) *JWTService
NewJWTService creates a new instance of the service
func (*JWTService) AddJWTClaim ¶
func (s *JWTService) AddJWTClaim(tokenString string, senderDID *didlib.DID) (*jwt.Token, error)
AddJWTClaim adds a new jwt claim to it's issuers tree
func (*JWTService) GenerateProof ¶
func (s *JWTService) GenerateProof(tokenString string) (*MTProof, error)
GenerateProof creates a proof from a jwt
func (*JWTService) GetJWTSforDID ¶
func (s *JWTService) GetJWTSforDID(userDID *didlib.DID) ([]*jwt.Token, error)
GetJWTSforDID returns all jwt claims for a DID
func (*JWTService) GetJWTSforSubjectsOrIssuers ¶
func (s *JWTService) GetJWTSforSubjectsOrIssuers(issuers []string, subjects []string) ([]*claimsstore.JWTClaimPostgres, error)
GetJWTSforSubjectsOrIssuers gets the token by subjects or issuers
func (*JWTService) RevokeJWTClaim ¶
func (s *JWTService) RevokeJWTClaim(tokenString string) error
RevokeJWTClaim takes a token and revokes it in the merkle tree
type MTProof ¶
type MTProof struct { ExistsInDIDMTProof string `json:"entryExistsInIssuerTree"` // HEX NotRevokedInDIDMTProof string `json:"entryNotRevokedInIssuerTree"` // HEX DIDRootExistsProof string `json:"issuerRootExistsInRelayTree"` // HEX DIDRootExistsVersion uint32 `json:"issuerRootVersion"` // The version of the claim in the tree, this is needed to verify the proof BlockNumber int64 `json:"blockNumber"` ContractAddress common.Address `json:"contractAddress"` TXHash common.Hash `json:"txHash"` Root merkletree.Hash `json:"relayTreeRoot"` DIDRoot merkletree.Hash `json:"issuerTreeRoot"` CommitterAddress common.Address `json:"relayAddress"` DID string `json:"issuer"` }
MTProof is
type ProgressUpdate ¶
ProgressUpdate format for passing status of the transaction to the main routine
type RootCommitter ¶
RootCommitter performs the transaction that commits the root to the blockchain and awaits completion
func NewRootCommitter ¶
func NewRootCommitter(ethHelper *eth.Helper, transactionReader ethereum.TransactionReader, address string) (*RootCommitter, error)
NewRootCommitter constructs a new root committer
func (*RootCommitter) CommitRoot ¶
func (r *RootCommitter) CommitRoot(root [32]byte, c chan<- *ProgressUpdate)
CommitRoot given a root performs the transaction to add it to the contract
func (*RootCommitter) GetAccount ¶
func (r *RootCommitter) GetAccount() ethCommon.Address
GetAccount returns the default eth account used for the commit
type RootCommitterInterface ¶
type RootCommitterInterface interface { GetAccount() ethCommon.Address CommitRoot(root [32]byte, c chan<- *ProgressUpdate) }
RootCommitterInterface specifies the interface of the struct that interacts with the blockchain
type RootService ¶
type RootService struct {
// contains filtered or unexported fields
}
RootService coordinates publishing the root to the blockchain and saving the result to pg
func NewRootService ¶
func NewRootService(treeStore db.Storage, committer RootCommitterInterface, persister *claimsstore.RootCommitsPGPersister) (*RootService, error)
NewRootService constructs a new root service
func (*RootService) CommitRoot ¶
func (s *RootService) CommitRoot() error
CommitRoot commits the current root of the root tree to the contract and saves the blocknumber and transaction in pg
func (*RootService) GetCurrent ¶
func (s *RootService) GetCurrent() (string, error)
GetCurrent returns the current root
func (*RootService) GetLatest ¶
func (s *RootService) GetLatest() (*claimsstore.RootCommit, error)
GetLatest returns the latest committed root
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a service for creating and reading claims
func NewService ¶
func NewService(treeStore *claimsstore.PGStore, signedClaimStore *claimsstore.SignedClaimPGPersister, didService *did.Service, rootService *RootService, dlock lock.DLock) (*Service, error)
NewService returns a new service
func (*Service) AddNewRootClaim ¶
AddNewRootClaim adds a new root claim for a did in the root tree
func (*Service) BuildDIDMt ¶
func (s *Service) BuildDIDMt(userDid *didlib.DID) (*merkletree.MerkleTree, error)
BuildDIDMt takes a did and returns a merkle tree with that tree as a prefix
func (*Service) ClaimContent ¶
func (s *Service) ClaimContent(cred *claimtypes.ContentCredential) error
ClaimContent takes a content credential and saves it to the signed credential table and then registers it in the tree
func (*Service) ClaimLicense ¶
func (s *Service) ClaimLicense(cred *claimtypes.LicenseCredential, claimer *didlib.DID) error
ClaimLicense adds a license claim to the claimers claim tree
func (*Service) ClaimsToContentCredentials ¶
func (s *Service) ClaimsToContentCredentials(clms []merkletree.Claim) ( []*claimtypes.ContentCredential, error)
ClaimsToContentCredentials converts a list of merkletree.Claim interfaces to concrete ContentCredentials. Filters out claims not of type ContentCredential.
func (*Service) CreateTreeForDID ¶
CreateTreeForDID creates a new tree for a user DID if it does not exist already.
func (*Service) CreateTreeForDIDWithPks ¶
CreateTreeForDIDWithPks creates a new merkle tree for the did and registers a slice of public key that can be used for signing with this did Can also be used to add additional key claims to the userDID MT
func (*Service) GenerateProof ¶
func (s *Service) GenerateProof(claim claimtypes.Credential) (*MTProof, error)
GenerateProof returns a proof that the content credential is in the tree and on the blockchain
func (*Service) GenerateProofRegistedDocument ¶
func (s *Service) GenerateProofRegistedDocument(rdClaim *claimtypes.ClaimRegisteredDocument, issuer *didlib.DID) (*MTProof, error)
GenerateProofRegistedDocument creates a proof for any registered document
func (*Service) GetDIDRoot ¶
GetDIDRoot returns the root hash of a dids tree
func (*Service) GetMerkleTreeClaimsForDid ¶
GetMerkleTreeClaimsForDid returns all the claims in a DID's merkletree
func (*Service) GetRootMerkleTreeClaims ¶
func (s *Service) GetRootMerkleTreeClaims() ([]merkletree.Claim, error)
GetRootMerkleTreeClaims returns all root claims
func (*Service) RevokeClaim ¶
func (s *Service) RevokeClaim(cred claimtypes.Credential, claimer *didlib.DID) error
RevokeClaim adds a revocation to the registered doc associated with a credential
type Signer ¶
type Signer interface {
Sign(claim *claimtypes.ContentCredential, creator string) error
}
Signer interface is for signing content claims