• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.travis.ymlH A D05-Jun-2020136

LICENSEH A D05-Jun-20202.9 KiB

README.mdH A D05-Jun-20205 KiB

addmul_amd64.goH A D05-Jun-20201.9 KiB

addmul_amd64.sH A D05-Jun-20205.7 KiB

addmul_noasm.goH A D05-Jun-20201.4 KiB

addmul_tables_amd64.goH A D05-Jun-202055 KiB

addmul_test.goH A D05-Jun-20201.8 KiB

berlekamp_welch.goH A D05-Jun-20206 KiB

berlekamp_welch_test.goH A D05-Jun-20206.8 KiB

common.goH A D05-Jun-20202 KiB

common_test.goH A D05-Jun-20201.9 KiB

example_test.goH A D05-Jun-20202.3 KiB

fec.goH A D05-Jun-20208.1 KiB

fec_test.goH A D05-Jun-20206.9 KiB

gf_alg.goH A D05-Jun-20208.1 KiB

gf_alg_test.goH A D05-Jun-20201.5 KiB

go.modH A D05-Jun-2020106

go.sumH A D05-Jun-2020207

math.goH A D05-Jun-20204.2 KiB

tables.goH A D05-Jun-20208.2 KiB

README.md

1# infectious
2
3[![GoDoc](https://godoc.org/github.com/vivint/infectious?status.png)](https://godoc.org/github.com/vivint/infectious)
4
5Infectious implements
6[Reed-Solomon forward error correction](https://en.wikipedia.org/wiki/Reed%E2%80%93Solomon_error_correction).
7It uses the
8[Berlekamp-Welch error correction algorithm](https://en.wikipedia.org/wiki/Berlekamp%E2%80%93Welch_algorithm)
9to achieve the ability to actually correct errors.
10
11[We wrote a blog post about how this library works!](https://innovation.vivint.com/introduction-to-reed-solomon-bc264d0794f8)
12
13### Example
14
15```golang
16const (
17	required = 8
18	total    = 14
19)
20
21// Create a *FEC, which will require required pieces for reconstruction at
22// minimum, and generate total total pieces.
23f, err := infectious.NewFEC(required, total)
24if err != nil {
25	panic(err)
26}
27
28// Prepare to receive the shares of encoded data.
29shares := make([]infectious.Share, total)
30output := func(s infectious.Share) {
31	// the memory in s gets reused, so we need to make a deep copy
32	shares[s.Number] = s.DeepCopy()
33}
34
35// the data to encode must be padded to a multiple of required, hence the
36// underscores.
37err = f.Encode([]byte("hello, world! __"), output)
38if err != nil {
39	panic(err)
40}
41
42// we now have total shares.
43for _, share := range shares {
44	fmt.Printf("%d: %#v\n", share.Number, string(share.Data))
45}
46
47// Let's reconstitute with two pieces missing and one piece corrupted.
48shares = shares[2:]     // drop the first two pieces
49shares[2].Data[1] = '!' // mutate some data
50
51result, err := f.Decode(nil, shares)
52if err != nil {
53	panic(err)
54}
55
56// we have the original data!
57fmt.Printf("got: %#v\n", string(result))
58```
59
60**Caution:** this package API leans toward providing the user more power and
61performance at the expense of having some really sharp edges! Read the
62documentation about memory lifecycles carefully!
63
64Please see the docs at http://godoc.org/github.com/vivint/infectious
65
66### Thanks
67
68We're forever indebted to the giants on whose shoulders we stand. The LICENSE
69has our full copyright history, but an extra special thanks to Klaus Post for
70much of the initial Go code. See his post for more:
71http://blog.klauspost.com/blazingly-fast-reed-solomon-coding/
72
73### LICENSE
74
75 * Copyright (C) 2016-2017 Vivint, Inc.
76 * Copyright (c) 2015 Klaus Post
77 * Copyright (c) 2015 Backblaze
78 * Copyright (C) 2011 Billy Brumley (billy.brumley@aalto.fi)
79 * Copyright (C) 2009-2010 Jack Lloyd (lloyd@randombit.net)
80 * Copyright (C) 1996-1998 Luigi Rizzo (luigi@iet.unipi.it)
81
82Portions derived from code by Phil Karn (karn@ka9q.ampr.org),
83Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu) and Hari
84Thirumoorthy (harit@spectra.eng.hawaii.edu), Aug 1995
85
86**Portions of this project (labeled in each file) are licensed under this
87license:**
88
89Redistribution and use in source and binary forms, with or without
90modification, are permitted provided that the following conditions are
91met:
92
931. Redistributions of source code must retain the above copyright
94   notice, this list of conditions and the following disclaimer.
95
962. Redistributions in binary form must reproduce the above copyright
97   notice, this list of conditions and the following disclaimer in the
98   documentation and/or other materials provided with the
99   distribution.
100
101THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
102IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
103WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
104DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT,
105INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
106(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
107SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
108HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
109STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
110IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
111POSSIBILITY OF SUCH DAMAGE.
112
113**All other portions of this project are licensed under this license:**
114
115The MIT License (MIT)
116
117Permission is hereby granted, free of charge, to any person obtaining a copy
118of this software and associated documentation files (the "Software"), to deal
119in the Software without restriction, including without limitation the rights
120to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
121copies of the Software, and to permit persons to whom the Software is
122furnished to do so, subject to the following conditions:
123
124The above copyright notice and this permission notice shall be included in all
125copies or substantial portions of the Software.
126
127THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
128IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
129FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
130AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
131LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
132OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
133SOFTWARE.
134