X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=shamirs;a=blobdiff_plain;f=main.c;h=f79f074aec31327ca19b8cc0df7a151a0b8ecc81;hp=42ec45ebcc4c17392bd2fa33e233f5b338b32843;hb=29327faf07a0331e10a2f9c7104a41870a74efe5;hpb=085515e769d794f70c3f9ae0c80902dd5a5eee09 diff --git a/main.c b/main.c index 42ec45e..f79f074 100644 --- a/main.c +++ b/main.c @@ -3,18 +3,21 @@ * * Copyright (C) 2013 Matt Corallo * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. + * This file is part of ASSS (Audit-friendly Shamir's Secret Sharing) * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * ASSS is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place - Suite 330, Boston, MA 02111-1307 USA. + * ASSS is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with ASSS. If not, see + * . */ #define _GNU_SOURCE @@ -55,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++) { @@ -198,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) @@ -206,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); }