awslabs / bike-kem

Additional implementation of BIKE (Bit Flipping Key Encapsulation)
Apache License 2.0
45 stars 11 forks source link

how to compile it without avx2/avx512? #16

Closed Lucas-Wye closed 1 year ago

Lucas-Wye commented 1 year ago

Hi, I am trying to build it without avx2 and avx512, just for serial running. I dont know how to use the cmake to realize it, could you help me? Thanks.

ambiso commented 1 year ago

The implementation will automatically detect (at runtime) if the CPU supports AVX2 or AVX512 and use the best available option. If you want to disable that you'll need to modify the source code.

You could for example make these functions return 0: https://github.com/awslabs/bike-kem/blob/1d67131ee4812fc5ec5c032ee84271cde4ba9d2b/src/common/cpu_features.c#L17

I don't however see why you would want to do this.

Lucas-Wye commented 1 year ago

Thank you so much. Because in some platforms such as ARM, axv2/avx512 is not available. And due of the limitation of hareware resource, SIMD instructions may not be supported.

I want to know if this code repository support serial and constant-time implementation. Thanks again.

ambiso commented 1 year ago

If you're compiling for aarch64/ARM64, AVX2 and AVX512 will be disabled:

https://github.com/awslabs/bike-kem/blob/1d67131ee4812fc5ec5c032ee84271cde4ba9d2b/src/common/cpu_features.c#L73-L79

The implementation should still be constant-time with AVX2/512 turned off.

I don't believe aarch32/ARM32 is supported. See issue #10.

Lucas-Wye commented 1 year ago

Thanks. It works.

Is it because of the very low speed that there is not 32-bit implementations or any other reasons?

ambiso commented 1 year ago

A constant-time implementation would probably be very slow, as there's many issues you'd need to work around. See also https://www.bearssl.org/ctmul.html

Lucas-Wye commented 1 year ago

Thank you so much.