Home

Awesome

P2P Web

P2PWeb is a project that aims at replacing the traditional websites with P2PWebSites. These have the advantage of being completely distributed over the network. There is no central point of failure and there is no other way to shut down a site than shutting down all nodes that replicates it.

Unlike Freenet, replicating a P2PWebSite is a voluntary. Anyone can replicate a site, and in fact, when you visit a site, you replicate the pages you are viewing (TODO). Thus, a popular site will be faster than the others.

The protocol itself doesn't handle security. Such things are better left off to lower layers such as the cjdns protocol. Exchanged information is public anyway.

This is designed as a replacement for websites that contain mostly static content such as blogs. Complex web applications are not a target for P2PWeb. Some applications may however be implemented in pure JavaScript.

Advantages over the current Web

The design allows new applications:

Design

The network is based on the kademlia DHT. This DHT is used as a public storage containing the location of each resource. The resources on the network are identified by a hash that guarantee the integrity of the resource.

A resource can either be a blob or a P2PWebSite. We can imagine other type of resources in the future. Every resource has metadata attached to it. These metadata are available as HTTP headers and are included in the resource hash (sha1).

Metadata

The metadata are a subset of the HTTP headers transmitted along with the resource. To know the headers that are part of the metadata, there is a special header x-p2pws-signed-headers that lists them. Headers are normalized lowercase.

The metadata is included with the resource when computing its hash that identifies the resource. A serialized version of the metadata is appended at the beginning of the resource before computing the hash.

Each header is serialized in the order of x-p2pws-signed-headers. The header name is normalized lower case. The header value all its newlines ("\n") replaced by "\n ". This is line continuation. The header itself is serialized this way:

header-name ": " header-value-with-line-cont "\n"

The blobs

resources can be blobs. A blob is just a piece of data. It has only one hash computed:

blob-hash = sha1(serialized-metadata + blob-data)

On the HTTP proxy, the blobs can be accessed using a request like:

GET /obj/faf6936528390edf5c762e7d30a99b14a4da54ba

The P2PWebSite

The P2PWebSite is a resource that links to other resource. It is also a special file format. Look at js/signedheader.js for more information on the format itself.

A site is signed by a private key that the author(s) keep to themselves. The public key is available at the beginning of the file. A file has generally many versions or revisions. Each of them are signed using the private key. Once signed, a revision cannot be changed.

Each site revision contains a list of paths. For each path, there is a list of header override and the hash of a linked resource. The file is append-only (the new revisions are put at the end of the file).

Contrary to a blob, a site has many hash ids. One for each revision, and one for the last revision that may be unsigned (generally that's because you are the editor). When accessed as a blob for any of these IDs, the latest version of the file is provided.

When viewing a site, you generally visit its pages. In that case, the last signed revision is generally used (unless specified otherwise). Notes that host a site will will periodically check for new revisions. (TODO: make this instantaneous). The HTTP requests look like:

GET /obj/faf6936528390edf5c762e7d30a99b14a4da54ba/                (the home page)
GET /obj/faf6936528390edf5c762e7d30a99b14a4da54ba/article-1.html  (a specific page)

You can specify a revision of your choice:

GET /obj/faf6936528390edf5c762e7d30a99b14a4da54ba,5/article-at-rev-5.html

You can also accept unsigned revisions (off by default):

GET /obj/faf6936528390edf5c762e7d30a99b14a4da54ba,+/article-at-rev-5.html

Linking to other sites

In order to allow absolute linking and linking to other sites, a special character ~ is introduced. This character is not allowed in site paths. Links can be:

This works by having URLs like /obj/SHA1/anything/~... reduced to /obj/....

Package Contents

This repository contains:

With that you can:

License

This work is licenced under the GNU GPL 3.0 or any later version at your option.

Work in Progress

TODO

Roadmap

make it work on cjdns

Backlinks

The user agent, when publishing a P2PWS, can add forward links in relation to a specific file. For example:

Files-Merge: { '/toto.html': {
    id: ABC123,
    headers: {...},
    links: {
      [ 'alternate', object-id, site-id, path ],
      [ 'reference', XYZ567,    site-id, path ],
      ...
    }
  } }

A node responsible for publishing a site will ensure that the DHT contains the backlinks:

primary key:   XYZ567
secondary key: h(backlinks-site_id-/toto.html)
content:       ['reference', 'ABC123']

This can be used to replace a builtin-board.

Public websites or wikis

The private key is available on the site itself. Anyone can modify it. TODO: manage concurrent editing.

Messaging

On a personal website, messages can be posted encrypted, and recipients should check regularly to see if there is a message available for decryption.

Porting over to torrent network

The server software would:

This would make a good demo. Improvement includes extnsions to bittorrent: