Toychain!
A toy blockchain in C
|
header for dataio.c More...
Go to the source code of this file.
Data Structures | |
struct | cellKey |
struct | cellProtected |
Typedefs | |
typedef struct cellKey | CellKey |
typedef struct cellProtected | CellProtected |
Functions | |
CellProtected * | create_cell_protected (Protected *pr) |
Create a cell protected object. More... | |
void | prepend_protected (CellProtected **list, Protected *pr) |
Prepend CellProtected to a list !!! takes ownership of pr. More... | |
CellProtected * | read_protected (const char *filename) |
read protected list from file. data format is lines in protected_to_str format each representing a protected More... | |
void | print_protected_list (CellProtected *list) |
prints the chained list of protected More... | |
CellProtected * | copy_protected_list (const CellProtected *o) |
copies the list of protected values. The copies order is inverted. More... | |
char * | list_protected_to_str (const CellProtected *list) |
converts list of protected to a string. More... | |
CellProtected * | str_to_list_protected (const char *str) |
converts string to a list of protected More... | |
void | free_cell_protected (CellProtected *c) |
correspond au delete_cell_protected dans le sujet More... | |
void | free_list_protected (CellProtected *c) |
frees the list of pretected More... | |
void | remove_fraudulent_declarations (CellProtected **list) |
removes fraudulent block from the chain. Fraudulent blocks are the ones that don't verify the signature. More... | |
void | generate_random_data (int nv, int nc, const char *dir) |
generates nv public and private keys and prints them in ./{dir}/keys.txt. Chooses nc couple of keys among them and print them in ./{dir}/candidates.txt. Then for all nv public keys, assign a random public key from the previous nc couples converted using key_to_str(), and its signed version using sign(). Prints the results in ./{dir}/declarations.txt. More... | |
CellKey * | create_cell_key (Key *key) |
Allocate and initialize a CellKey object. More... | |
CellKey * | insert_cell_key (CellKey *cellkey, Key *key) |
Insert a new element to cellkey (head insertion). More... | |
CellKey * | read_public_keys (char *file) |
Read the public keys of a file, return them in a CellKey structure. More... | |
void | print_list_keys (CellKey *LCK) |
print the keys from a list More... | |
void | free_cell_keys (CellKey *c) |
free a CellKey object(correspond to delete_cell_key in the subject). More... | |
void | free_list_keys (CellKey *cellkey) |
free a list of keys More... | |
CellProtected * | rand_list_protected (size_t len) |
generate random list of protected More... | |
CellProtected * | rand_list_protected_range (size_t len, char low, char hi) |
generate random list of protected with message characters in range [low, hi]. More... | |
CellProtected * | fuse_protected_lists (CellProtected *A, CellProtected *B) |
fusionner les liste A et B. Modifies A! More... | |
void | delete_dir_files (const char *path) |
void | create_dir_structure () |
header for dataio.c
typedef struct cellProtected CellProtected |
Strucutre for Protected (declarations) storing.
CellProtected * copy_protected_list | ( | const CellProtected * | o | ) |
copies the list of protected values. The copies order is inverted.
o |
Allocate and initialize a CellKey object.
key | key to assign |
CellProtected * create_cell_protected | ( | Protected * | pr | ) |
Create a cell protected object.
pr |
void free_cell_keys | ( | CellKey * | c | ) |
free a CellKey object(correspond to delete_cell_key in the subject).
c | Cellkey object to delete |
void free_cell_protected | ( | CellProtected * | c | ) |
correspond au delete_cell_protected dans le sujet
c |
void free_list_keys | ( | CellKey * | cellkey | ) |
free a list of keys
cellkey |
void free_list_protected | ( | CellProtected * | c | ) |
frees the list of pretected
c |
CellProtected * fuse_protected_lists | ( | CellProtected * | A, |
CellProtected * | B | ||
) |
fusionner les liste A et B. Modifies A!
A | |
B |
void generate_random_data | ( | int | nv, |
int | nc, | ||
const char * | dir | ||
) |
generates nv public and private keys and prints them in ./{dir}/keys.txt. Chooses nc couple of keys among them and print them in ./{dir}/candidates.txt. Then for all nv public keys, assign a random public key from the previous nc couples converted using key_to_str(), and its signed version using sign(). Prints the results in ./{dir}/declarations.txt.
nv | number of couple of keys(citizen) to be generated |
nc | number of candidates among the nv couples |
Insert a new element to cellkey (head insertion).
cellkey | list of key |
key | key to insert |
char * list_protected_to_str | ( | const CellProtected * | list | ) |
converts list of protected to a string.
list |
void prepend_protected | ( | CellProtected ** | list, |
Protected * | pr | ||
) |
Prepend CellProtected to a list !!! takes ownership of pr.
list | |
pr |
void print_list_keys | ( | CellKey * | LCK | ) |
print the keys from a list
LCK | list of keys |
void print_protected_list | ( | CellProtected * | list | ) |
prints the chained list of protected
list |
CellProtected * rand_list_protected | ( | size_t | len | ) |
generate random list of protected
len |
CellProtected * rand_list_protected_range | ( | size_t | len, |
char | low, | ||
char | hi | ||
) |
generate random list of protected with message characters in range [low, hi].
len | |
low | |
hi |
CellProtected * read_protected | ( | const char * | filename | ) |
read protected list from file. data format is lines in protected_to_str format each representing a protected
filename |
CellKey * read_public_keys | ( | char * | file | ) |
Read the public keys of a file, return them in a CellKey structure.
file | path to the file |
void remove_fraudulent_declarations | ( | CellProtected ** | list | ) |
removes fraudulent block from the chain. Fraudulent blocks are the ones that don't verify the signature.
list |
CellProtected * str_to_list_protected | ( | const char * | str | ) |
converts string to a list of protected
str |