aboutsummaryrefslogtreecommitdiffstats
path: root/test/bls_if_test.cpp
blob: 6c6e549ad46baf9f8bba02c8894226966ce45983 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <cybozu/test.hpp>
#include <bls_if.h>
#include <string.h>

CYBOZU_TEST_AUTO(bls_if)
{
    blsSecretKey *sec;
    blsPublicKey *pub;
    blsSign *sign;
//  blsId *id;
    const char *msg = "this is a pen";
    const size_t msgSize = strlen(msg);

    blsInit();
    sec = blsSecretKeyCreate();
    blsSecretKeyInit(sec);
    blsSecretKeyPut(sec);

    pub = blsPublicKeyCreate();
    blsSecretKeyGetPublicKey(sec, pub);
    blsPublicKeyPut(pub);

    sign = blsSignCreate();
    blsSecretKeySign(sec, sign, msg, msgSize);
    blsSignPut(sign);

    printf("verify %d\n", blsSignVerify(sign, pub, msg, msgSize));

    blsSignDestroy(sign);
    blsPublicKeyDestroy(pub);
    blsSecretKeyDestroy(sec);
}