Documentation ¶
Index ¶
- Constants
- Variables
- func Int64ToByteArr(i int64) []byte
- type Base64Address
- type EnvVars
- type JSONRepSummary
- type JSONSignableTransaction
- type LayerFileMetadata
- type LayerRep
- type LayerRepTrans
- type OriginInfo
- type PersonalAddress
- type PublishTorrentTrans
- type RepMessage
- type ReputationSummary
- type SetAliasTrans
- type SharedLayerTrans
- type SignableTransaction
- func (st SignableTransaction) GetHash() []byte
- func (st SignableTransaction) GetOrigin() OriginInfo
- func (st SignableTransaction) GetRS() (*big.Int, *big.Int)
- func (st SignableTransaction) SignAndSetTxID(priv *ecdsa.PrivateKey) SignableTransaction
- func (st SignableTransaction) ToString() string
- func (st SignableTransaction) Verify() bool
- func (st SignableTransaction) VerifyWithKey(key ecdsa.PublicKey) bool
- type TorrentFile
- func (torr1 TorrentFile) Equals(torr2 TorrentFile) bool
- func (torr TorrentFile) GetLayerHashMap() map[string]LayerFileMetadata
- func (torr TorrentFile) GetRawBytes() []byte
- func (torr TorrentFile) GetUrl() string
- func (torr TorrentFile) ToString() string
- func (torr TorrentFile) Validate() (bool, error)
- type TorrentRep
- type TorrentRepTrans
- type TorrentTransaction
Constants ¶
const ( PUBLISH_TORRENT = "PUBLISH_TORRENT" TORRENT_REP = "TORRENT_REP" SHARED_LAYER = "SHARED_LAYER" LAYER_REP = "LAYER_REP" SET_ALIAS = "SET_ALIAS" )
const BlockchainHostDefault = "http://localhost"
const BlockchainPortDefault = "5000"
const TorrentPortDefault = "8000"
Variables ¶
var AUTHENTICATION_CURVE = elliptic.P256()
Functions ¶
func Int64ToByteArr ¶
Types ¶
type Base64Address ¶
type Base64Address string
func HashPublicToB64Address ¶
func HashPublicToB64Address(pub ecdsa.PublicKey) Base64Address
type EnvVars ¶
func LoadEnvFromFile ¶
type JSONRepSummary ¶
type JSONSignableTransaction ¶
type JSONSignableTransaction struct { Origin OriginInfo // needed to say who I am (WITHIN the transaction) Transaction json.RawMessage TransactionType string R, S *big.Int // signature of the transaction, should be separate from the actual "message" components TxID string }
func (JSONSignableTransaction) ConvertToSignable ¶
func (js JSONSignableTransaction) ConvertToSignable() SignableTransaction
type LayerFileMetadata ¶
func AppendLayerDataToFile ¶
func AppendLayerDataToFile(layerId string, data []byte) LayerFileMetadata
func (LayerFileMetadata) GetUrl ¶
func (lm LayerFileMetadata) GetUrl() string
type LayerRepTrans ¶
type LayerRepTrans struct { TxID string //the original transaction when the layer was shared with "me" LayerHash string WasLayerReceived bool WasLayerValid bool }
LayerRepTrans represents an address leaving feedback on a layer that was shared with it. This can be used to determine if a particular node/address is reputable when sharing layers that are valid and hash correctly, or even if they shared the layer at all
func (LayerRepTrans) GetRawBytes ¶
func (rt LayerRepTrans) GetRawBytes() []byte
func (LayerRepTrans) ToString ¶
func (rt LayerRepTrans) ToString() string
type OriginInfo ¶
type OriginInfo struct { PubKeyX *big.Int PubKeyY *big.Int Address Base64Address }
func (OriginInfo) GetRawBytes ¶
func (oi OriginInfo) GetRawBytes() []byte
func (OriginInfo) ToString ¶
func (oi OriginInfo) ToString() string
type PersonalAddress ¶
type PersonalAddress struct { PrivateKey ecdsa.PrivateKey //TODO Encrypt and save locally PublicKey ecdsa.PublicKey Address Base64Address }
func GenerateNewPersonalAddress ¶
func GenerateNewPersonalAddress() PersonalAddress
func (PersonalAddress) ConvertToOriginInfo ¶
func (address PersonalAddress) ConvertToOriginInfo() OriginInfo
type PublishTorrentTrans ¶
type PublishTorrentTrans struct {
Torrent TorrentFile
}
PublishTorrentTrans represents a transaction that shows a node/user posting a new torrent onto the blockchain This allows other users and nodes to discover what layers comprise what type of file or content, so that the individual layers can be directly/"privately" requested from nodes (users don't request layers on the blockchain)
func (PublishTorrentTrans) GetRawBytes ¶
func (tt PublishTorrentTrans) GetRawBytes() []byte
func (PublishTorrentTrans) ToString ¶
func (tt PublishTorrentTrans) ToString() string
type RepMessage ¶
RepMessage represents a message that conveys the quality of a Torrent, in terms of the accuracy of the name, the validity of the file itself (does it form a cohesive file that runs/opens as expected?), and if the content itself is high quality
type ReputationSummary ¶
type ReputationSummary struct { //Reputation of all torrents, indexed by their hashes TorrentRep map[string]TorrentRep //Reputation of all layers, indexed by hash LayerRep map[string]LayerRep }
func (ReputationSummary) ToJSONSummary ¶
func (summary ReputationSummary) ToJSONSummary() JSONRepSummary
type SetAliasTrans ¶
type SetAliasTrans struct {
Alias string
}
func (SetAliasTrans) GetRawBytes ¶
func (sat SetAliasTrans) GetRawBytes() []byte
func (SetAliasTrans) ToString ¶
func (sat SetAliasTrans) ToString() string
type SharedLayerTrans ¶
type SharedLayerTrans struct {}
SharedLayerTrans represents a transaction that shows a node sharing a torrent layer with a particular address This can be used by other nodes to see if a node has indicated sharing with an address, and whether or not that address left feedback on the share, if that address actually received the layer, etc.
func (SharedLayerTrans) GetRawBytes ¶
func (lt SharedLayerTrans) GetRawBytes() []byte
func (SharedLayerTrans) ToString ¶
func (lt SharedLayerTrans) ToString() string
type SignableTransaction ¶
type SignableTransaction struct { Origin OriginInfo // needed to say who I am (WITHIN the transaction) Transaction TorrentTransaction TransactionType string R, S *big.Int // signature of the transaction, should be separate from the actual "message" components TxID string }
func NewSignable ¶
func NewSignable(info OriginInfo, transaction TorrentTransaction, ttype string) SignableTransaction
func (SignableTransaction) GetHash ¶
func (st SignableTransaction) GetHash() []byte
func (SignableTransaction) GetOrigin ¶
func (st SignableTransaction) GetOrigin() OriginInfo
func (SignableTransaction) SignAndSetTxID ¶
func (st SignableTransaction) SignAndSetTxID(priv *ecdsa.PrivateKey) SignableTransaction
func (SignableTransaction) ToString ¶
func (st SignableTransaction) ToString() string
func (SignableTransaction) Verify ¶
func (st SignableTransaction) Verify() bool
func (SignableTransaction) VerifyWithKey ¶
func (st SignableTransaction) VerifyWithKey(key ecdsa.PublicKey) bool
type TorrentFile ¶
type TorrentFile struct { Name string LayerByteSize int64 TotalByteSize int64 TotalHash string LayerHashKeys []string //fine to expose publicly to say what layers the torrent has // contains filtered or unexported fields }
func MakeTorrentFileFromFile ¶
func MakeTorrentFileFromFile(layerByteSize int64, url string, name string) (TorrentFile, error)
func MakeTorrentFromBytes ¶
func MakeTorrentFromBytes(layerByteSize int64, data []byte, name string) (TorrentFile, error)
func (TorrentFile) Equals ¶
func (torr1 TorrentFile) Equals(torr2 TorrentFile) bool
func (TorrentFile) GetLayerHashMap ¶
func (torr TorrentFile) GetLayerHashMap() map[string]LayerFileMetadata
GetLayerHashMap exposes the hashes and file metadata associated with a torrent file's layers, but without exposing the fields to manipulation, or exposure by mux when listing the TorrentFile as a web response
func (TorrentFile) GetRawBytes ¶
func (torr TorrentFile) GetRawBytes() []byte
func (TorrentFile) GetUrl ¶
func (torr TorrentFile) GetUrl() string
func (TorrentFile) ToString ¶
func (torr TorrentFile) ToString() string
func (TorrentFile) Validate ¶
func (torr TorrentFile) Validate() (bool, error)
type TorrentRep ¶
type TorrentRepTrans ¶
type TorrentRepTrans struct { TxID string //the original transaction when the layer was shared with "me" TorrentHash string RepMessage RepMessage }
TorrentRepTrans represents a transaction for feedback on a Torrent. See RepMessage for more details
func (TorrentRepTrans) GetRawBytes ¶
func (rt TorrentRepTrans) GetRawBytes() []byte
func (TorrentRepTrans) ToString ¶
func (rt TorrentRepTrans) ToString() string