frosix

Multiparty signature service (experimental)
Log | Files | Refs | README | LICENSE

keygen_finalize.c (2004B)


      1 /*
      2   This file is part of Frosix
      3   Copyright (C) 2022, 2023 Joel Urech
      4 
      5   Frosix is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU Affero General Public License as published by the Free Software
      7   Foundation; either version 3, or (at your option) any later version.
      8 
      9   Frosix is distributed in the hope that it will be useful, but WITHOUT ANY
     10   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11   A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
     12 
     13   You should have received a copy of the GNU Affero General Public License along with
     14   Frosix; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15 */
     16 /**
     17  * @file keygen_finalize.c
     18  * @brief Implementation of the finalization of the distributed key generation process
     19  * @author Joel Urech
     20 */
     21 #include "keygen.h"
     22 
     23 /**
     24  * With the shares of all other participants, this function computes the
     25  * individual key pair and derives the group public key from the commitments.
     26 */
     27 void
     28 FROST_keygen_finalize (struct FROST_KeyPair *keypair,
     29                        uint8_t my_index,
     30                        const struct FROST_DkgShare shares[],
     31                        const struct FROST_DkgCommitment commitments[],
     32                        uint8_t num_of_participants)
     33 {
     34   // id
     35   keypair->identifier = my_index;
     36 
     37   // sk_i
     38   FROST_scalar_zero (&keypair->my_sk);
     39   for (int i = 0; i < num_of_participants; i++)
     40   {
     41     FROST_scalar_add_scalar (&keypair->my_sk,
     42                              &keypair->my_sk,
     43                              &shares[i].share);
     44   }
     45 
     46   // pk_i
     47   FROST_base_mul_scalar (&keypair->my_pk,
     48                          &keypair->my_sk);
     49 
     50   // set pk from keypair to 0
     51   FROST_point_identity (&keypair->group_pk.pk);
     52 
     53   for (int i = 0; i < num_of_participants; i++)
     54   {
     55     FROST_point_add_point (&keypair->group_pk.pk,
     56                            &keypair->group_pk.pk,
     57                            &commitments[i].share_comm[0].sc);
     58   }
     59 }