Documentation ¶
Index ¶
- func GetGroupKeyFromAddress(address ethcommon.Address, ctx *UserContext) error
- func NewAccount(username string, storage *fs.Storage) (interfaces.IAccount, error)
- func NewAccountFromStorage(storage *fs.Storage, backend chequebook.Backend) (interfaces.IAccount, error)
- func NewGroup(address ethcommon.Address, groupName string, storage *fs.Storage) interfaces.IGroup
- func NewGroupFromMeta(meta *meta.GroupMeta, storage *fs.Storage) interfaces.IGroup
- type Account
- func (acc *Account) Boxer() tribecrypto.AnonymBoxer
- func (acc *Account) Contract() *ethacc.Account
- func (acc *Account) ContractAddress() ethcommon.Address
- func (acc *Account) Name() string
- func (acc *Account) Save() error
- func (acc *Account) SetContract(address ethcommon.Address, backend chequebook.Backend) error
- type AccountData
- type Auth
- type Eth
- type FileView
- type Group
- func (g *Group) AddMember(account ethcommon.Address)
- func (g *Group) Address() ethcommon.Address
- func (g *Group) Boxer() tribecrypto.SymmetricKey
- func (g *Group) CountMembers() int
- func (g *Group) Encode() ([]byte, error)
- func (g *Group) EncryptedIpfsHash() []byte
- func (g *Group) IpfsHash() string
- func (g *Group) IsMember(account ethcommon.Address) bool
- func (g *Group) Members() []ethcommon.Address
- func (g *Group) Name() string
- func (g *Group) RemoveMember(account ethcommon.Address)
- func (g *Group) Save() error
- func (g *Group) SetBoxer(boxer tribecrypto.SymmetricKey)
- func (g *Group) SetIpfsHash(encIpfsHash []byte) error
- func (g *Group) Update(name string, members []ethcommon.Address, encIpfsHash []byte) error
- type GroupContext
- func (groupCtx *GroupContext) Address() ethcommon.Address
- func (groupCtx *GroupContext) CommitChanges() error
- func (groupCtx *GroupContext) GrantWriteAccess(filePath string, user ethcommon.Address) error
- func (groupCtx *GroupContext) HandleGroupInvitationAcceptedEvents(group *ethgroup.Group)
- func (groupCtx *GroupContext) HandleGroupInvitationSentEvents(group *ethgroup.Group)
- func (groupCtx *GroupContext) HandleIpfsHashChangedEvents(group *ethgroup.Group)
- func (groupCtx *GroupContext) HandleNewConsensusEvents(group *ethgroup.Group)
- func (groupCtx *GroupContext) Invite(newMember ethcommon.Address, hasInviteRight bool) error
- func (groupCtx *GroupContext) Leave() error
- func (groupCtx *GroupContext) ListFiles() []FileView
- func (groupCtx *GroupContext) ListMembers() []MemberView
- func (groupCtx *GroupContext) Name() string
- func (groupCtx *GroupContext) RevokeWriteAccess(filePath string, user ethcommon.Address) error
- func (groupCtx *GroupContext) Save() error
- func (groupCtx *GroupContext) Stop()
- func (groupCtx *GroupContext) Update() error
- type GroupContextConfig
- type GroupEth
- type IGroupFacade
- type IUserFacade
- type MemberView
- type UserContext
- func (ctx *UserContext) AcceptInvitation(groupAddress ethcommon.Address) error
- func (ctx *UserContext) BuildGroups() error
- func (ctx *UserContext) CreateGroup(groupname string) error
- func (ctx *UserContext) GetBoxerOfGroup(group ethcommon.Address) (tribecrypto.SymmetricKey, error)
- func (ctx *UserContext) GetProposedBoxerOfGroup(group ethcommon.Address, proposer ethcommon.Address) (tribecrypto.SymmetricKey, error)
- func (ctx *UserContext) Groups() []IGroupFacade
- func (ctx *UserContext) HandleAccountCreatedEvents(app *ethapp.FileTribeDApp)
- func (ctx *UserContext) HandleGroupCreatedEvents(acc *ethacc.Account)
- func (ctx *UserContext) HandleGroupInvitationEvents(acc *ethacc.Account)
- func (ctx *UserContext) HandleInvitationAcceptedEvents(acc *ethacc.Account)
- func (ctx *UserContext) Init(acc interfaces.IAccount) error
- func (ctx *UserContext) IsMember(group ethcommon.Address, account ethcommon.Address) error
- func (ctx *UserContext) ListFiles() map[string][]string
- func (ctx *UserContext) Save() error
- func (ctx *UserContext) SignOut()
- func (ctx *UserContext) SignUp(username string) error
- func (ctx *UserContext) Transactions() ([]*types.Transaction, error)
- func (ctx *UserContext) User() interfaces.IAccount
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetGroupKeyFromAddress ¶
func GetGroupKeyFromAddress(address ethcommon.Address, ctx *UserContext) error
GetGroupKeyFromAddress tries to get the group key of a group with the given address
func NewAccount ¶
NewAccount creates a new empty account without any smart contract data
func NewAccountFromStorage ¶
func NewAccountFromStorage(storage *fs.Storage, backend chequebook.Backend) (interfaces.IAccount, error)
NewAccountFromStorage loads an existing account from disk
func NewGroupFromMeta ¶
NewGroupFromMeta creates a new Group from an existing GroupMeta file stored on disk
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
Account is a wrapper object around a smart contract of type Account
func (*Account) Boxer ¶
func (acc *Account) Boxer() tribecrypto.AnonymBoxer
Boxer returns the private key of the account
func (*Account) ContractAddress ¶
ContractAddress returns the address of its smart contract
func (*Account) SetContract ¶
SetContract stores the smart contract address of an account and its smart contract object
type AccountData ¶
type AccountData struct { Name string ContractAddress ethcommon.Address Boxer tribecrypto.AnonymBoxer // might be deleted if libp2p is encrypted }
AccountData represents those data of an account object that can be saved on disk
type Auth ¶
type Auth struct { Address ethcommon.Address TxOpts *bind.TransactOpts // contains filtered or unexported fields }
Auth stores all the information of an Ethereum account with which one can sign transactions
type Eth ¶
type Eth struct { Auth *Auth App *ethapp.FileTribeDApp Backend chequebook.Backend }
Eth is a collection of those objects that are necessary for performing operations on the blockchain such as authentication data, DApp contract and a full ethereum node
type FileView ¶
type FileView struct { Name string WriteAccess []MemberView }
FileView is a view of a file objects. These objects are sent back to main.go when it lists the group repository
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is the mirror object of a Group smart contract
func (*Group) CountMembers ¶
CountMembers returns the number of members
func (*Group) EncryptedIpfsHash ¶
EncryptedIpfsHash returns the group's current encrypted IPFS hash
func (*Group) RemoveMember ¶
RemoveMember removes an account from the member list
func (*Group) SetBoxer ¶
func (g *Group) SetBoxer(boxer tribecrypto.SymmetricKey)
SetBoxer is a setter for the group key
func (*Group) SetIpfsHash ¶
SetIpfsHash decrypts an encrypted IPFS hash and stores both the decrypted one and the encrypted one. Note that it is not enough to only receive ipfsHash and encrypt it and use that as encryptedIpfsHash because the encryption uses a random element when producing the cipher text, therefore on each instance of the ipfs-share daemon, the ecnryptedIpfsHash's will be different
type GroupContext ¶
type GroupContext struct { Group interfaces.IGroup P2P *com.P2PManager Repo *fs.GroupRepo GroupConnection *com.GroupConnection AddressBook *common.AddressBook Ipfs ipfsapi.IIpfs Storage *fs.Storage Transactions *List // contains filtered or unexported fields }
GroupContext represents a groups current state and is responsible for all the communication, storage, encryption work
func NewGroupContext ¶
func NewGroupContext(config *GroupContextConfig) (*GroupContext, error)
NewGroupContext creates a GroupContext with data described in the provided configuration object
func (*GroupContext) Address ¶
func (groupCtx *GroupContext) Address() ethcommon.Address
Address returns the smart contract address of the group
func (*GroupContext) CommitChanges ¶
func (groupCtx *GroupContext) CommitChanges() error
CommitChanges collects all changes in the group's root directory, creates a path from it and commits the changes on the blockchain
func (*GroupContext) GrantWriteAccess ¶
func (groupCtx *GroupContext) GrantWriteAccess(filePath string, user ethcommon.Address) error
GrantWriteAccess adds the defined user to the write ACL in the file meta
func (*GroupContext) HandleGroupInvitationAcceptedEvents ¶
func (groupCtx *GroupContext) HandleGroupInvitationAcceptedEvents(group *ethgroup.Group)
HandleGroupInvitationAcceptedEvents listens to GroupInvitationAccepted events on the blockchain and adds the new member to the group, if it receives one
func (*GroupContext) HandleGroupInvitationSentEvents ¶
func (groupCtx *GroupContext) HandleGroupInvitationSentEvents(group *ethgroup.Group)
HandleGroupInvitationSentEvents listens to GroupInvitationSent events on the blockchain
func (*GroupContext) HandleIpfsHashChangedEvents ¶
func (groupCtx *GroupContext) HandleIpfsHashChangedEvents(group *ethgroup.Group)
HandleIpfsHashChangedEvents listens to IpfsHashChanged events on the blockchain and if it receives one, it updates the group IPFS hash and fetches its contents
func (*GroupContext) HandleNewConsensusEvents ¶
func (groupCtx *GroupContext) HandleNewConsensusEvents(group *ethgroup.Group)
HandleNewConsensusEvents listens to NewConsensus events on the blockchain and checks if the target of the consensus is correct. If so it approves it
func (*GroupContext) Invite ¶
func (groupCtx *GroupContext) Invite(newMember ethcommon.Address, hasInviteRight bool) error
Invite invokes the 'Invite' method of the group on the blockchain
func (*GroupContext) Leave ¶
func (groupCtx *GroupContext) Leave() error
Leave invokes the 'Leave' operation of the group on the blockchain
func (*GroupContext) ListFiles ¶
func (groupCtx *GroupContext) ListFiles() []FileView
ListFiles returns a list of type string with the group files
func (*GroupContext) ListMembers ¶
func (groupCtx *GroupContext) ListMembers() []MemberView
ListMembers returns a list of the members addresses
func (*GroupContext) RevokeWriteAccess ¶
func (groupCtx *GroupContext) RevokeWriteAccess(filePath string, user ethcommon.Address) error
RevokeWriteAccess removes the defined user from the write ACL in the file meta
func (*GroupContext) Save ¶
func (groupCtx *GroupContext) Save() error
Save stores group data on disk
func (*GroupContext) Stop ¶
func (groupCtx *GroupContext) Stop()
Stop kills all IPFS pubsub group connection - NOT USED
func (*GroupContext) Update ¶
func (groupCtx *GroupContext) Update() error
Update fetches all the current group information from the blockchain and refreshes the GroupContext with its contents
type GroupContextConfig ¶
type GroupContextConfig struct { Group interfaces.IGroup Account interfaces.IAccount P2P *com.P2PManager AddressBook *common.AddressBook Eth *GroupEth Ipfs ipfsapi.IIpfs Storage *fs.Storage Transactions *List }
GroupContextConfig is a configuration struct for creating GroupContext
type IGroupFacade ¶
type IGroupFacade interface { Address() ethcommon.Address Name() string GrantWriteAccess(filePath string, user ethcommon.Address) error RevokeWriteAccess(filePath string, user ethcommon.Address) error CommitChanges() error Invite(user ethcommon.Address, hasInviteRigth bool) error Leave() error ListFiles() []FileView ListMembers() []MemberView }
IGroupFacade is an interface to main.go through which it can communicate with a GroupContext
type IUserFacade ¶
type IUserFacade interface { SignUp(username string) error CreateGroup(groupname string) error AcceptInvitation(groupAddress ethcommon.Address) error User() interfaces.IAccount Groups() []IGroupFacade SignOut() Transactions() ([]*types.Transaction, error) }
IUserFacade is an interface through which main.go can communicate with its UserContext
type MemberView ¶
MemberView is a view of a group member. These objects are sent back to main.go when it lists group members
type UserContext ¶
type UserContext struct {
// contains filtered or unexported fields
}
UserContext stores all the user data and it is responsible for handling communication, events, encryption, etc.
func NewUserContext ¶
func NewUserContext(auth *Auth, backend chequebook.Backend, appContractAddress ethcommon.Address, ipfs ipfsapi.IIpfs, p2pPort string) (*UserContext, error)
NewUserContext creates a new UserContext with the data provided
func (*UserContext) AcceptInvitation ¶
func (ctx *UserContext) AcceptInvitation(groupAddress ethcommon.Address) error
AcceptInvitation accepts a group invitation
func (*UserContext) BuildGroups ¶
func (ctx *UserContext) BuildGroups() error
BuildGroups builds up all groups found on disk
func (*UserContext) CreateGroup ¶
func (ctx *UserContext) CreateGroup(groupname string) error
CreateGroup creates a group through a blockchain method invoke
func (*UserContext) GetBoxerOfGroup ¶
func (ctx *UserContext) GetBoxerOfGroup(group ethcommon.Address) (tribecrypto.SymmetricKey, error)
GetBoxerOfGroup returns the secret key of the given group. It is used by communication sessions that have no direct access to GroupContexts
func (*UserContext) GetProposedBoxerOfGroup ¶
func (ctx *UserContext) GetProposedBoxerOfGroup(group ethcommon.Address, proposer ethcommon.Address) (tribecrypto.SymmetricKey, error)
GetProposedBoxerOfGroup returns the secret key of the given group. It is used by communication sessions that have no direct access to GroupContexts
func (*UserContext) Groups ¶
func (ctx *UserContext) Groups() []IGroupFacade
Groups returns a list of group facades
func (*UserContext) HandleAccountCreatedEvents ¶
func (ctx *UserContext) HandleAccountCreatedEvents(app *ethapp.FileTribeDApp)
HandleAccountCreatedEvents listens to 'AccountCreated' blockchain events and if one belongs to the current user, creates its appropriate UserContext
func (*UserContext) HandleGroupCreatedEvents ¶
func (ctx *UserContext) HandleGroupCreatedEvents(acc *ethacc.Account)
HandleGroupCreatedEvents listens to GroupCreated blockchain events and upon receiving one, it creates the group's appropriate GroupContext
func (*UserContext) HandleGroupInvitationEvents ¶
func (ctx *UserContext) HandleGroupInvitationEvents(acc *ethacc.Account)
HandleGroupInvitationEvents listens to GroupCreated blockchain events and upon receiving one, it stores the invitation
func (*UserContext) HandleInvitationAcceptedEvents ¶
func (ctx *UserContext) HandleInvitationAcceptedEvents(acc *ethacc.Account)
HandleInvitationAcceptedEvents listens to InvitationAccapted blockchain events and upon receiving one, it tries to get the group key and upon its success it creates the group's appropriate GroupContext
func (*UserContext) Init ¶
func (ctx *UserContext) Init(acc interfaces.IAccount) error
Init initializes a UserContext: it starts the P2P manager and the event handlers
func (*UserContext) IsMember ¶
IsMember returns whether a given user is a member of a given group or not. It is used by communication sessions that have no direct access to GroupContexts.
func (*UserContext) ListFiles ¶
func (ctx *UserContext) ListFiles() map[string][]string
ListFiles lists the files names in the account's repository
func (*UserContext) SignOut ¶
func (ctx *UserContext) SignOut()
SignOut tries to gracefully stop all started threads and processes
func (*UserContext) SignUp ¶
func (ctx *UserContext) SignUp(username string) error
SignUp creates a new Account, saves it and registers it on the blockchain
func (*UserContext) Transactions ¶
func (ctx *UserContext) Transactions() ([]*types.Transaction, error)
Transactions returns a list of transactions initiated by the user
func (*UserContext) User ¶
func (ctx *UserContext) User() interfaces.IAccount
User returns the Account interface