aboutsummaryrefslogblamecommitdiffstats
path: root/include/bls_if.h
blob: ac6849597e18406948fa26db1eb48d6f6761a1b4 (plain) (tree)
1
2
3
4
5
6
7
8
9








                                                   
                                            














                                         
 







                                                                  


                                     




                                              

                                                                                 







                                                                                          

                                                                                 



                                     

                                                                        





                                                                                            
#pragma once
/**
    @file
    @brief C interface of bls.hpp
    @author MITSUNARI Shigeo(@herumi)
    @license modified new BSD license
    http://opensource.org/licenses/BSD-3-Clause
*/

#include <stdint.h> // for uint64_t, uint8_t
#include <stdlib.h> // for size_t

#ifdef __cplusplus
extern "C" {
#endif

typedef struct blsSecretKey blsSecretKey;
typedef struct blsPublicKey blsPublicKey;
typedef struct blsSign blsSign;
typedef struct blsId blsId;

void blsInit(void);

blsId *blsIdCreate(void);
void blsIdDestroy(blsId *id);

// return 0 if success
int blsIdSetStr(blsId *id, const char *buf, size_t bufSize);

/*
    return written size
    otherwise 0
*/
size_t blsIdGetStr(const blsId *id, char *buf, size_t maxBufSize);
/*
    access p[0], p[1], p[2], p[3]
*/
void blsIdSet(blsId *id, const uint64_t *p);

blsSecretKey* blsSecretKeyCreate(void);
void blsSecretKeyDestroy(blsSecretKey *sec);
void blsSecretKeyPut(const blsSecretKey *sec);
int blsSecretKeySetStr(blsSecretKey *sec, const char *buf, size_t bufSize);
size_t blsSecretKeyGetStr(const blsSecretKey *sec, char *buf, size_t maxBufSize);

void blsSecretKeyInit(blsSecretKey *sec);
void blsSecretKeyGetPublicKey(const blsSecretKey *sec, blsPublicKey *pub);
void blsSecretKeySign(const blsSecretKey *sec, blsSign *sign, const char *m, size_t size);

blsPublicKey *blsPublicKeyCreate(void);
void blsPublicKeyDestroy(blsPublicKey *pub);
void blsPublicKeyPut(const blsPublicKey *pub);
int blsPublicKeySetStr(blsPublicKey *pub, const char *buf, size_t bufSize);
size_t blsPublicKeyGetStr(const blsPublicKey *pub, char *buf, size_t maxBufSize);

blsSign *blsSignCreate(void);
void blsSignDestroy(blsSign *sign);
void blsSignPut(const blsSign *sign);
int blsSignSetStr(blsSign *sign, const char *buf, size_t bufSize);
size_t blsSignGetStr(const blsSign *sign, char *buf, size_t maxBufSize);

int blsSignVerify(const blsSign *sign, const blsPublicKey *pub, const char *m, size_t size);

#ifdef __cplusplus
}
#endif