GNUnet debian-0.24.3-29-g453fda2cf
 
Loading...
Searching...
No Matches
gnunet-pils-tvg.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2025 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
25#include "platform.h"
26#include "gnunet_util_lib.h"
28#include "gnunet_pils_service.h"
29#include "pils.h"
30#include <inttypes.h>
31
32
33static const char *d_seed =
34 "50d7b652a4efeadff37396909785e5952171a02178c8e7d450fa907925fafd98";
35
36static uint8_t seed_key[256/ 8];
37
38static void
39print_addr (void *cls,
40 const struct GNUNET_PeerIdentity *pid,
41 const char *uri)
42{
43 printf ("%s\n", uri);
44}
45
54static void
55run (void *cls,
56 char *const *args,
57 const char *cfgfile,
59 )
60{
61 struct GNUNET_HELLO_Builder *b;
62 struct GNUNET_HashCode hash;
63 struct GNUNET_CRYPTO_EddsaPrivateKey derived_key;
64
67 "gnunet+tcp://1.2.3.4"));
69 "gnunet+udp://6.7.8.9"));
71 "gnunet+https://example.gnu"));
72
73 printf ("Addresses (sorted):\n");
75 printf ("\n");
77 printf ("Address hash:\n");
78 GNUNET_print_bytes (&hash, sizeof hash, 8, 0);
79 printf ("\n");
80
82 printf("Seed key:\n");
84 printf ("\n");
85
86 printf("Derived key:\n");
87 GNUNET_PILS_derive_pid(sizeof seed_key, seed_key, &hash, &derived_key);
88 GNUNET_print_bytes(&derived_key, sizeof derived_key, 8, 0);
89}
90
91
99int
100main (int argc,
101 char *const *argv
102 )
103{
106 };
107
108 GNUNET_assert (GNUNET_OK ==GNUNET_log_setup ("gnunet-gns-tvg", "INFO", NULL));
109 // gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0);
110 // gcry_control (GCRYCTL_SET_VERBOSITY, 99);
112 argc,
113 argv,
114 "gnunet-pils-tvg",
115 "Generate test vectors for PILS",
116 options,
117 &run,
118 NULL))
119 return 1;
120 return 0;
121}
122
123
124/* end of gnunet-gns-tvg.c */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition 002.c:5
int main()
Program to simulate results from GCP_get_desirability_of_path() for various plausible inputs.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
static void print_addr(void *cls, const struct GNUNET_PeerIdentity *pid, const char *uri)
static uint8_t seed_key[256/8]
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run.
static const char * d_seed
static struct GNUNET_FS_Uri * uri
Value of URI provided on command-line (when not publishing a file but just creating UBlocks to refer ...
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
Helper library for handling HELLO URIs.
void GNUNET_PILS_derive_pid(size_t seed_key_bytes, const uint8_t seed_key[seed_key_bytes], const struct GNUNET_HashCode *addrs_hash, struct GNUNET_CRYPTO_EddsaPrivateKey *outkey)
Generate the peer id from the addresses hash and the initial secret key.
Definition pils_api.c:507
#define GNUNET_GETOPT_OPTION_END
Marker for the end of the list of options.
struct GNUNET_HELLO_Builder * GNUNET_HELLO_builder_new()
Allocate builder.
Definition hello-uri.c:343
void GNUNET_HELLO_builder_iterate(const struct GNUNET_HELLO_Builder *builder, GNUNET_HELLO_UriCallback uc, void *uc_cls)
Iterate over URIs in a builder.
Definition hello-uri.c:956
enum GNUNET_GenericReturnValue GNUNET_HELLO_builder_add_address(struct GNUNET_HELLO_Builder *builder, const char *address)
Add individual address to the builder.
Definition hello-uri.c:624
void GNUNET_HELLO_builder_hash_addresses(const struct GNUNET_HELLO_Builder *builder, struct GNUNET_HashCode *hash)
Compute hash over addresses in builder.
Definition hello-uri.c:1134
@ GNUNET_OK
void GNUNET_print_bytes(const void *buf, size_t buf_len, int fold, int in_be)
Print a byte string in hexadecimal ascii notation.
size_t GNUNET_hex2b(const char *src, void *dst, size_t dstlen, int invert)
Parse an ascii-encoded hexadecimal string into the buffer.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
enum GNUNET_GenericReturnValue GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition program.c:407
Common type definitions for the peer identity lifecycle service and API.
Private ECC key encoded for transmission.
Definition of a command line option.
Context for building (or parsing) HELLO URIs.
Definition hello-uri.c:184
A 512-bit hashcode.
The identity of the host (wraps the signing key of the peer).