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) RequestContractTransactionVerification(ctx context.Context, peerID peer.ID, contractHash []byte) (bool, error)
- 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
- func (d *Protocol) VerifierHasEncryptionMetadata(ctx context.Context, verifierID peer.ID, contractHash []byte) (bool, 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" // ContractTransactionValidationProtocolID is a protocol used by data requester node to ask data verifier and storage provider // if a transaction containing the download contract was received by their node. ContractTransactionValidationProtocolID = "/ffg/dataverification_contract_validate/1.0.0" // VerifierHasEncryptionMetadataProtocolID is mainly used by data requesters to check if the data verifier received the necessary encryption // metadata so requester can ask verifier for decryption metadata. VerifierHasEncryptionMetadataProtocolID = "/ffg/dataverification_has_enc/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, withProgres bool) (string, error) GetDownloadDirectory() string GetMerkleTreeFileSegmentsEncryptionPercentage() (int, int) RequestContractTransactionVerification(ctx context.Context, peerID peer.ID, contractHash []byte) (bool, error) VerifierHasEncryptionMetadata(ctx context.Context, peerID peer.ID, contractHash []byte) (bool, error) }
Interface specifies the data verification functionalities.
type NetworkMessagePublisher ¶
type NetworkMessagePublisher interface {
PublishMessageToNetwork(ctx context.Context, topicName string, 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, storageFeesPerByte string, allowZeroFeesDataUnder512KB bool, ) (*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) RequestContractTransactionVerification ¶ added in v1.1.23
func (d *Protocol) RequestContractTransactionVerification(ctx context.Context, peerID peer.ID, contractHash []byte) (bool, error)
RequestContractTransactionVerification is used by a data downloader to query storage provider and data verifier about a transaction containing a contract hash. This way data requester can orchestrate the downloading procedure.
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, withProgres bool) (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.
func (*Protocol) VerifierHasEncryptionMetadata ¶ added in v1.1.23
func (d *Protocol) VerifierHasEncryptionMetadata(ctx context.Context, verifierID peer.ID, contractHash []byte) (bool, error)
VerifierHasEncryptionMetadata asks the verifier if all the files encryption metadata in a contract have been transferred from storage provider to data verifier. This will be used by data requester to know when to ask for decryption metadata from the verifier. This protocol can be polled until it returns true or false indicating an error.