Documentation
¶
Index ¶
- Constants
- type Interface
- type NetworkMessagePublisher
- type Protocol
- func (d *Protocol) DecryptFile(filePath, decryptedFilePath string, key, iv []byte, ...) (string, error)
- func (d *Protocol) GetDownloadDirectory() string
- func (d *Protocol) GetMerkleTreeFileSegmentsEncryptionPercentage() (int, int)
- func (d *Protocol) RequestEncryptionData(ctx context.Context, verifierID peer.ID, request *messages.KeyIVRequestsProto) (*messages.KeyIVRandomizedFileSegmentsEnvelopeProto, error)
- func (d *Protocol) RequestFileTransfer(ctx context.Context, destinationFilePath, fileNameWithPart string, ...) (string, error)
- func (d *Protocol) SendContractToVerifierForAcceptance(ctx context.Context, verifierID peer.ID, ...) (*messages.DownloadContractProto, error)
- func (d *Protocol) SendFileMerkleTreeNodesToVerifier(ctx context.Context, verifierID peer.ID, ...) error
- func (d *Protocol) SendKeyIVRandomizedFileSegmentsAndDataToVerifier(ctx context.Context, verifierID peer.ID, filePath string, contractHash string, ...) error
- func (d *Protocol) TransferContract(ctx context.Context, peerID peer.ID, request *messages.DownloadContractProto) error
Constants ¶
const ( // ReceiveMerkleTreeProtocolID is a protocol which receives the merkle tree nodes. ReceiveMerkleTreeProtocolID = "/ffg/dataverification_receive_merkletree/1.0.0" // FileTransferProtocolID is a protocol which is used to transfer files from file hoster to downloader node. FileTransferProtocolID = "/ffg/dataverification_file_transfer/1.0.0" // ReceiveKeyIVRandomizedFileSegmentsAndDataProtocolID is a protocol which receives the encryotion data and the raw unencrypted file segments to verifier. ReceiveKeyIVRandomizedFileSegmentsAndDataProtocolID = "/ffg/dataverification_receive_keyivrandomsegments_data/1.0.0" // EncryptionDataTransferProtocolID is a protocol which transfers the key data from verifier to file requester. EncryptionDataTransferProtocolID = "/ffg/dataverification_encryption_data_transfer/1.0.0" // ContractTransferProtocolID is a protocol which transfers download contracts between nodes. ContractTransferProtocolID = "/ffg/dataverification_contract_transfer/1.0.0" // ContractVerifierAcceptanceProtocolID is a protocol which accepts incoming download contracts and seal them by verifier. ContractVerifierAcceptanceProtocolID = "/ffg/dataverification_contract_accept/1.0.0" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface { SendContractToVerifierForAcceptance(ctx context.Context, verifierID peer.ID, request *messages.DownloadContractProto) (*messages.DownloadContractProto, error) TransferContract(ctx context.Context, peerID peer.ID, request *messages.DownloadContractProto) error DecryptFile(filePath, decryptedFilePath string, key, iv []byte, encryptionType common.EncryptionType, randomizedFileSegments []int, onlyFileReArrangement bool) (string, error) RequestEncryptionData(ctx context.Context, verifierID peer.ID, request *messages.KeyIVRequestsProto) (*messages.KeyIVRandomizedFileSegmentsEnvelopeProto, error) SendFileMerkleTreeNodesToVerifier(ctx context.Context, verifierID peer.ID, request *messages.MerkleTreeNodesOfFileContractProto) error SendKeyIVRandomizedFileSegmentsAndDataToVerifier(ctx context.Context, verifierID peer.ID, filePath string, contractHash string, fileHash []byte) error RequestFileTransfer(ctx context.Context, destinationFilePath, fileNameWithPart string, fileHosterID peer.ID, request *messages.FileTransferInfoProto) (string, error) GetDownloadDirectory() string GetMerkleTreeFileSegmentsEncryptionPercentage() (int, int) }
Interface specifies the data verification functionalities.
type NetworkMessagePublisher ¶
type NetworkMessagePublisher interface {
PublishMessageToNetwork(ctx context.Context, data []byte) error
}
NetworkMessagePublisher is a pub sub message broadcaster.
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
Protocol wraps the data verification protocols and handlers
func New ¶
func New(h host.Host, contractStore contract.Interface, storage storage.Interface, blockchain blockchain.Interface, publisher NetworkMessagePublisher, merkleTreeTotalSegments, encryptionPercentage int, downloadDirectory string, dataVerifier bool, dataVerifierVerificationFees, dataVerifierTransactionFees string) (*Protocol, error)
New creates a data verification protocol.
func (*Protocol) DecryptFile ¶
func (d *Protocol) DecryptFile(filePath, decryptedFilePath string, key, iv []byte, encryptionType common.EncryptionType, randomizedFileSegments []int, onlyFileReArrangement bool) (string, error)
DecryptFile descrypts a file given the file's encryption setup.
func (*Protocol) GetDownloadDirectory ¶
GetDownloadDirectory returns the download directory.
func (*Protocol) GetMerkleTreeFileSegmentsEncryptionPercentage ¶
GetMerkleTreeFileSegmentsEncryptionPercentage returns the total merkle tree nodes and percentage encryption.
func (*Protocol) RequestEncryptionData ¶
func (d *Protocol) RequestEncryptionData(ctx context.Context, verifierID peer.ID, request *messages.KeyIVRequestsProto) (*messages.KeyIVRandomizedFileSegmentsEnvelopeProto, error)
RequestEncryptionData requests the encryption data from a verifier.
func (*Protocol) RequestFileTransfer ¶
func (d *Protocol) RequestFileTransfer(ctx context.Context, destinationFilePath, fileNameWithPart string, fileHosterID peer.ID, request *messages.FileTransferInfoProto) (string, error)
RequestFileTransfer requests a file download from the file hoster. Request is initiated from the downloader peer.
func (*Protocol) SendContractToVerifierForAcceptance ¶
func (d *Protocol) SendContractToVerifierForAcceptance(ctx context.Context, verifierID peer.ID, request *messages.DownloadContractProto) (*messages.DownloadContractProto, error)
SendContractToVerifierForAcceptance sends a contract to a verifier and gets signed by verifier. this method is called by file requester
func (*Protocol) SendFileMerkleTreeNodesToVerifier ¶
func (d *Protocol) SendFileMerkleTreeNodesToVerifier(ctx context.Context, verifierID peer.ID, request *messages.MerkleTreeNodesOfFileContractProto) error
SendFileMerkleTreeNodesToVerifier sends the file merkle tree nodes to the verifier.
func (*Protocol) SendKeyIVRandomizedFileSegmentsAndDataToVerifier ¶
func (d *Protocol) SendKeyIVRandomizedFileSegmentsAndDataToVerifier(ctx context.Context, verifierID peer.ID, filePath string, contractHash string, fileHash []byte) error
SendKeyIVRandomizedFileSegmentsAndDataToVerifier sends the encryption key and iv with the random segments and the unencrypted file segments.
func (*Protocol) TransferContract ¶
func (d *Protocol) TransferContract(ctx context.Context, peerID peer.ID, request *messages.DownloadContractProto) error
TransferContract transfers a contract to a node.