microsoft / PQCrypto-SIDH

SIDH Library is a fast and portable software library that implements state-of-the-art supersingular isogeny cryptographic schemes. The chosen parameters aim to provide security against attackers running a large-scale quantum computer, and security against classical algorithms.
MIT License
317 stars 101 forks source link

Question about SECRETKEY_B_BYTES #59

Open wangwwz opened 2 years ago

wangwwz commented 2 years ago

These macros are defined in P610_internal.h

#define SECRETKEY_A_BYTES       ((OALICE_BITS + 7) / 8)
#define SECRETKEY_B_BYTES       ((OBOB_BITS - 1 + 7) / 8)
#define FP2_ENCODED_BYTES       2*((NBITS_FIELD + 7) / 8)

#ifdef COMPRESS
    #define MASK2_BOB               0x07
    #define MASK3_BOB               0xFF
    #define ORDER_A_ENCODED_BYTES   SECRETKEY_A_BYTES
    #define ORDER_B_ENCODED_BYTES   (SECRETKEY_B_BYTES + 1)

I wonder why SECRETKEY_A_BYTES = (OALICE_BITS + 7) / 8 but SECRETKEY_B_BYTES = (OBOB_BITS + 6) / 8. What's more, ORDER_B_ENCODED_BYTES is defined as SECRETKEY_B_BYTES + 1 in P610_internal.h but in other Pxxx_internal.h ORDER_B_ENCODED_BYTES is just SECRETKEY_B_BYTES. According to my understanding, SECRETKEY_B_BYTES should be defined as (OBOB_BITS + 7) / 8 so that the ORDER_B_ENCODED_BYTES in P610_internal.h does not need to be especially defined.