pq-code-package / mlkem-native

High-assurance, high-performance ML-KEM implementation for mobile, pc, and server targets
https://pq-code-package.github.io/mlkem-native/dev/bench/
Apache License 2.0
11 stars 9 forks source link

Document C language requirements #50

Open hanno-becker opened 5 months ago

hanno-becker commented 5 months ago

Document which version of C and which implementation-defined behaviour of the C implementation we are assuming.

Notably, the correctness of montgomery_reduce() relies on implementation-defined behavior for conversions to signed integer types if the input values are not within the bounds of the target type.

mkannwischer commented 2 hours ago

The README now states C99. It is documented in https://github.com/pq-code-package/mlkem-native/blob/348c5a08c87059970de5f4c2360eec3131ee734e/mlkem/reduce.c#L23 that we rely on implementation-defined behavior for unsigned to signed conversion.

@hanno-becker Is that sufficient to close this issue? As literally all compilers implement this behavior, I suppose it is.