Skip to content

Commit

Permalink
Add SQISign prime.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaranha committed May 6, 2024
1 parent cc73c65 commit c191fdb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/relic_fp.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ enum {
PRIME_25109,
/** Prime with high 2-adicity for curve Tweedledum. */
PRIME_H2ADC,
/** 254-bit prime modulus for SQISign at NIST level 1. */
SQI_254,
/** Curve25519 255-bit prime modulus. */
PRIME_25519,
/** NIST 256-bit fast reduction polynomial. */
Expand Down
2 changes: 1 addition & 1 deletion src/ep/relic_ep_param.c
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ int ep_param_level(void) {
case B12_P383:
case BN_P446:
case B12_P446:
case GMT8_544:
case GMT8_P544:
case SS_P1536:
return 128;
case B12_P455:
Expand Down
19 changes: 17 additions & 2 deletions src/fp/relic_fp_param.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@
/* Private definitions */
/*============================================================================*/

#if FP_PRIME == 255
#if FP_PRIME == 254
/**
* Prime with 254 bits for the SQISign signature scheme at NIST-I level.
*/
#define STR_P254 "29234DBD832FCAA9CF08FCD"

#elif FP_PRIME == 255
/**
* Primes with high 2-adicity for curves Tweedledum and Tweedledee.
*/
Expand Down Expand Up @@ -224,6 +230,14 @@ void fp_param_set(int param) {
bn_neg(t0, t0);
fp_prime_set_pairf(t0, EP_BN);
break;
case SQI_254:
bn_read_str(t0, STR_P254, strlen(STR_P254), 16);
bn_lsh(t0, t0, 37);
bn_sqr(t0, t0);
bn_dbl(t0, t0);
bn_sub_dig(t0, t0, 1);
fp_prime_set_dense(t0);
break;
#elif FP_PRIME == 255
case PRIME_25519:
/* p = 2^255 - 2^4 - 2^1 - 2^0. */
Expand Down Expand Up @@ -781,7 +795,8 @@ int fp_param_set_any_tower(void) {
#if FP_PRIME == 158
fp_param_set(BN_158);
#elif FP_PRIME == 254
fp_param_set(BN_254);
//fp_param_set(BN_254);
fp_param_set(SQI_254);
#elif FP_PRIME == 256
fp_param_set(BN_256);
#elif FP_PRIME == 315
Expand Down

0 comments on commit c191fdb

Please sign in to comment.