Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kyber Ref dead code ? #74

Open
yogappu opened this issue Apr 18, 2024 · 3 comments
Open

Kyber Ref dead code ? #74

yogappu opened this issue Apr 18, 2024 · 3 comments

Comments

@yogappu
Copy link

yogappu commented Apr 18, 2024

Hello all,

I was analyzing Kyber768 ref code and found a possible deadcode.

Can this line be reached : https://github.com/pq-crystals/kyber/blob/main/ref/indcpa.c#L185 ?

GEN_MATRIX_NBLOCKS is 3 & XOF_BLOCKBYTES is168 (also multiple of 3) that makes off ( @ https://github.com/pq-crystals/kyber/blob/main/ref/indcpa.c#L183) always 0.

---EDIT---
The same is applicable for Dilithium as well : https://github.com/pq-crystals/dilithium/blob/master/ref/poly.c#L360

Thanks.

@yogappu yogappu changed the title Kyber Ref Implementation Doubts - dead code ? Kyber Ref dead code ? Apr 18, 2024
@bhess
Copy link
Contributor

bhess commented Apr 22, 2024

I think you are right that this is dead code in the 'standard' branch. Tagging @cryptojedi @gregorseiler.

In the Kyber 'main' branch there is the "90s" version where XOF_BLOCKBYTES is 64 and GEN_MATRIX_NBLOCKS is 8.

@cryptojedi
Copy link
Contributor

I agree that it's dead code, because the block size of SHAKE-128 is a multiple of 3.

I'm not sure how I feel about removing it, though. If we do, we should have a #if around that function
to ensure that it's only ever used with symmetric primitives that have a block sizes that are a multiple of 3
and have that checked at compile time. Also, add a comment then stating where this is used.

@iambatmanandjoker
Copy link

@cryptojedi is there a fix planned for this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants