This commit is contained in:
Jim McDonald
2024-10-01 13:02:39 +01:00
parent 0276a72de6
commit 72a9390f97
7 changed files with 17 additions and 16 deletions

View File

@@ -75,9 +75,9 @@ func (p *polynomial) evaluate(x uint8) uint8 {
func interpolatePolynomial(xSamples, ySamples []uint8, x uint8) uint8 {
limit := len(xSamples)
var result, basis uint8
for i := 0; i < limit; i++ {
for i := range limit {
basis = 1
for j := 0; j < limit; j++ {
for j := range limit {
if i == j {
continue
}
@@ -183,7 +183,7 @@ func Split(secret []byte, parts, threshold int) ([][]byte, error) {
// Generate a `parts` number of (x,y) pairs
// We cheat by encoding the x value once as the final index,
// so that it only needs to be stored once.
for i := 0; i < parts; i++ {
for i := range parts {
x := uint8(xCoordinates[i]) + 1
y := p.evaluate(x)
out[i][idx] = y