libswarm-ng

C implementation of BMT hasher, Swarmhash and Single Owner Chunk for swarm
git clone git://git.defalsify.org/libswarm-ng.git
Info | Log | Files | Refs | Submodules | README

common.c (719B)


      1 #include <stdlib.h>
      2 #include <stddef.h>
      3 
      4 #include "secp256k1.h"
      5 #include "secp256k1_recovery.h"
      6 
      7 #include "swarm.h"
      8 #include "keystore.h"
      9 #include "common.h"
     10 
     11 int block_generate(struct block_generator *bg, char *buf, size_t l) {
     12 	int i;
     13 
     14 	for (i = 0; i < l; i++) {
     15 		*(buf+i) = bg->v;
     16 		bg->v++;
     17 		bg->v %= bg->m;
     18 	}
     19 
     20 	return i;
     21 }
     22 
     23 keystore_t* keystore_init(keystore_t *keystore) {
     24 	struct keystore_backend *backend;
     25 
     26 	keystore->keys = malloc(sizeof(keystore_key_t) * 32);
     27 	keystore->pk_sz = SWARM_PRIVATE_KEY_SIZE;
     28 	keystore->label_sz = SWARM_KEY_LABEL_SIZE;
     29 	keystore->digest_sz = SWARM_WORD_SIZE;
     30 	keystore->keys_count = 0;
     31 
     32 	return keystore;
     33 }
     34 
     35 void keystore_free(keystore_t *keystore) {
     36 	free(keystore->keys);	
     37 }
     38