Dilithium key pair
This commit is contained in:
@@ -37,6 +37,7 @@ std::string MYCCLIBNAME = (char *)"rogue";
|
||||
|
||||
#define EVAL_SUDOKU 17
|
||||
#define EVAL_MUSIG 18
|
||||
#define EVAL_DILITHIUM 19
|
||||
std::string MYCCLIBNAME = (char *)"sudoku";
|
||||
#endif
|
||||
|
||||
@@ -80,6 +81,11 @@ CClib_methods[] =
|
||||
{ (char *)"musig", (char *)"verify", (char *)"msg sig pubkey", 3, 3, 'V', EVAL_MUSIG },
|
||||
{ (char *)"musig", (char *)"send", (char *)"combined_pk amount", 2, 2, 'x', EVAL_MUSIG },
|
||||
{ (char *)"musig", (char *)"spend", (char *)"sendtxid sig destpubkey", 3, 3, 'y', EVAL_MUSIG },
|
||||
{ (char *)"dilithium", (char *)"keypair", (char *)"<no args>", 0, 0, 'K', EVAL_DILITHIUM },
|
||||
{ (char *)"dilithium", (char *)"sign", (char *)"msg privkey", 2, 2, 'S', EVAL_DILITHIUM },
|
||||
{ (char *)"dilithium", (char *)"verify", (char *)"msg sig pubtxid", 3, 3, 'V', EVAL_DILITHIUM },
|
||||
{ (char *)"dilithium", (char *)"send", (char *)"pubtxid amount", 2, 2, 'x', EVAL_DILITHIUM },
|
||||
{ (char *)"dilithium", (char *)"spend", (char *)"sendtxid sig destpubkey", 3, 3, 'y', EVAL_DILITHIUM },
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -119,6 +125,13 @@ UniValue musig_partialsig(uint64_t txfee,struct CCcontract_info *cp,cJSON *param
|
||||
UniValue musig_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue musig_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue musig_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
|
||||
UniValue dilithium_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue dilithium_sign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
UniValue dilithium_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params);
|
||||
|
||||
#endif
|
||||
|
||||
cJSON *cclib_reparse(int32_t *nump,char *jsonstr) // assumes origparams will be freed by caller
|
||||
@@ -243,6 +256,26 @@ UniValue CClib_method(struct CCcontract_info *cp,char *method,char *jsonstr)
|
||||
return(result);
|
||||
}
|
||||
}
|
||||
else if ( cp->evalcode == EVAL_DILITHIUM )
|
||||
{
|
||||
if ( strcmp(method,"send") == 0 )
|
||||
return(dilithium_send(txfee,cp,params));
|
||||
else if ( strcmp(method,"spend") == 0 )
|
||||
return(dilithium_spend(txfee,cp,params));
|
||||
else if ( strcmp(method,"keypair") == 0 )
|
||||
return(dilithium_keypair(txfee,cp,params));
|
||||
else if ( strcmp(method,"sign") == 0 )
|
||||
return(dilithium_sign(txfee,cp,params));
|
||||
else if ( strcmp(method,"verify") == 0 )
|
||||
return(dilithium_verify(txfee,cp,params));
|
||||
else
|
||||
{
|
||||
result.push_back(Pair("result","error"));
|
||||
result.push_back(Pair("error","invalid dilithium method"));
|
||||
result.push_back(Pair("method",method));
|
||||
return(result);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
|
||||
@@ -2835,3 +2835,42 @@ int32_t main(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
UniValue dilithium_keypair(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ); uint8_t pk[CRYPTO_PUBLICKEYBYTES],sk[CRYPTO_SECRETKEYBYTES]; char str[CRYPTO_SECRETKEYBYTES*2+1]; int32_t i;
|
||||
dilithium_keypair(pk,sk);
|
||||
for (i=0; i<sizeof(pk); i++)
|
||||
sprintf(&str[i<<1],"%02x",pk[i]);
|
||||
str[i<<1] = 0;
|
||||
result.push_back(Pair("pubkey",str));
|
||||
for (i=0; i<sizeof(sk); i++)
|
||||
sprintf(&str[i<<1],"%02x",sk[i]);
|
||||
str[i<<1] = 0;
|
||||
result.push_back(Pair("privkey",str));
|
||||
result.push_back(Pair("result","success"));
|
||||
return(result);
|
||||
}
|
||||
|
||||
UniValue dilithium_sign(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
return(result);
|
||||
}
|
||||
|
||||
UniValue dilithium_verify(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
return(result);
|
||||
}
|
||||
|
||||
UniValue dilithium_send(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
return(result);
|
||||
}
|
||||
|
||||
UniValue dilithium_spend(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ);
|
||||
return(result);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
#ifndef CPUCYCLES_H
|
||||
#define CPUCYCLES_H
|
||||
|
||||
@@ -11,7 +12,7 @@
|
||||
#define DBENCH_STOP(t)
|
||||
#endif
|
||||
|
||||
#ifdef USE_RDPMC /* Needs echo 2 > /sys/devices/cpu/rdpmc */
|
||||
#ifdef USE_RDPMC // Needs echo 2 > /sys/devices/cpu/rdpmc
|
||||
#ifdef SERIALIZE_RDC
|
||||
|
||||
static inline uint64_t cpucycles_start(void) {
|
||||
@@ -103,7 +104,7 @@ static inline uint64_t cpucycles_stop(void) {
|
||||
|
||||
int64_t cpucycles_overhead(void);
|
||||
|
||||
#endif
|
||||
#endif*/
|
||||
|
||||
#ifndef FIPS202_H
|
||||
#define FIPS202_H
|
||||
@@ -144,7 +145,7 @@ void shake256(uint8_t *output,
|
||||
#define PARAMS_H
|
||||
|
||||
#ifndef MODE
|
||||
#define MODE 2
|
||||
#define MODE 3
|
||||
#endif
|
||||
|
||||
#define SEEDBYTES 32U
|
||||
@@ -410,7 +411,7 @@ int crypto_sign_open(uint8_t *m, int32_t *mlen,
|
||||
#define API_H
|
||||
|
||||
#ifndef MODE
|
||||
#define MODE 2
|
||||
#define MODE 3
|
||||
#endif
|
||||
|
||||
#if MODE == 0
|
||||
|
||||
Reference in New Issue
Block a user