dataverification

package
v1.1.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2023 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
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

func (d *Protocol) GetDownloadDirectory() string

GetDownloadDirectory returns the download directory.

func (*Protocol) GetMerkleTreeFileSegmentsEncryptionPercentage

func (d *Protocol) GetMerkleTreeFileSegmentsEncryptionPercentage() (int, int)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL