func NewRSCode(nData, nParity int) (modules.ErasureCoder, error) {
	enc, err := reedsolomon.New(nData, nParity)
	if err != nil {
		return nil, err
	}
	return &rsCode{
		enc:        enc,
		numPieces:  nData + nParity,
		dataPieces: nData,
	}, nil
}
NewRSCode creates a new Reed-Solomon encoder/decoder using the supplied
parameters.
package renter
import (
	"fmt"
	"io"
	"github.com/klauspost/reedsolomon"
	"github.com/NebulousLabs/Sia/modules"
)
type rsCode struct {
	enc reedsolomon.Encoder
	numPieces  int
	dataPieces int
}
func (rs *rsCode) NumPieces() int { return rs.numPieces }
func (rs *rsCode) MinPieces() int { return rs.dataPieces }
func (rs *rsCode) Encode(data []byte) ([][]byte, error) {
	pieces, err := rs.enc.Split(data)
	if err != nil {
		return nil, err
	}
	err = rs.enc.Encode(pieces)
	if err != nil {
		return nil, err
	}
	return pieces, nil
}
func (rs *rsCode) EncodeShards(pieces [][]byte) ([][]byte, error) {
	if len(pieces) != rs.MinPieces() {
		return nil, fmt.Errorf("invalid number of pieces given %v %v", len(pieces), rs.MinPieces())
	}
	for len(pieces) < rs.NumPieces() {
		pieces = append(pieces, make([]byte, pieceSize))
	}
	err := rs.enc.Encode(pieces)
	if err != nil {
		return nil, err
	}
	return pieces, nil
}
func (rs *rsCode) Recover(pieces [][]byte, n uint64, w io.Writer) error {
	err := rs.enc.ReconstructData(pieces)
	if err != nil {
		return err
	}
	return rs.enc.Join(w, pieces, int(n))
}