lift code to recent GNUNET version; uncrustify

This commit is contained in:
Özgür Kesim 2024-01-14 21:42:10 +01:00
parent 09af66c165
commit e095416bc2
Signed by: oec
GPG Key ID: 3D76A56D79EDD9D7
16 changed files with 4330 additions and 4249 deletions

316
INSTALL
View File

@ -1,8 +1,8 @@
Installation Instructions
*************************
Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
Inc.
Copyright (C) 1994-1996, 1999-2002, 2004-2017, 2020-2021 Free
Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
@ -12,97 +12,96 @@ without warranty of any kind.
Basic Installation
==================
Briefly, the shell command `./configure && make && make install'
Briefly, the shell command './configure && make && make install'
should configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
more-detailed instructions are generic; see the 'README' file for
instructions specific to this package. Some packages provide this
`INSTALL' file but do not implement all of the features documented
'INSTALL' file but do not implement all of the features documented
below. The lack of an optional feature in a given package is not
necessarily a bug. More recommendations for GNU packages can be found
in *note Makefile Conventions: (standards)Makefile Conventions.
The `configure' shell script attempts to guess correct values for
The 'configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
those values to create a 'Makefile' in each directory of the package.
It may also create one or more '.h' files containing system-dependent
definitions. Finally, it creates a shell script 'config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
file 'config.log' containing compiler output (useful mainly for
debugging 'configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
It can also use an optional file (typically called 'config.cache' and
enabled with '--cache-file=config.cache' or simply '-C') that saves the
results of its tests to speed up reconfiguring. Caching is disabled by
default to prevent problems with accidental use of stale cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
to figure out how 'configure' could check whether to do them, and mail
diffs or instructions to the address given in the 'README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
some point 'config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The file 'configure.ac' (or 'configure.in') is used to create
'configure' by a program called 'autoconf'. You need 'configure.ac' if
you want to change it or regenerate 'configure' using a newer version of
'autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
1. 'cd' to the directory containing the package's source code and type
'./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
Running 'configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
2. Type 'make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
3. Optionally, type 'make check' to run any self-tests that come with
the package, generally using the just-built uninstalled binaries.
4. Type `make install' to install the programs and any data files and
4. Type 'make install' to install the programs and any data files and
documentation. When installing into a prefix owned by root, it is
recommended that the package be configured and built as a regular
user, and only the `make install' phase executed with root
user, and only the 'make install' phase executed with root
privileges.
5. Optionally, type `make installcheck' to repeat any self-tests, but
5. Optionally, type 'make installcheck' to repeat any self-tests, but
this time using the binaries in their final installed location.
This target does not install anything. Running this target as a
regular user, particularly if the prior `make install' required
regular user, particularly if the prior 'make install' required
root privileges, verifies that the installation completed
correctly.
6. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
source code directory by typing 'make clean'. To also remove the
files that 'configure' created (so you can compile the package for
a different kind of computer), type 'make distclean'. There is
also a 'make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
7. Often, you can also type `make uninstall' to remove the installed
7. Often, you can also type 'make uninstall' to remove the installed
files again. In practice, not all packages have tested that
uninstallation works correctly, even though it is required by the
GNU Coding Standards.
8. Some packages, particularly those that use Automake, provide `make
8. Some packages, particularly those that use Automake, provide 'make
distcheck', which can by used by developers to test that all other
targets like `make install' and `make uninstall' work correctly.
targets like 'make install' and 'make uninstall' work correctly.
This target is generally not run by end users.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
the 'configure' script does not know about. Run './configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
You can give 'configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here is
an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
@ -113,21 +112,21 @@ Compiling For Multiple Architectures
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
own directory. To do this, you can use GNU 'make'. 'cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'. This
is known as a "VPATH" build.
the 'configure' script. 'configure' automatically checks for the source
code in the directory that 'configure' is in and in '..'. This is known
as a "VPATH" build.
With a non-GNU `make', it is safer to compile the package for one
With a non-GNU 'make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
installed the package for one architecture, use 'make distclean' before
reconfiguring for another architecture.
On MacOS X 10.5 and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple `-arch' options to the
compiler but only a single `-arch' option to the preprocessor. Like
"universal" binaries--by specifying multiple '-arch' options to the
compiler but only a single '-arch' option to the preprocessor. Like
this:
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
@ -136,105 +135,104 @@ this:
This is not guaranteed to produce working output in all cases, you
may have to build one architecture at a time and combine the results
using the `lipo' tool if you have problems.
using the 'lipo' tool if you have problems.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX', where PREFIX must be an
By default, 'make install' installs the package's commands under
'/usr/local/bin', include files under '/usr/local/include', etc. You
can specify an installation prefix other than '/usr/local' by giving
'configure' the option '--prefix=PREFIX', where PREFIX must be an
absolute file name.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
pass the option '--exec-prefix=PREFIX' to 'configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them. In general, the
default for these options is expressed in terms of `${prefix}', so that
specifying just `--prefix' will affect all of the other directory
options like '--bindir=DIR' to specify different values for particular
kinds of files. Run 'configure --help' for a list of the directories
you can set and what kinds of files go in them. In general, the default
for these options is expressed in terms of '${prefix}', so that
specifying just '--prefix' will affect all of the other directory
specifications that were not explicitly provided.
The most portable way to affect installation locations is to pass the
correct locations to `configure'; however, many packages provide one or
correct locations to 'configure'; however, many packages provide one or
both of the following shortcuts of passing variable assignments to the
`make install' command line to change installation locations without
'make install' command line to change installation locations without
having to reconfigure or recompile.
The first method involves providing an override variable for each
affected directory. For example, `make install
affected directory. For example, 'make install
prefix=/alternate/directory' will choose an alternate location for all
directory configuration variables that were expressed in terms of
`${prefix}'. Any directories that were specified during `configure',
but not in terms of `${prefix}', must each be overridden at install
time for the entire installation to be relocated. The approach of
makefile variable overrides for each directory variable is required by
the GNU Coding Standards, and ideally causes no recompilation.
However, some platforms have known limitations with the semantics of
shared libraries that end up requiring recompilation when using this
method, particularly noticeable in packages that use GNU Libtool.
'${prefix}'. Any directories that were specified during 'configure',
but not in terms of '${prefix}', must each be overridden at install time
for the entire installation to be relocated. The approach of makefile
variable overrides for each directory variable is required by the GNU
Coding Standards, and ideally causes no recompilation. However, some
platforms have known limitations with the semantics of shared libraries
that end up requiring recompilation when using this method, particularly
noticeable in packages that use GNU Libtool.
The second method involves providing the `DESTDIR' variable. For
example, `make install DESTDIR=/alternate/directory' will prepend
`/alternate/directory' before all installation names. The approach of
`DESTDIR' overrides is not required by the GNU Coding Standards, and
The second method involves providing the 'DESTDIR' variable. For
example, 'make install DESTDIR=/alternate/directory' will prepend
'/alternate/directory' before all installation names. The approach of
'DESTDIR' overrides is not required by the GNU Coding Standards, and
does not work on platforms that have drive letters. On the other hand,
it does better at avoiding recompilation issues, and works well even
when some directory options were not specified in terms of `${prefix}'
at `configure' time.
when some directory options were not specified in terms of '${prefix}'
at 'configure' time.
Optional Features
=================
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
with an extra prefix or suffix on their names by giving 'configure' the
option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'.
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
Some packages pay attention to '--enable-FEATURE' options to
'configure', where FEATURE indicates an optional part of the package.
They may also pay attention to '--with-PACKAGE' options, where PACKAGE
is something like 'gnu-as' or 'x' (for the X Window System). The
'README' should mention any '--enable-' and '--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
For packages that use the X Window System, 'configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
you can use the 'configure' options '--x-includes=DIR' and
'--x-libraries=DIR' to specify their locations.
Some packages offer the ability to configure how verbose the
execution of `make' will be. For these packages, running `./configure
execution of 'make' will be. For these packages, running './configure
--enable-silent-rules' sets the default to minimal output, which can be
overridden with `make V=1'; while running `./configure
overridden with 'make V=1'; while running './configure
--disable-silent-rules' sets the default to verbose, which can be
overridden with `make V=0'.
overridden with 'make V=0'.
Particular systems
==================
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
CC is not installed, it is recommended to use the following options in
On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC
is not installed, it is recommended to use the following options in
order to use an ANSI C compiler:
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
HP-UX `make' updates targets which have the same time stamps as
their prerequisites, which makes it generally unusable when shipped
generated files such as `configure' are involved. Use GNU `make'
instead.
HP-UX 'make' updates targets which have the same timestamps as their
prerequisites, which makes it generally unusable when shipped generated
files such as 'configure' are involved. Use GNU 'make' instead.
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
a workaround. If GNU CC is not installed, it is therefore recommended
to try
parse its '<wchar.h>' header file. The option '-nodtk' can be used as a
workaround. If GNU CC is not installed, it is therefore recommended to
try
./configure CC="cc"
@ -242,26 +240,26 @@ and if that doesn't work, try
./configure CC="cc -nodtk"
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
On Solaris, don't put '/usr/ucb' early in your 'PATH'. This
directory contains several dysfunctional programs; working variants of
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
in your `PATH', put it _after_ `/usr/bin'.
these programs are available in '/usr/bin'. So, if you need '/usr/ucb'
in your 'PATH', put it _after_ '/usr/bin'.
On Haiku, software installed for all users goes in `/boot/common',
not `/usr/local'. It is recommended to use the following options:
On Haiku, software installed for all users goes in '/boot/common',
not '/usr/local'. It is recommended to use the following options:
./configure --prefix=/boot/common
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
There may be some features 'configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
_same_ architectures, 'configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
'--build=TYPE' option. TYPE can either be a short name for the system
type, such as 'sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
@ -270,101 +268,101 @@ where SYSTEM can have one of these forms:
OS
KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
See the file 'config.sub' for the possible values of each field. If
'config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
use the option '--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
eventually be run) with '--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
If you want to set default values for 'configure' scripts to share,
you can create a site shell script called 'config.site' that gives
default values for variables like 'CC', 'cache_file', and 'prefix'.
'configure' looks for 'PREFIX/share/config.site' if it exists, then
'PREFIX/etc/config.site' if it exists. Or, you can set the
'CONFIG_SITE' environment variable to the location of the site script.
A warning: not all 'configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
environment passed to 'configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
them in the 'configure' command line, using 'VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
causes the specified 'gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf limitation. Until the limitation is lifted, you can use
this workaround:
Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an
Autoconf limitation. Until the limitation is lifted, you can use this
workaround:
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
'configure' Invocation
======================
`configure' recognizes the following options to control how it
'configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of all of the options to `configure', and exit.
'--help'
'-h'
Print a summary of all of the options to 'configure', and exit.
`--help=short'
`--help=recursive'
'--help=short'
'--help=recursive'
Print a summary of the options unique to this package's
`configure', and exit. The `short' variant lists options used
only in the top level, while the `recursive' variant lists options
also present in any nested packages.
'configure', and exit. The 'short' variant lists options used only
in the top level, while the 'recursive' variant lists options also
present in any nested packages.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
'--version'
'-V'
Print the version of Autoconf used to generate the 'configure'
script, and exit.
`--cache-file=FILE'
'--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
traditionally 'config.cache'. FILE defaults to '/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
'--config-cache'
'-C'
Alias for '--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
'--quiet'
'--silent'
'-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
suppress all normal output, redirect it to '/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
'--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
'configure' can determine that directory automatically.
`--prefix=DIR'
Use DIR as the installation prefix. *note Installation Names::
for more details, including other options available for fine-tuning
the installation locations.
'--prefix=DIR'
Use DIR as the installation prefix. *note Installation Names:: for
more details, including other options available for fine-tuning the
installation locations.
`--no-create'
`-n'
'--no-create'
'-n'
Run the configure checks, but stop before creating any output
files.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.
'configure' also accepts some other, not widely useful, options. Run
'configure --help' for more details.

29
bench.c
View File

@ -30,14 +30,16 @@
#define MIN(A, B) ((A) < (B) ? (A) : (B))
struct msg {
struct msg
{
uint16_t sender;
uint16_t receiver;
void *buf;
size_t buf_len;
};
struct testcase {
struct testcase
{
uint16_t n;
uint16_t k;
uint16_t *bids;
@ -450,20 +452,24 @@ main (int argc, char *argv[])
uint16_t *bids = NULL;
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_option_help ("benchmark a single libbrandt auction"),
{'k', "k", "NUMBER",
GNUNET_GETOPT_option_uint16 (
'k', "k", "NUMBER",
gettext_noop ("number of prices\n"),
1, &GNUNET_GETOPT_option_uint, &k},
{'n', "n", "NUMBER",
&k),
GNUNET_GETOPT_option_uint16 (
'n', "n", "NUMBER",
gettext_noop ("number of bidders\n"),
1, &GNUNET_GETOPT_option_uint, &n},
{'m', "m", "NUMBER",
&n),
GNUNET_GETOPT_option_uint16 (
'm', "m", "NUMBER",
gettext_noop ("number of items to sell\n"
"0 for first price auction\n"
">0 for vickrey/M+1st price auction"),
1, &GNUNET_GETOPT_option_uint, &m},
{'p', "public", NULL,
&m),
GNUNET_GETOPT_option_uint16 (
'p', "public", NULL,
gettext_noop ("public auction outcome"),
0, &GNUNET_GETOPT_option_flag, &public},
&public),
GNUNET_GETOPT_OPTION_END
};
@ -483,7 +489,8 @@ main (int argc, char *argv[])
if (! (bids = calloc (sizeof(uint16_t), n)))
return 1;
for (uint16_t i = 0; i < n; i++)
bids[i] = (uint16_t)GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, k);
bids[i] = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
k);
edc = GNUNET_CRYPTO_ecc_dlog_prepare (1024, 16);
BRANDT_init ();

View File

@ -32,7 +32,8 @@
struct BRANDT_Auction;
/** Enumeration of all possible status reports for a single bidder */
enum BRANDT_BidderStatus {
enum BRANDT_BidderStatus
{
BRANDT_bidder_won,
};
@ -40,7 +41,8 @@ enum BRANDT_BidderStatus {
* An array of this struct is given to the application by the BRANDT_CbResult()
* callback. One instance represents the status of a single bidder.
*/
struct BRANDT_Result {
struct BRANDT_Result
{
/** Id of the bidder this instance refers to */
uint16_t bidder;

View File

@ -51,13 +51,15 @@
} while (0)
struct zkp_challenge_dl {
struct zkp_challenge_dl
{
struct ec_mpi g;
struct ec_mpi v;
struct ec_mpi a;
};
struct zkp_challenge_2dle {
struct zkp_challenge_2dle
{
struct ec_mpi g1;
struct ec_mpi g2;
struct ec_mpi v;
@ -66,7 +68,8 @@ struct zkp_challenge_2dle {
struct ec_mpi b;
};
struct zkp_challenge_0og {
struct zkp_challenge_0og
{
struct ec_mpi g;
struct ec_mpi alpha;
struct ec_mpi beta;
@ -646,9 +649,9 @@ smc_gen_keyshare (struct BRANDT_Auction *ad, size_t *buflen)
struct proof_dl *proof1;
brandt_assert (ad && buflen);
*buflen = (sizeof (*head) +
sizeof (*pubkey_share) +
sizeof (*proof1));
*buflen = (sizeof (*head)
+ sizeof (*pubkey_share)
+ sizeof (*proof1));
ret = GNUNET_new_array (*buflen, unsigned char);
head = (struct msg_head *) ret;
@ -743,11 +746,11 @@ smc_encrypt_bid (struct BRANDT_Auction *ad, size_t *buflen)
gcry_mpi_t r_part;
brandt_assert (ad && buflen);
*buflen = (sizeof (*head) + /* msg header */
ad->k * /* k * (alpha, beta, proof3) */
(sizeof (struct ec_mpi) * 2 +
sizeof (*proof3)) +
sizeof (struct proof_2dle)); /* proof2 */
*buflen = (sizeof (*head) /* msg header */
+ ad->k /* k * (alpha, beta, proof3) */
* (sizeof (struct ec_mpi) * 2
+ sizeof (*proof3))
+ sizeof (struct proof_2dle)); /* proof2 */
if (0 < ad->m)
*buflen += sizeof (struct proof_2dle);
ret = GNUNET_new_array (*buflen, unsigned char);
@ -815,8 +818,8 @@ smc_recv_encrypted_bid (struct BRANDT_Auction *ad,
brandt_assert (ad && buf);
if (buflen != (ad->k * (sizeof (struct ec_mpi) * 2 + sizeof (*proof3)) +
(0 < ad->m ? 2 : 1) * sizeof (struct proof_2dle)) ||
if (buflen != (ad->k * (sizeof (struct ec_mpi) * 2 + sizeof (*proof3))
+ (0 < ad->m ? 2 : 1) * sizeof (struct proof_2dle)) ||
NULL == (ct = smc_init2 (2, ad->k)))
{
GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,

View File

@ -37,18 +37,25 @@ void brandt_crypto_init ();
/* used for serialized mpis and serialized curve points (they are the same size
* when compressed) */
struct ec_mpi {
struct ec_mpi
{
unsigned char data[256 / 8];
};
void ec_point_serialize (struct ec_mpi *dst, const gcry_mpi_point_t src);
void ec_point_parse (gcry_mpi_point_t dst, const struct ec_mpi *src);
gcry_mpi_point_t *smc_init1 (uint16_t size1);
gcry_mpi_point_t **smc_init2 (uint16_t size1, uint16_t size2);
gcry_mpi_point_t ***smc_init3 (uint16_t size1, uint16_t size2, uint16_t size3);
void smc_free1 (gcry_mpi_point_t *dst, uint16_t size1);
void smc_free2 (gcry_mpi_point_t **dst, uint16_t size1, uint16_t size2);
void smc_free3 (gcry_mpi_point_t ***dst,
uint16_t size1,
uint16_t size2,
@ -59,15 +66,20 @@ void smc_sums_partial (gcry_mpi_point_t out[],
uint16_t len,
uint16_t stepi,
uint16_t stepo);
void smc_sum (gcry_mpi_point_t out,
gcry_mpi_point_t in[],
uint16_t len,
uint16_t step);
void ec_point_copy (gcry_mpi_point_t dst, const gcry_mpi_point_t src);
int ec_point_cmp (const gcry_mpi_point_t a, const gcry_mpi_point_t b);
void ec_skey_create (gcry_mpi_t skey);
void ec_keypair_create (gcry_mpi_point_t pkey, gcry_mpi_t skey);
void ec_keypair_create_base (gcry_mpi_point_t pkey,
gcry_mpi_t skey,
const gcry_mpi_point_t base);
@ -75,18 +87,21 @@ void ec_keypair_create_base (gcry_mpi_point_t pkey,
/* --- Zero knowledge proofs --- */
struct proof_dl {
struct proof_dl
{
struct ec_mpi r;
struct ec_mpi a;
};
struct proof_2dle {
struct proof_2dle
{
struct ec_mpi r;
struct ec_mpi a;
struct ec_mpi b;
};
struct proof_0og {
struct proof_0og
{
struct ec_mpi a1;
struct ec_mpi a2;
struct ec_mpi b1;
@ -100,6 +115,7 @@ struct proof_0og {
void smc_zkp_dl (gcry_mpi_point_t v,
const gcry_mpi_t x,
struct proof_dl *proof);
int smc_zkp_dl_check (const gcry_mpi_point_t v,
const struct proof_dl *proof);
@ -109,6 +125,7 @@ void smc_zkp_2dle (const gcry_mpi_point_t v,
const gcry_mpi_point_t g2,
const gcry_mpi_t x,
struct proof_2dle *proof);
int smc_zkp_2dle_check (const gcry_mpi_point_t v,
const gcry_mpi_point_t w,
const gcry_mpi_point_t g1,
@ -121,6 +138,7 @@ void smc_zkp_0og (int m_is_gen,
gcry_mpi_point_t alpha,
gcry_mpi_point_t beta,
struct proof_0og *proof);
int smc_zkp_0og_check (const gcry_mpi_point_t y,
const gcry_mpi_point_t alpha,
const gcry_mpi_point_t beta,
@ -130,30 +148,38 @@ int smc_zkp_0og_check (const gcry_mpi_point_t y,
/* --- Protocol implementation --- */
void smc_prep_keyshare (struct BRANDT_Auction *ad);
unsigned char *smc_gen_keyshare (struct BRANDT_Auction *ad, size_t *buflen);
int smc_recv_keyshare (struct BRANDT_Auction *ad,
const unsigned char *buf,
size_t buflen,
uint16_t sender_index);
void smc_prep_bid (struct BRANDT_Auction *ad);
unsigned char *smc_encrypt_bid (struct BRANDT_Auction *ad, size_t *buflen);
int smc_recv_encrypted_bid (struct BRANDT_Auction *ad,
const unsigned char *buf,
size_t buflen,
uint16_t sender_index);
void fp_priv_prep_outcome (struct BRANDT_Auction *ad);
unsigned char *fp_priv_compute_outcome (struct BRANDT_Auction *ad,
size_t *buflen);
int fp_priv_recv_outcome (struct BRANDT_Auction *ad,
const unsigned char *buf,
size_t buflen,
uint16_t sender);
void fp_priv_prep_decryption (struct BRANDT_Auction *ad);
unsigned char *fp_priv_decrypt_outcome (struct BRANDT_Auction *ad,
size_t *buflen);
int fp_priv_recv_decryption (struct BRANDT_Auction *ad,
const unsigned char *buf,
size_t buflen,
@ -163,16 +189,20 @@ struct BRANDT_Result *fp_priv_determine_outcome (struct BRANDT_Auction *ad,
uint16_t *len);
void fp_pub_prep_outcome (struct BRANDT_Auction *ad);
unsigned char *fp_pub_compute_outcome (struct BRANDT_Auction *ad,
size_t *buflen);
int fp_pub_recv_outcome (struct BRANDT_Auction *ad,
const unsigned char *buf,
size_t buflen,
uint16_t sender);
void fp_pub_prep_decryption (struct BRANDT_Auction *ad);
unsigned char *fp_pub_decrypt_outcome (struct BRANDT_Auction *ad,
size_t *buflen);
int fp_pub_recv_decryption (struct BRANDT_Auction *ad,
const unsigned char *buf,
size_t buflen,
@ -189,16 +219,20 @@ struct BRANDT_Result *mp_priv_determine_outcome (struct BRANDT_Auction *ad,
void mp_pub_prep_outcome (struct BRANDT_Auction *ad);
unsigned char *mp_pub_compute_outcome (struct BRANDT_Auction *ad,
size_t *buflen);
int mp_pub_recv_outcome (struct BRANDT_Auction *ad,
const unsigned char *buf,
size_t buflen,
uint16_t sender);
void mp_pub_prep_decryption (struct BRANDT_Auction *ad);
unsigned char *mp_pub_decrypt_outcome (struct BRANDT_Auction *ad,
size_t *buflen);
int mp_pub_recv_decryption (struct BRANDT_Auction *ad,
const unsigned char *buf,
size_t buflen,
@ -379,5 +413,4 @@ static const Result handler_res[auction_last][outcome_last] = {
};
#endif /* ifndef _BRANDT_CRYPTO_H */

View File

@ -167,9 +167,9 @@ fp_priv_compute_outcome (struct BRANDT_Auction *ad, size_t *buflen)
brandt_assert (ad && buflen);
*buflen = (sizeof (*head) + /* msg header */
ad->n * ad->k * /* nk * (gamma, delta, proof2) */
(sizeof (*gamma) + sizeof (*delta) + sizeof (*proof2)));
*buflen = (sizeof (*head) /* msg header */
+ ad->n * ad->k /* nk * (gamma, delta, proof2) */
* (sizeof (*gamma) + sizeof (*delta) + sizeof (*proof2)));
ret = GNUNET_new_array (*buflen, unsigned char);
head = (struct msg_head *) ret;
@ -223,8 +223,8 @@ fp_priv_recv_outcome (struct BRANDT_Auction *ad,
brandt_assert (ad && buf);
if (buflen != (ad->n * ad->k *
(2 * sizeof (struct ec_mpi) + sizeof (*proof2))))
if (buflen != (ad->n * ad->k
* (2 * sizeof (struct ec_mpi) + sizeof (*proof2))))
{
GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING,
"libbrandt",
@ -306,9 +306,9 @@ fp_priv_decrypt_outcome_seller (struct BRANDT_Auction *ad, size_t *buflen)
struct ec_mpi *phi;
struct proof_2dle *proof2;
*buflen = (sizeof (*head) +
(ad->n - 1) * ad->n * ad->k * (sizeof (*phi) +
sizeof (*proof2)));
*buflen = (sizeof (*head)
+ (ad->n - 1) * ad->n * ad->k * (sizeof (*phi)
+ sizeof (*proof2)));
ret = GNUNET_new_array (*buflen, unsigned char);
head = (struct msg_head *) ret;
@ -352,8 +352,8 @@ fp_priv_decrypt_outcome_bidder (struct BRANDT_Auction *ad, size_t *buflen)
struct ec_mpi *phi;
struct proof_2dle *proof2;
*buflen = (sizeof (*head) +
ad->n * ad->k * (sizeof (*phi) + sizeof (*proof2)));
*buflen = (sizeof (*head)
+ ad->n * ad->k * (sizeof (*phi) + sizeof (*proof2)));
ret = GNUNET_new_array (*buflen, unsigned char);
head = (struct msg_head *) ret;
@ -475,8 +475,8 @@ fp_priv_recv_decryption_bidder (struct BRANDT_Auction *ad,
struct proof_2dle *proof2;
gcry_mpi_point_t phi = gcry_mpi_point_new (0);
if (buflen != ((ad->n - 1) * ad->n * ad->k * (sizeof (struct ec_mpi) +
sizeof (*proof2))))
if (buflen != ((ad->n - 1) * ad->n * ad->k * (sizeof (struct ec_mpi)
+ sizeof (*proof2))))
{
GNUNET_log_from (
GNUNET_ERROR_TYPE_WARNING,

View File

@ -150,10 +150,10 @@ fp_pub_compute_outcome (struct BRANDT_Auction *ad, size_t *buflen)
brandt_assert (ad && buflen);
*buflen = (sizeof (*head) +
ad->k * (sizeof (*gamma) +
sizeof (*delta) +
sizeof (*proof2)));
*buflen = (sizeof (*head)
+ ad->k * (sizeof (*gamma)
+ sizeof (*delta)
+ sizeof (*proof2)));
ret = GNUNET_new_array (*buflen, unsigned char);
head = (struct msg_head *) ret;
@ -412,7 +412,21 @@ fp_pub_determine_outcome (struct BRANDT_Auction *ad,
}
}
dlogi = GNUNET_CRYPTO_ecc_dlog (ad->dlogctx, sum_gamma);
{
struct GNUNET_CRYPTO_EccPoint ec_point = {0};
gcry_mpi_t q_y;
GNUNET_assert (0 == gcry_mpi_ec_set_point ("q", sum_gamma, ec_ctx));
q_y = gcry_mpi_ec_get_mpi ("q@eddsa", ec_ctx, 0);
GNUNET_assert (q_y);
GNUNET_CRYPTO_mpi_print_unsigned (ec_point.v,
sizeof(ec_point.v),
q_y);
dlogi = GNUNET_CRYPTO_ecc_dlog (ad->dlogctx,
&ec_point);
gcry_mpi_release (q_y);
}
brandt_assert (dlogi > 0);
/* all bidders participated with a multiplicative share */

View File

@ -28,7 +28,8 @@
#include "brandt.h"
enum rounds {
enum rounds
{
msg_init = 0,
msg_bid = 1,
msg_outcome = 2,
@ -37,14 +38,16 @@ enum rounds {
};
enum auction_type {
enum auction_type
{
auction_firstPrice = 0,
auction_mPlusFirstPrice = 1,
auction_last = 2
};
enum outcome_type {
enum outcome_type
{
outcome_private = 0,
outcome_public = 1,
outcome_last = 2
@ -61,7 +64,8 @@ GNUNET_NETWORK_STRUCT_BEGIN
* k-choice of 512 possible prices) byte message from the seller to all bidders
* (decrypt-round). For just two bidders this is already 256k bytes, but 16bit
* uint only can address 64k bytes. */
struct msg_head {
struct msg_head
{
uint32_t prot_version GNUNET_PACKED;
uint32_t msg_type GNUNET_PACKED;
};
@ -71,7 +75,8 @@ struct msg_head {
* This struct describes the parameters of an auction. All fields are stored in
* network byte order.
*/
struct BRANDT_DescrP {
struct BRANDT_DescrP
{
/** Starting time of the auction. Bidders have to join the auction via
* BRANDT_join until this time */
struct GNUNET_TIME_AbsoluteNBO time_start;
@ -97,7 +102,8 @@ struct BRANDT_DescrP {
GNUNET_NETWORK_STRUCT_END
struct BRANDT_Auction {
struct BRANDT_Auction
{
/** Starting time of the auction. Bidders have to join the auction via
* BRANDT_join until this time */
struct GNUNET_TIME_Absolute time_start;

View File

@ -200,9 +200,9 @@ mp_pub_compute_outcome (struct BRANDT_Auction *ad, size_t *buflen)
brandt_assert (ad && buflen);
*buflen = (sizeof (*head) + /* msg header */
ad->k * /* k * (gamma, delta, proof2) */
(sizeof (*gamma) + sizeof (*delta) + sizeof (*proof2)));
*buflen = (sizeof (*head) /* msg header */
+ ad->k /* k * (gamma, delta, proof2) */
* (sizeof (*gamma) + sizeof (*delta) + sizeof (*proof2)));
ret = GNUNET_new_array (*buflen, unsigned char);
head = (struct msg_head *) ret;
@ -486,7 +486,20 @@ mp_pub_determine_outcome (struct BRANDT_Auction *ad,
smc_sum (sum_phi, &ad->phi3[0][1][price], ad->n, 2 * ad->k);
gcry_mpi_ec_sub (sum_gamma, sum_gamma, sum_phi, ec_ctx);
dlogi = GNUNET_CRYPTO_ecc_dlog (ad->dlogctx, sum_gamma);
{
struct GNUNET_CRYPTO_EccPoint ec_point = {0};
gcry_mpi_t q_y;
GNUNET_assert (0 == gcry_mpi_ec_set_point ("q", sum_gamma, ec_ctx));
q_y = gcry_mpi_ec_get_mpi ("q@eddsa", ec_ctx, 0);
GNUNET_assert (q_y);
GNUNET_CRYPTO_mpi_print_unsigned (ec_point.v,
sizeof(ec_point.v),
q_y);
dlogi = GNUNET_CRYPTO_ecc_dlog (ad->dlogctx,
&ec_point);
gcry_mpi_release (q_y);
}
brandt_assert (dlogi > 0);
/* all bidders participated with a multiplicative share */

View File

@ -24,7 +24,7 @@
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_json_lib.h>
#include <taler/taler_amount_lib.h>
#include <taler/taler_util.h>
#include <jansson.h>
#include "brandt.h"
@ -68,7 +68,7 @@ struct transcript
struct GNUNET_CRYPTO_EccDlogContext *edc;
};
static struct transcript tr;
/* static struct transcript tr; */
static void
@ -96,8 +96,9 @@ print_result (struct transcript *tr,
for (size_t i = 0; i < tr->results_len; i++)
{
json_t *result = json_pack ("{s:i, s:s}",
json_t *result = json_pack ("{s:i, s:i, s:s}",
"bidder", tr->results[i].bidder,
"price_idx", tr->results[i].price_idx,
"price", tr->results[i].price);
GNUNET_assert (result);
@ -231,7 +232,7 @@ parse_json_stdin (struct transcript *tr)
{
json_error_t jerror;
json_t *jtr;
struct GNUNET_CRYPTO_EddsaSignature sig;
/* struct GNUNET_CRYPTO_EddsaSignature sig; */
jtr = json_loadfd (0,
JSON_REJECT_DUPLICATES,
@ -254,8 +255,8 @@ parse_json_stdin (struct transcript *tr)
char *perr;
unsigned int eline;
struct GNUNET_JSON_Specification au_spec[] = {
GNUNET_JSON_spec_bool ("public", &tr->public),
GNUNET_JSON_spec_uint16 ("type", &tr->m),
GNUNET_JSON_spec_bool ("outcome_public", &tr->public),
GNUNET_JSON_spec_uint16 ("auction_type", &tr->m),
GNUNET_JSON_spec_end ()
};

3
test.h
View File

@ -27,7 +27,8 @@
int tests_run = 0;
int ret = 0;
#define CHECK(cond, message) do { if (!(cond)) { fputs (message, stderr); fputc ( \
#define CHECK(cond, message) do { if (! (cond)) { fputs (message, stderr); \
fputc ( \
'\n', \
stderr); return 0; \
} } while (0)

View File

@ -1,5 +1,5 @@
/* This file is part of libbrandt.
* Copyright (C) 2016 GNUnet e.V.
* Copyright (C) 2016,2023-2024 GNUnet e.V.
*
* libbrandt is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
@ -18,6 +18,7 @@
* @file test_brandt.c
* @brief testing API functions.
* @author Markus Teich
* @author Özgür Kesim
*/
#include "platform.h"
@ -476,10 +477,7 @@ quit:
}
static uint16_t
tr_start (void *auction_closure)
{
void
static void
resend (void *x)
{
size_t i = (size_t) x;
@ -494,7 +492,11 @@ tr_start (void *auction_closure)
}
dprintf (2, "REPLAY start replay auction\n");
static uint16_t
tr_start (void *auction_closure)
{
dprintf (2, "REPLAY start resend auction\n");
for (size_t i = 0; i < 4 * tcase.n; i++)
GNUNET_SCHEDULER_add_now (&resend, (void *) i);
@ -540,8 +542,9 @@ print_transcript (uint32_t highestprice)
ad->time_start.abs_value_us / 1000LL),
"time_round", "d_us", json_integer (
ad->time_round.rel_value_us),
"type", ad->m,
"is_public", ad->outcome_public == 0 ? json_false () : json_true (),
"auction_type", ad->m,
"outcome_public", ad->outcome_public == 0 ?
json_false () : json_true (),
"prices", prices,
"payto_uri", "payto://some/iban",
"pubkey", GNUNET_CRYPTO_eddsa_public_key_to_string (
@ -824,7 +827,7 @@ test_auction (uint16_t n,
int
main (int argc, char *argv[])
main ()
{
int ret = 0;