high_common.h (4534B)
1 /* 2 This file is part of Frosix 3 Copyright (C) 2022, 2023 Frosix 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 high_common.h 18 * @brief Provides functions which are used for different tasks during the signing or key generation process. 19 * @author Joel Urech 20 */ 21 #ifndef FROST_HIGH_COMMON_H 22 #define FROST_HIGH_COMMON_H 23 24 #include "frost_high.h" 25 26 /** 27 * Struct for a binding factor 28 */ 29 struct FROST_BindingFactor 30 { 31 /** 32 * For which participant is this binding factor? 33 */ 34 uint8_t identifier; 35 /** 36 * The binding factor 37 */ 38 struct FROST_Scalar binding_factor; 39 }; 40 41 /** 42 * Struct for a group commitment 43 */ 44 struct FROST_GroupCommitment 45 { 46 /** 47 * Our group commitment is a point on the curve 48 */ 49 struct FROST_Point commitment; 50 }; 51 52 /** 53 * Struct for the lagrange coefficient 54 */ 55 struct FROST_Coefficient 56 { 57 /** 58 * Our lagrange coefficient is a FROST_Scalar 59 */ 60 struct FROST_Scalar coeff; 61 }; 62 63 /** 64 * Struct for the signature challenge 65 */ 66 struct FROST_Challenge 67 { 68 /** 69 * Our challenge is a hash, mapped to a scalar in range of the order of the ristretto255 group 70 */ 71 struct FROST_Scalar challenge; 72 }; 73 74 /** 75 * @brief Computes the set of binding values for all participating participants. 76 * 77 * @param[out] binding_factors The resulting set of binding factors 78 * @param[in] commitments Array of all commitments 79 * @param commitments_len Length of commitments array 80 * @param[in] mh The message we have to sign 81 */ 82 void 83 FROST_compute_binding_factors_ ( 84 struct FROST_BindingFactor binding_factors[], 85 const struct FROST_Commitment commitments[], 86 uint8_t commitments_len, 87 const struct FROST_MessageHash *mh); 88 89 /** 90 * @brief Computes the group commitment. 91 * 92 * @param[out] group_commitment The resulting group commitment 93 * @param[in] commitments List of all commitments 94 * @param[in] binding_factors Set of all binding factors 95 * @param comm_and_bind_len Number of elements in commitments and binding_factors 96 */ 97 void FROST_compute_group_commitment_ ( 98 struct FROST_GroupCommitment *group_commitment, 99 const struct FROST_Commitment commitments[], 100 const struct FROST_BindingFactor binding_factors[], 101 uint8_t comm_and_bind_len); 102 103 /** 104 * @brief Returns the binding factor of a specific participant. 105 * 106 * @param[out] binding_factor The found binding factor 107 * @param[in] binding_factors Set of all binding factors 108 * @param binding_factors_len Number of elements in binding_factors 109 * @param participant The participant for whom we are looking for the binding factor 110 * @return GNUNET_OK if a binding factor was found, otherwise GNUNET_NO 111 */ 112 enum GNUNET_GenericReturnValue 113 FROST_binding_factor_for_participant_ ( 114 struct FROST_BindingFactor *binding_factor, 115 const struct FROST_BindingFactor binding_factors[], 116 uint8_t binding_factors_len, 117 uint8_t participant); 118 119 /** 120 * @brief Computes the lagrange coefficient for a specific participant. 121 * 122 * @param[out] coefficient The resulting lagrange coefficient 123 * @param[in] participant The participant for which we need the lagrange coefficient 124 * @param[in] commitments List of all commitments. We only need the identifiers of the participants from it 125 * @param commitments_len Length of commitment list 126 * @return 1 if success, otherwise 0 127 */ 128 enum GNUNET_GenericReturnValue 129 FROST_compute_lagrange_coefficient_ ( 130 struct FROST_Coefficient *coefficient, 131 uint8_t participant, 132 const struct FROST_Commitment commitments[], 133 size_t commitments_len); 134 135 /** 136 * @brief Computes the signature challenge 137 * 138 * @param[out] challenge The resulting challenge 139 * @param[in] group_commitment A previously computed group commitment 140 * @param[in] group_pk Public key of the signing group 141 * @param[in] mh Our hash of the message we have to sign 142 */ 143 void 144 FROST_compute_challenge_ ( 145 struct FROST_Challenge *challenge, 146 const struct FROST_GroupCommitment *group_commitment, 147 const struct FROST_PublicKey *group_pk, 148 const struct FROST_MessageHash *mh); 149 150 #endif