X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=shamirs;a=blobdiff_plain;f=main.c;h=f79f074aec31327ca19b8cc0df7a151a0b8ecc81;hp=a46dda1e094f9834236c05fddc3123f2fc82025b;hb=HEAD;hpb=2a2c594f89b469431de08aa68e38ada3bb88d9a3 diff --git a/main.c b/main.c index a46dda1..f79f074 100644 --- a/main.c +++ b/main.c @@ -58,8 +58,6 @@ static void derive_missing_part(uint8_t total_shares, uint8_t shares_required, b // shares, because more shares could be added arbitrarily, any x should not be // able to rule out any possible secrets) and try each possible q, making sure // that each q gives us a new possibility for the secret. - bool impossible_secrets[P]; - memset(impossible_secrets, 0, sizeof(impossible_secrets)); for (uint16_t final_x = 1; final_x < P; final_x++) { bool x_already_used = false; for (uint8_t j = 0; j < shares_required; j++) { @@ -201,7 +199,7 @@ int main(int argc, char* argv[]) { // TODO: The following loop may take a long time and eat lots of /dev/random if total_shares is high for (uint32_t i = 0; i < total_shares; i++) { - int32_t j = 0; + int32_t j = -1; do { assert(fread(&x[i], sizeof(uint8_t), 1, random) == 1); if (x[i] == 0) @@ -209,7 +207,7 @@ int main(int argc, char* argv[]) { for (j = 0; j < i; j++) if (x[j] == x[i]) break; - } while (j < i); // Inner loop will get to j = i when x[j] != x[i] for all j + } while (j < (int32_t)i); // Inner loop will get to j = i when x[j] != x[i] for all j if (i % 32 == 31) printf("Finished picking X coordinates for %u shares\n", i+1); }