|
34 | 34 | #define mld_rej_eta MLD_ADD_PARAM_SET(mld_rej_eta) |
35 | 35 | #define mld_poly_decompose_c MLD_ADD_PARAM_SET(mld_poly_decompose_c) |
36 | 36 | #define mld_poly_use_hint_c MLD_ADD_PARAM_SET(mld_poly_use_hint_c) |
| 37 | +#define mld_polyz_unpack_c MLD_ADD_PARAM_SET(mld_polyz_unpack_c) |
37 | 38 | /* End of parameter set namespacing */ |
38 | 39 |
|
39 | 40 |
|
@@ -776,33 +777,16 @@ void mld_polyz_pack(uint8_t r[MLDSA_POLYZ_PACKEDBYTES], const mld_poly *a) |
776 | 777 | #endif /* MLD_CONFIG_PARAMETER_SET != 44 */ |
777 | 778 | } |
778 | 779 |
|
779 | | -MLD_INTERNAL_API |
780 | | -void mld_polyz_unpack(mld_poly *r, const uint8_t a[MLDSA_POLYZ_PACKEDBYTES]) |
| 780 | +MLD_STATIC_TESTABLE void mld_polyz_unpack_c( |
| 781 | + mld_poly *r, const uint8_t a[MLDSA_POLYZ_PACKEDBYTES]) |
| 782 | +__contract__( |
| 783 | + requires(memory_no_alias(r, sizeof(mld_poly))) |
| 784 | + requires(memory_no_alias(a, MLDSA_POLYZ_PACKEDBYTES)) |
| 785 | + assigns(memory_slice(r, sizeof(mld_poly))) |
| 786 | + ensures(array_bound(r->coeffs, 0, MLDSA_N, -(MLDSA_GAMMA1 - 1), MLDSA_GAMMA1 + 1)) |
| 787 | +) |
781 | 788 | { |
782 | 789 | unsigned int i; |
783 | | -#if defined(MLD_USE_NATIVE_POLYZ_UNPACK_17) && MLD_CONFIG_PARAMETER_SET == 44 |
784 | | - /* TODO: proof */ |
785 | | - int ret; |
786 | | - ret = mld_polyz_unpack_17_native(r->coeffs, a); |
787 | | - if (ret == MLD_NATIVE_FUNC_SUCCESS) |
788 | | - { |
789 | | - mld_assert_bound(r->coeffs, MLDSA_N, -(MLDSA_GAMMA1 - 1), MLDSA_GAMMA1 + 1); |
790 | | - return; |
791 | | - } |
792 | | -#elif defined(MLD_USE_NATIVE_POLYZ_UNPACK_19) && \ |
793 | | - (MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87) |
794 | | - /* TODO: proof */ |
795 | | - int ret; |
796 | | - ret = mld_polyz_unpack_19_native(r->coeffs, a); |
797 | | - if (ret == MLD_NATIVE_FUNC_SUCCESS) |
798 | | - { |
799 | | - mld_assert_bound(r->coeffs, MLDSA_N, -(MLDSA_GAMMA1 - 1), MLDSA_GAMMA1 + 1); |
800 | | - return; |
801 | | - } |
802 | | -#endif /* !(MLD_USE_NATIVE_POLYZ_UNPACK_17 && MLD_CONFIG_PARAMETER_SET == 44) \ |
803 | | - && MLD_USE_NATIVE_POLYZ_UNPACK_19 && (MLD_CONFIG_PARAMETER_SET == 65 \ |
804 | | - || MLD_CONFIG_PARAMETER_SET == 87) */ |
805 | | - |
806 | 790 | #if MLD_CONFIG_PARAMETER_SET == 44 |
807 | 791 | for (i = 0; i < MLDSA_N / 4; ++i) |
808 | 792 | __loop__( |
@@ -858,6 +842,35 @@ void mld_polyz_unpack(mld_poly *r, const uint8_t a[MLDSA_POLYZ_PACKEDBYTES]) |
858 | 842 | mld_assert_bound(r->coeffs, MLDSA_N, -(MLDSA_GAMMA1 - 1), MLDSA_GAMMA1 + 1); |
859 | 843 | } |
860 | 844 |
|
| 845 | +MLD_INTERNAL_API |
| 846 | +void mld_polyz_unpack(mld_poly *r, const uint8_t a[MLDSA_POLYZ_PACKEDBYTES]) |
| 847 | +{ |
| 848 | +#if defined(MLD_USE_NATIVE_POLYZ_UNPACK_17) && MLD_CONFIG_PARAMETER_SET == 44 |
| 849 | + /* TODO: proof */ |
| 850 | + int ret; |
| 851 | + ret = mld_polyz_unpack_17_native(r->coeffs, a); |
| 852 | + if (ret == MLD_NATIVE_FUNC_SUCCESS) |
| 853 | + { |
| 854 | + mld_assert_bound(r->coeffs, MLDSA_N, -(MLDSA_GAMMA1 - 1), MLDSA_GAMMA1 + 1); |
| 855 | + return; |
| 856 | + } |
| 857 | +#elif defined(MLD_USE_NATIVE_POLYZ_UNPACK_19) && \ |
| 858 | + (MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87) |
| 859 | + /* TODO: proof */ |
| 860 | + int ret; |
| 861 | + ret = mld_polyz_unpack_19_native(r->coeffs, a); |
| 862 | + if (ret == MLD_NATIVE_FUNC_SUCCESS) |
| 863 | + { |
| 864 | + mld_assert_bound(r->coeffs, MLDSA_N, -(MLDSA_GAMMA1 - 1), MLDSA_GAMMA1 + 1); |
| 865 | + return; |
| 866 | + } |
| 867 | +#endif /* !(MLD_USE_NATIVE_POLYZ_UNPACK_17 && MLD_CONFIG_PARAMETER_SET == 44) \ |
| 868 | + && MLD_USE_NATIVE_POLYZ_UNPACK_19 && (MLD_CONFIG_PARAMETER_SET == 65 \ |
| 869 | + || MLD_CONFIG_PARAMETER_SET == 87) */ |
| 870 | + |
| 871 | + mld_polyz_unpack_c(r, a); |
| 872 | +} |
| 873 | + |
861 | 874 | MLD_INTERNAL_API |
862 | 875 | void mld_polyw1_pack(uint8_t r[MLDSA_POLYW1_PACKEDBYTES], const mld_poly *a) |
863 | 876 | { |
@@ -895,6 +908,7 @@ void mld_polyw1_pack(uint8_t r[MLDSA_POLYW1_PACKEDBYTES], const mld_poly *a) |
895 | 908 | #undef mld_rej_eta |
896 | 909 | #undef mld_poly_decompose_c |
897 | 910 | #undef mld_poly_use_hint_c |
| 911 | +#undef mld_polyz_unpack_c |
898 | 912 | #undef POLY_UNIFORM_ETA_NBLOCKS |
899 | 913 | #undef POLY_UNIFORM_ETA_NBLOCKS |
900 | 914 | #undef POLY_UNIFORM_GAMMA1_NBLOCKS |
0 commit comments