courselab / allium

Prototype implementation of the Riffle anonimity network.
GNU General Public License v3.0
2 stars 2 forks source link

Riffle torrent implementation #7

Open charles2910 opened 2 years ago

charles2910 commented 2 years ago

As one part of allium, we will implement the anonymous file sharing system proposed in the Riffle article. It's described in section 5 of the paper and it consists of 3 main parts:

charles2910 commented 2 years ago

Upon further analysis, we can break down this work in a handful of parts. These parts are listed below with important points of each part.

charles2910 commented 2 years ago

Research about Create Torrent File:

The torrent file uses a specific enconding known as bencode and it has mandatory fields as well as some optional ones.

The explanation and text below were adapted from the unoficial BitTorrent Specification.

Bencoding

Bencoding is a way to specify and organize data in a concise format. It supports the following types: byte strings, integers, lists, and dictionaries.

Byte Strings

Byte strings are encoded as follows: :

Integers

Integers are encoded as follows: ie

Lists

Lists are encoded as follows: le

Dictionaries

Dictionaries are encoded as follows: de

Metainfo File Structure

The content of a metainfo file (the file ending in ".torrent") is a bencoded dictionary, containing the keys listed below. All character string values are UTF-8 encoded.

Note that some fields were left off for brevity.

Info Dictionary

This section contains the dictionary structure for the "single file" mode.

Note:

charles2910 commented 2 years ago

I've found 2 libraries that can be used for generating the torrent files. They are:

To give a better example of the torrent file, I've created a test torrent. The high level (fields and values) will be shown together with the bencoded resulting file.

{
    'info': {
        'length': 223,
        'name': 'teste.c',
        'piece length': 16384,
        'pieces': b'\x9dz\x12\x90\xe4\xfdK\xec\x1b_\xb28\xc6/\xab\x87\xd1\x9c\x1cc'
    },
    'created by': 'Charles',
    'comment': 'This is a test torrent file',
    'creation date': 1635279024
}
d7:comment27:This is a test torrent file10:created by7:Charles13:creation datei1635279024e4:infod6:lengthi223e4:name7:teste.c12:piece lengthi16384e6:pieces20:\x9dz\x12\x90\xe4\xfdK\xec\x1b_\xb28\xc6/\xab\x87\xd1\x9c\x1ccee