Skip to content

Commit

Permalink
fix inlining of Kyber reencryption
Browse files Browse the repository at this point in the history
  • Loading branch information
mkannwischer committed Apr 3, 2024
1 parent 5d0fe86 commit 6ab1a04
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
5 changes: 2 additions & 3 deletions crypto_kem/kyber512/m4fspeed/poly.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ int cmp_poly_compress(const unsigned char *r, poly *a) {
int i, j, k = 0;

#if (KYBER_POLYCOMPRESSEDBYTES == 128)
for (i = 0; i < KYBER_N; i += 8) {
for(i=0;i<KYBER_N/8;i++) {
for(j=0;j<8;j++) {
// map to positive standard representatives
u = a->coeffs[8*i+j];
Expand All @@ -256,8 +256,7 @@ int cmp_poly_compress(const unsigned char *r, poly *a) {
k += 4;
}
#elif (KYBER_POLYCOMPRESSEDBYTES == 160)
for(i=0;i<KYBER_N;i+=8)
{
for(i=0;i<KYBER_N/8;i++) {
for(j=0;j<8;j++) {
// map to positive standard representatives
u = a->coeffs[8*i+j];
Expand Down
5 changes: 2 additions & 3 deletions crypto_kem/kyber512/m4fstack/poly.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ int cmp_poly_compress(const unsigned char *r, poly *a) {
int i, j, k = 0;

#if (KYBER_POLYCOMPRESSEDBYTES == 128)
for (i = 0; i < KYBER_N; i += 8) {
for(i=0;i<KYBER_N/8;i++) {
for(j=0;j<8;j++) {
// map to positive standard representatives
u = a->coeffs[8*i+j];
Expand All @@ -256,8 +256,7 @@ int cmp_poly_compress(const unsigned char *r, poly *a) {
k += 4;
}
#elif (KYBER_POLYCOMPRESSEDBYTES == 160)
for(i=0;i<KYBER_N;i+=8)
{
for(i=0;i<KYBER_N/8;i++) {
for(j=0;j<8;j++) {
// map to positive standard representatives
u = a->coeffs[8*i+j];
Expand Down
5 changes: 1 addition & 4 deletions crypto_kem/kyber768/m4fspeed/kem.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ int crypto_kem_dec(unsigned char *ss, const unsigned char *ct, const unsigned ch
uint8_t buf[2 * KYBER_SYMBYTES];
/* Will contain key, coins */
uint8_t kr[2 * KYBER_SYMBYTES];
uint8_t cmp[KYBER_CIPHERTEXTBYTES + KYBER_SYMBYTES];
const uint8_t *pk = sk + KYBER_INDCPA_SECRETKEYBYTES;

indcpa_dec(buf, ct, sk);
Expand All @@ -148,9 +147,7 @@ int crypto_kem_dec(unsigned char *ss, const unsigned char *ct, const unsigned ch
hash_g(kr, buf, 2 * KYBER_SYMBYTES);

/* coins are in kr+KYBER_SYMBYTES */
indcpa_enc(cmp, buf, pk, kr + KYBER_SYMBYTES);

fail = verify(ct, cmp, KYBER_CIPHERTEXTBYTES);
fail = indcpa_enc_cmp(ct, buf, pk, kr + KYBER_SYMBYTES);

/* Compute rejection key */
rkprf(ss, sk + KYBER_SECRETKEYBYTES - KYBER_SYMBYTES, ct);
Expand Down
5 changes: 2 additions & 3 deletions crypto_kem/kyber768/m4fspeed/poly.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ int cmp_poly_compress(const unsigned char *r, poly *a) {
int i, j, k = 0;

#if (KYBER_POLYCOMPRESSEDBYTES == 128)
for (i = 0; i < KYBER_N; i += 8) {
for(i=0;i<KYBER_N/8;i++) {
for(j=0;j<8;j++) {
// map to positive standard representatives
u = a->coeffs[8*i+j];
Expand All @@ -256,8 +256,7 @@ int cmp_poly_compress(const unsigned char *r, poly *a) {
k += 4;
}
#elif (KYBER_POLYCOMPRESSEDBYTES == 160)
for(i=0;i<KYBER_N;i+=8)
{
for(i=0;i<KYBER_N/8;i++) {
for(j=0;j<8;j++) {
// map to positive standard representatives
u = a->coeffs[8*i+j];
Expand Down
5 changes: 2 additions & 3 deletions crypto_kem/kyber768/m4fstack/poly.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ int cmp_poly_compress(const unsigned char *r, poly *a) {
int i, j, k = 0;

#if (KYBER_POLYCOMPRESSEDBYTES == 128)
for (i = 0; i < KYBER_N; i += 8) {
for(i=0;i<KYBER_N/8;i++) {
for(j=0;j<8;j++) {
// map to positive standard representatives
u = a->coeffs[8*i+j];
Expand All @@ -256,8 +256,7 @@ int cmp_poly_compress(const unsigned char *r, poly *a) {
k += 4;
}
#elif (KYBER_POLYCOMPRESSEDBYTES == 160)
for(i=0;i<KYBER_N;i+=8)
{
for(i=0;i<KYBER_N/8;i++) {
for(j=0;j<8;j++) {
// map to positive standard representatives
u = a->coeffs[8*i+j];
Expand Down

0 comments on commit 6ab1a04

Please sign in to comment.