Unverified Commit 1fbd4a0b authored by Sofia Celi's avatar Sofia Celi

Get rid of some p521 things

parent 914840e8
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#define COFACTOR 4 #define COFACTOR 4
static const int EDWARDS_D = -39081; static const int EDWARDS_D = -39081;
/* This is prob also not needed */
#define RISTRETTO_FACTOR DECAF_448_RISTRETTO_FACTOR #define RISTRETTO_FACTOR DECAF_448_RISTRETTO_FACTOR
extern const gf RISTRETTO_FACTOR; extern const gf RISTRETTO_FACTOR;
...@@ -146,15 +147,7 @@ API_NS(invert_elligator_nonuniform) ( ...@@ -146,15 +147,7 @@ API_NS(invert_elligator_nonuniform) (
gf_cond_neg(b, sgn_r0^gf_lobit(b)); gf_cond_neg(b, sgn_r0^gf_lobit(b));
/* Eliminate duplicate values for identity ... */ /* Eliminate duplicate values for identity ... */
succ &= ~(gf_eq(b,ZERO) & (sgn_r0 | sgn_s)); succ &= ~(gf_eq(b,ZERO) & (sgn_r0 | sgn_s));
// #if COFACTOR == 8 gf_serialize(recovered_hash,b,1);
// succ &= ~(is_identity & sgn_ed_T); /* NB: there are no preimages of rotated identity. */
// #endif
#if 448 == 8*SER_BYTES + 1 /* p521 */
gf_serialize(recovered_hash,b,0);
#else
gf_serialize(recovered_hash,b,1);
#endif
#if 0 #if 0
recovered_hash[SER_BYTES-1] ^= (hint>>3)<<0; recovered_hash[SER_BYTES-1] ^= (hint>>3)<<0;
#endif #endif
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
static const gf MODULUS = {FIELD_LITERAL( static const gf MODULUS = {FIELD_LITERAL(
0xffffffffffffff, 0xffffffffffffff, 0xffffffffffffff, 0xffffffffffffff, 0xfffffffffffffe, 0xffffffffffffff, 0xffffffffffffff, 0xffffffffffffff 0xffffffffffffff, 0xffffffffffffff, 0xffffffffffffff, 0xffffffffffffff, 0xfffffffffffffe, 0xffffffffffffff, 0xffffffffffffff, 0xffffffffffffff
)}; )};
#if P_MOD_8 == 5 #if P_MOD_8 == 5
const gf SQRT_MINUS_ONE = {FIELD_LITERAL( const gf SQRT_MINUS_ONE = {FIELD_LITERAL(
/* NOPE */ /* NOPE */
...@@ -29,7 +29,7 @@ void gf_serialize (uint8_t serial[SER_BYTES], const gf x, int with_hibit) { ...@@ -29,7 +29,7 @@ void gf_serialize (uint8_t serial[SER_BYTES], const gf x, int with_hibit) {
gf_copy(red, x); gf_copy(red, x);
gf_strong_reduce(red); gf_strong_reduce(red);
if (!with_hibit) { assert(gf_hibit(red) == 0); } if (!with_hibit) { assert(gf_hibit(red) == 0); }
unsigned int j=0, fill=0; unsigned int j=0, fill=0;
dword_t buffer = 0; dword_t buffer = 0;
UNROLL for (unsigned int i=0; i<(with_hibit ? X_SER_BYTES : SER_BYTES); i++) { UNROLL for (unsigned int i=0; i<(with_hibit ? X_SER_BYTES : SER_BYTES); i++) {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#define COFACTOR $(cofactor) #define COFACTOR $(cofactor)
static const int EDWARDS_D = $(d); static const int EDWARDS_D = $(d);
/* This is prob also not needed */
#define RISTRETTO_FACTOR $(C_NS)_RISTRETTO_FACTOR #define RISTRETTO_FACTOR $(C_NS)_RISTRETTO_FACTOR
extern const gf RISTRETTO_FACTOR; extern const gf RISTRETTO_FACTOR;
...@@ -135,15 +136,7 @@ API_NS(invert_elligator_nonuniform) ( ...@@ -135,15 +136,7 @@ API_NS(invert_elligator_nonuniform) (
gf_cond_neg(b, sgn_r0^gf_lobit(b)); gf_cond_neg(b, sgn_r0^gf_lobit(b));
/* Eliminate duplicate values for identity ... */ /* Eliminate duplicate values for identity ... */
succ &= ~(gf_eq(b,ZERO) & (sgn_r0 | sgn_s)); succ &= ~(gf_eq(b,ZERO) & (sgn_r0 | sgn_s));
// #if COFACTOR == 8 gf_serialize(recovered_hash,b,1);
// succ &= ~(is_identity & sgn_ed_T); /* NB: there are no preimages of rotated identity. */
// #endif
#if $(gf_bits) == 8*SER_BYTES + 1 /* p521 */
gf_serialize(recovered_hash,b,0);
#else
gf_serialize(recovered_hash,b,1);
#endif
#if $(gf_bits%8) #if $(gf_bits%8)
recovered_hash[SER_BYTES-1] ^= (hint>>3)<<$(gf_bits%8); recovered_hash[SER_BYTES-1] ^= (hint>>3)<<$(gf_bits%8);
#endif #endif
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
static const gf MODULUS = {FIELD_LITERAL( static const gf MODULUS = {FIELD_LITERAL(
$(ser(modulus,gf_lit_limb_bits)) $(ser(modulus,gf_lit_limb_bits))
)}; )};
#if P_MOD_8 == 5 #if P_MOD_8 == 5
const gf SQRT_MINUS_ONE = {FIELD_LITERAL( const gf SQRT_MINUS_ONE = {FIELD_LITERAL(
$(ser(msqrt(-1,modulus),gf_lit_limb_bits) if modulus % 4 == 1 else "/* NOPE */") $(ser(msqrt(-1,modulus),gf_lit_limb_bits) if modulus % 4 == 1 else "/* NOPE */")
...@@ -18,7 +18,7 @@ void gf_serialize (uint8_t serial[SER_BYTES], const gf x, int with_hibit) { ...@@ -18,7 +18,7 @@ void gf_serialize (uint8_t serial[SER_BYTES], const gf x, int with_hibit) {
gf_copy(red, x); gf_copy(red, x);
gf_strong_reduce(red); gf_strong_reduce(red);
if (!with_hibit) { assert(gf_hibit(red) == 0); } if (!with_hibit) { assert(gf_hibit(red) == 0); }
unsigned int j=0, fill=0; unsigned int j=0, fill=0;
dword_t buffer = 0; dword_t buffer = 0;
UNROLL for (unsigned int i=0; i<(with_hibit ? X_SER_BYTES : SER_BYTES); i++) { UNROLL for (unsigned int i=0; i<(with_hibit ? X_SER_BYTES : SER_BYTES); i++) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment