libhcs
Data Structures | Functions
hcs_shares.h File Reference

This is a structure which is designed to hold a number of shares. More...

#include <gmp.h>
Include dependency graph for hcs_shares.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  hcs_shares
 Stores a number of shares, with flags indicating if they are currently to be counted. More...
 

Functions

hcs_shareshcs_init_shares (unsigned long size)
 Initialise a hcs_shares and return a pointer to the newly created structure. More...
 
void hcs_set_share (hcs_shares *hs, mpz_t value, unsigned long index)
 Set a share value for the server given by id index. More...
 
void hcs_set_flag (hcs_shares *hs, unsigned long index)
 Set the flag on hs at index. More...
 
void hcs_clear_flag (hcs_shares *hs, unsigned long index)
 Clear the flag on hs at index. More...
 
void hcs_toggle_flag (hcs_shares *hs, unsigned long index)
 Toggle the flag on hs at index. More...
 
int hcs_tst_flag (hcs_shares *hs, unsigned long index)
 Test if the server given by index is to be counted. More...
 
void hcs_free_shares (hcs_shares *hs)
 Frees a hcs_shares and all associated memory. More...
 

Detailed Description

This is a structure which is designed to hold a number of shares.

It can be thought of as an array of mpz_t values, each with a corresponding bit which signals if the particular value of the share should be counted when combining shares. This is used by all threshold encryption schemes.

The rationale for this is that one may want to test a number of different combinations of shares, and setting a flag simplifies this process.

Function Documentation

hcs_shares* hcs_init_shares ( unsigned long  size)

Initialise a hcs_shares and return a pointer to the newly created structure.

Parameters
sizeThe number of shares this hcs_shares should store
Returns
A pointer to an initialised hcs_shares, NULL on allocation failure
void hcs_set_share ( hcs_shares hs,
mpz_t  value,
unsigned long  index 
)

Set a share value for the server given by id index.

index should be less than hs->size. It is up to the caller to enforce this. The owner of this hs should have a mapping of server id's to indices, as it is required by a number of other functions involved in threshold system.

Parameters
hsA pointer to an initialised hcs_shares
valueShare stored in an mpz_t variable
indexIndex of the server to store this share in
void hcs_set_flag ( hcs_shares hs,
unsigned long  index 
)

Set the flag on hs at index.

This share will then be counted by any share combinining functions that are subsequently called.

Parameters
hsA pointer to an initialised hcs_shares
indexIndex of the server to set
void hcs_clear_flag ( hcs_shares hs,
unsigned long  index 
)

Clear the flag on hs at index.

This share will NOT be counted by any share combining functions that are subsequently called.

Parameters
hsA pointer to an initialised hcs_shares
indexIndex of the server to clear
void hcs_toggle_flag ( hcs_shares hs,
unsigned long  index 
)

Toggle the flag on hs at index.

Parameters
hsA pointer to an initialised hcs_shares
indexIndex of the server to clear
int hcs_tst_flag ( hcs_shares hs,
unsigned long  index 
)

Test if the server given by index is to be counted.

Parameters
hsA pointer to an initialised hcs_shares
indexIndex of the server to clear
Returns
non-zero if flag is set, 0 otherwise
void hcs_free_shares ( hcs_shares hs)

Frees a hcs_shares and all associated memory.

Parameters
hsA pointer to an initialised hcs_shares