Siacoin/Sia — pull request #50 by DavidVorick (2014-04-03 07:35:19+00:00)
Title: Add Reed-Solomon Coding

The erasure coding goes in it's own package. Inside of that folder there's also another git repo, which is where I pulled my erasure coding library from.

You can encode data by calling EncodeRing(), which takes as input a block of data, a number of non-redundant pieces 'k' (out of common.SWARMSIZE total), and then a slice size 'bytesPerSlice'. Before calling encode, you are expected to pick your slice size and pad your data accordingly. EncodeRing() does error-check the input. The return value is common.SWARMSIZE strings, each bytesPerSlice large. The first k strings are the original data, the remaining strings are redundant.

You can decode data by calling RebuildBlock, which takes as input 'k' strings, along with a slice of ints that correspond to the indicies of the input strings. It also takes a value 'k', and a value 'bytesPerSlice'. These last two values could be derived from the sizes of the first two values, and I may remove them at some point.