This is an old revision of the document!
In order to store files on Sia, renters must first form Contracts with various hosts. A contract sets aside a fixed amount of siacoins to be spent on storing and transferring data over a fixed period. The renter pays all the siacoins in advance, and any unused coins are returned to them at the end of the contract period.
To help facilitate this process, the Sia client allows users to set an allowance. An allowance specifies the maximum amount of siacoins to be spent, and the period (in blocks) in which they are spent. The client then intelligently chooses hosts and forms contracts with them such that each contract can store the same amount of data.
Sia uses encryption and erasure coding to ensure that files are private and remain available even if hosts go offline.
The uploading process is as follows. First, the file is striped into chunks of 40MB. Reed-Solomon erasure coding is then applied on each chunk, expanding them into 30 pieces of 4MB. Erasure coding is like an M-of-N multisig protocol, but for data: out of N total pieces, only M are needed to recover the full 40MB chunk. This ensures a high level of redundancy, much greater than traditional replication.
Each piece is then encrypted with the Twofish algorithm. It was one of the five finalists of the Advanced Encryption Standard contest, but it was not selected for standardization. Nonetheless, this algorithm is considered very secure.
Finally the pieces are sent to hosts to be stored. Currently, no host receives more than one piece of any given chunk. For example, host 1 might contain the first piece of chunk 1, chunk 2, chunk 3, etc., and host 2 might contain the second piece of the same chunks. This ensures that if host 1 is offline, you can still download pieces from every chunk. Even if host 1 is not offline, but merely slow, this scheme prevents you from being bottlenecked by the slow host.
Since contracts expire after a fixed duration (i.e. number of blocks), new contracts must be formed to take their place. In the simplest case, the renter could repeat the contract formation process and then reupload their data to the hosts. But this is obviously inefficient for both the renter and host. To address this, Sia's renter-host protocol supports directly replacing a previously-formed contract. A new contract is formed with a new duration, and references the current data stored on the host instead of starting over from scratch. The new contract may also contain a different amount of siacoins than the original.
The Sia client will automatically renew contracts when they are within a certain window of expiring. This means that there will be some overlap between the old contract and the new contract. The expiration height of the new contract will be equal to the current height plus the allowance period.