sync_signatures.h (5395B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2026 Taler Systems SA 4 5 TALER 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 TALER 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 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file include/sync/sync_signatures.h 18 * @brief Utility functions for sync signatures 19 * @author Iván Ávalos 20 */ 21 #ifndef SYNC_SIGNATURES_H 22 #define SYNC_SIGNATURES_H 23 24 #include <gnunet/gnunet_util_lib.h> 25 #include "sync_service.h" 26 27 28 /** 29 * Sign a block upload (append/update). 30 * 31 * @param account_priv private key to sign with 32 * @param nonce nonce identifying the block 33 * @param prev_nonce nonce of the preceding block, NULL for none 34 * @param next_nonce nonce of the succeeding block, NULL for none 35 * @param old_hash hash of existing block data for an update, 36 * NULL for an append 37 * @param new_hash hash of the new block data 38 * @param refs_hash from #SYNC_object_refs_hash() 39 * @param[out] upload_sig signature to create 40 */ 41 void 42 SYNC_block_upload_sign ( 43 const struct SYNC_AccountPrivateKeyP *account_priv, 44 const struct SYNC_BlockNonce *nonce, 45 const struct SYNC_BlockNonce *prev_nonce, 46 const struct SYNC_BlockNonce *next_nonce, 47 const struct GNUNET_HashCode *old_hash, 48 const struct GNUNET_HashCode *new_hash, 49 const struct GNUNET_HashCode *refs_hash, 50 struct SYNC_AccountSignatureP *upload_sig); 51 52 53 /** 54 * Verify signature on a block upload (append/update). 55 * 56 * @param account_pub public key of the account 57 * @param nonce nonce identifying the block 58 * @param prev_nonce nonce of the preceding block, NULL for none 59 * @param next_nonce nonce of the succeeding block, NULL for none 60 * @param old_hash hash of existing block data for an update, 61 * NULL for an append 62 * @param new_hash hash of the new block data 63 * @param refs_hash from #SYNC_object_refs_hash() 64 * @param upload_sig signature to verify 65 * @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR otherwise 66 */ 67 enum GNUNET_GenericReturnValue 68 SYNC_block_upload_verify ( 69 const struct SYNC_AccountPublicKeyP *account_pub, 70 const struct SYNC_BlockNonce *nonce, 71 const struct SYNC_BlockNonce *prev_nonce, 72 const struct SYNC_BlockNonce *next_nonce, 73 const struct GNUNET_HashCode *old_hash, 74 const struct GNUNET_HashCode *new_hash, 75 const struct GNUNET_HashCode *refs_hash, 76 const struct SYNC_AccountSignatureP *upload_sig); 77 78 79 /** 80 * Sign a block deletion. 81 * 82 * @param account_priv private key to sign with 83 * @param nonce nonce of the block to delete 84 * @param prev_nonce nonce of the preceding block, NULL for none 85 * @param next_nonce nonce of the succeeding block, NULL for none 86 * @param hash hash of the block to delete 87 * @param refs_hash from #SYNC_object_refs_hash() 88 * @param[out] delete_sig signature to create 89 */ 90 void 91 SYNC_block_delete_sign ( 92 const struct SYNC_AccountPrivateKeyP *account_priv, 93 const struct SYNC_BlockNonce *nonce, 94 const struct SYNC_BlockNonce *prev_nonce, 95 const struct SYNC_BlockNonce *next_nonce, 96 const struct GNUNET_HashCode *hash, 97 const struct GNUNET_HashCode *refs_hash, 98 struct SYNC_AccountSignatureP *delete_sig); 99 100 101 /** 102 * Verify signature on a block deletion. 103 * 104 * @param account_pub public key of the account 105 * @param nonce nonce of the block to delete 106 * @param prev_nonce nonce of the preceding block, NULL for none 107 * @param next_nonce nonce of the succeeding block, NULL for none 108 * @param hash hash of the block to delete 109 * @param refs_hash from #SYNC_object_refs_hash() 110 * @param delete_sig signature to verify 111 * @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR otherwise 112 */ 113 enum GNUNET_GenericReturnValue 114 SYNC_block_delete_verify ( 115 const struct SYNC_AccountPublicKeyP *account_pub, 116 const struct SYNC_BlockNonce *nonce, 117 const struct SYNC_BlockNonce *prev_nonce, 118 const struct SYNC_BlockNonce *next_nonce, 119 const struct GNUNET_HashCode *hash, 120 const struct GNUNET_HashCode *refs_hash, 121 const struct SYNC_AccountSignatureP *delete_sig); 122 123 124 /** 125 * Sign an object upload. 126 * 127 * @param account_priv private key to sign with 128 * @param uid UID of the object to upload 129 * @param hash hash of the object to upload 130 * @param[out] upload_sig signature to create 131 */ 132 void 133 SYNC_object_upload_sign ( 134 const struct SYNC_AccountPrivateKeyP *account_priv, 135 const struct SYNC_ObjectUID *uid, 136 const struct GNUNET_HashCode *hash, 137 struct SYNC_AccountSignatureP *upload_sig); 138 139 140 /** 141 * Verify signature on an object upload. 142 * 143 * @param account_pub public key of the account 144 * @param uid UID of the object 145 * @param hash hash of the object 146 * @param upload_sig signature to verify 147 * @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR otherwise 148 */ 149 enum GNUNET_GenericReturnValue 150 SYNC_object_upload_verify ( 151 const struct SYNC_AccountPublicKeyP *account_pub, 152 const struct SYNC_ObjectUID *uid, 153 const struct GNUNET_HashCode *hash, 154 const struct SYNC_AccountSignatureP *upload_sig); 155 156 157 #endif