GNUnet 0.22.0
gnunet-elligator-tvg.c File Reference
#include "gnunet_common.h"
#include "gnunet_util_lib.h"
#include <gcrypt.h>
#include <stdio.h>
#include <sodium.h>
Include dependency graph for gnunet-elligator-tvg.c:

Go to the source code of this file.

Functions

static void eddsa_pub_to_hpke_key (struct GNUNET_CRYPTO_EddsaPublicKey *edpk, struct GNUNET_CRYPTO_EcdhePublicKey *pk)
 
int main (int argc, char *const *argv)
 The main function of the test vector generation tool. More...
 

Variables

static uint8_t seed = 6
 
static uint8_t skRmBytes [32]
 
static uint8_t pkRmBytes [32]
 
static uint8_t skEmBytes [32]
 

Function Documentation

◆ eddsa_pub_to_hpke_key()

static void eddsa_pub_to_hpke_key ( struct GNUNET_CRYPTO_EddsaPublicKey edpk,
struct GNUNET_CRYPTO_EcdhePublicKey pk 
)
static

Definition at line 56 of file gnunet-elligator-tvg.c.

58{
60 key.type = htonl (GNUNET_PUBLIC_KEY_TYPE_EDDSA);
61 key.eddsa_key = *edpk;
63}
struct GNUNET_HashCode key
The key used in the DHT.
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_pk_to_x25519(const struct GNUNET_CRYPTO_PublicKey *pk, struct GNUNET_CRYPTO_EcdhePublicKey *x25519)
Convert a GNUnet identity key to a key sutiable for HPKE (X25519)
Definition: crypto_hpke.c:989
@ GNUNET_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
An identity key as per LSD0001.

References GNUNET_CRYPTO_hpke_pk_to_x25519(), GNUNET_PUBLIC_KEY_TYPE_EDDSA, key, and pk.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

The main function of the test vector generation tool.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 74 of file gnunet-elligator-tvg.c.

76{
77 // hardcoded receiver key pair ("skRm","pkRm") and ephemeral secret key "skEm"
81 memcpy (skRm.d, skRmBytes, sizeof(skRm.d));
82 memcpy (pkRm.q_y, pkRmBytes, sizeof(pkRm.q_y));
83 memcpy (skEm.d, skEmBytes, sizeof(skEm.d));
84
85 // compute special elligator public key "pkEm" and representative "enc" deterministically
86 struct GNUNET_CRYPTO_EcdhePublicKey pkEm = {0};
87 struct GNUNET_CRYPTO_ElligatorRepresentative enc = {0}; // randomness through seed
89 &skEm,
90 &pkEm,
91 &enc);
92
93 // compute "key" deterministically
94 struct GNUNET_CRYPTO_EcdhePublicKey pkRmHpke = {0};
95 struct GNUNET_ShortHashCode key = {0};
96 eddsa_pub_to_hpke_key (&pkRm, &pkRmHpke);
98 &pkRmHpke,
99 (struct
101 *) &enc,
102 &skEm,
103 &key);
104
105 // print all
106 printf ("coin flip 1: %d\n", (seed) & 1); // high_y
107 printf ("coin flip 2: %d\n", (seed >> 1) & 1); // most significant bit (msb)
108 printf ("coin flip 3: %d\n", (seed >> 2) & 1); // second msb
109 printf ("pkEm: ");
110 GNUNET_print_bytes (pkEm.q_y, sizeof(pkEm.q_y), 0, 0);
111 printf ("skEm: ");
112 GNUNET_print_bytes (skEm.d, sizeof(skEm.d), 0, 0);
113 printf ("skRm: ");
114 GNUNET_print_bytes (skRm.d, sizeof(skRm.d), 0, 0);
115 printf ("pkRm: ");
116 GNUNET_print_bytes (pkRm.q_y, sizeof(pkRm.q_y), 0, 0);
117 printf ("enc: ");
118 GNUNET_print_bytes (enc.r, sizeof(enc.r), 0, 0);
119 printf ("key: ");
120 GNUNET_print_bytes (key.bits, sizeof(key.bits), 0, 0);
121}
static uint8_t pkRmBytes[32]
static uint8_t seed
static uint8_t skRmBytes[32]
static uint8_t skEmBytes[32]
static void eddsa_pub_to_hpke_key(struct GNUNET_CRYPTO_EddsaPublicKey *edpk, struct GNUNET_CRYPTO_EcdhePublicKey *pk)
static OpusEncoder * enc
OPUS encoder.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_ecdhe_elligator_key_get_public_norand(uint8_t random_tweak, const struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *sk, struct GNUNET_CRYPTO_EcdhePublicKey *pub, struct GNUNET_CRYPTO_ElligatorRepresentative *repr)
Generates a valid public key for elligator's inverse map by adding a lower order point to a prime ord...
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_elligator_kem_encaps_norand(uint8_t random_tweak, const struct GNUNET_CRYPTO_EcdhePublicKey *pkR, struct GNUNET_CRYPTO_HpkeEncapsulation *c, const struct GNUNET_CRYPTO_ElligatorEcdhePrivateKey *skE, struct GNUNET_ShortHashCode *shared_secret)
Carries out ecdh encapsulation with given public key and the private key from a freshly created ephem...
Definition: crypto_hpke.c:423
uint32_t bits[512/8/sizeof(uint32_t)]
void GNUNET_print_bytes(const void *buf, size_t buf_len, int fold, int in_be)
Print a byte string in hexadecimal ascii notation.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and encr...
unsigned char q_y[256/8]
Q consists of an x- and a y-value, each mod p (256 bits), given here in affine coordinates and Ed2551...
Private ECC key encoded for transmission.
Public ECC key (always for curve Ed25519) encoded in a format suitable for network transmission and E...
Special private ECC key generated by GNUNET_CRYPTO_ecdhe_elligator_key_create.
Elligator representative (always for Curve25519)
HPKE DHKEM encapsulation (X25519) See RFC 9180.
A 256-bit hashcode.

References GNUNET_HashCode::bits, GNUNET_CRYPTO_EddsaPrivateKey::d, GNUNET_CRYPTO_ElligatorEcdhePrivateKey::d, eddsa_pub_to_hpke_key(), enc, GNUNET_CRYPTO_ecdhe_elligator_key_get_public_norand(), GNUNET_CRYPTO_hpke_elligator_kem_encaps_norand(), GNUNET_print_bytes(), key, pkRmBytes, GNUNET_CRYPTO_EddsaPublicKey::q_y, GNUNET_CRYPTO_EcdhePublicKey::q_y, seed, skEmBytes, and skRmBytes.

Here is the call graph for this function:

Variable Documentation

◆ seed

◆ skRmBytes

uint8_t skRmBytes[32]
static
Initial value:
= {
0xf3, 0x38, 0x87, 0xa8, 0x56, 0x2d, 0xad, 0x51,
0x51, 0xe9, 0x28, 0x9a, 0x0a, 0xfa, 0x13, 0x01,
0xcc, 0xc6, 0x98, 0x91, 0x78, 0x50, 0xd5, 0x6e,
0xa4, 0x09, 0xa9, 0x94, 0x94, 0x97, 0xba, 0xa4
}

Definition at line 34 of file gnunet-elligator-tvg.c.

Referenced by main().

◆ pkRmBytes

uint8_t pkRmBytes[32]
static
Initial value:
= {
0x3f, 0xeb, 0xad, 0xac, 0x12, 0x2d, 0x39, 0x77,
0x25, 0xff, 0x58, 0x0f, 0x6c, 0xe9, 0xa3, 0xe1,
0xc1, 0xc4, 0xa7, 0xde, 0x19, 0x80, 0x7f, 0x13,
0xd3, 0x83, 0xf2, 0xf9, 0xb6, 0x46, 0x71, 0x36
}

Definition at line 41 of file gnunet-elligator-tvg.c.

Referenced by main().

◆ skEmBytes

uint8_t skEmBytes[32]
static
Initial value:
= {
0x09, 0x39, 0x59, 0x66, 0xd6, 0xd1, 0xc4, 0x93,
0xb9, 0x91, 0x7d, 0xd1, 0x2c, 0x8d, 0xd2, 0x4e,
0x2c, 0x05, 0xc0, 0x81, 0xc9, 0x8a, 0x67, 0xeb,
0x2d, 0x6d, 0xff, 0x62, 0x2e, 0xc9, 0xc0, 0x69
}

Definition at line 48 of file gnunet-elligator-tvg.c.

Referenced by main().