3333 * within a single compilation unit. */
3434#define mld_rej_eta MLD_ADD_PARAM_SET(mld_rej_eta)
3535#define mld_poly_decompose_c MLD_ADD_PARAM_SET(mld_poly_decompose_c)
36+ #define mld_poly_use_hint_c MLD_ADD_PARAM_SET(mld_poly_use_hint_c)
3637/* End of parameter set namespacing */
3738
3839
@@ -123,40 +124,21 @@ unsigned int mld_poly_make_hint(mld_poly *h, const mld_poly *a0,
123124 return s ;
124125}
125126
126- MLD_INTERNAL_API
127- void mld_poly_use_hint (mld_poly * b , const mld_poly * a , const mld_poly * h )
127+ MLD_STATIC_TESTABLE void mld_poly_use_hint_c (mld_poly * b , const mld_poly * a ,
128+ const mld_poly * h )
129+ __contract__ (
130+ requires (memory_no_alias (a , sizeof (mld_poly )))
131+ requires (memory_no_alias (b , sizeof (mld_poly )))
132+ requires (memory_no_alias (h , sizeof (mld_poly )))
133+ requires (array_bound (a - > coeffs , 0 , MLDSA_N , 0 , MLDSA_Q ))
134+ requires (array_bound (h - > coeffs , 0 , MLDSA_N , 0 , 2 ))
135+ assigns (memory_slice (b , sizeof (mld_poly )))
136+ ensures (array_bound (b - > coeffs , 0 , MLDSA_N , 0 , (MLDSA_Q - 1 )/(2 * MLDSA_GAMMA2 )))
137+ )
128138{
129139 unsigned int i ;
130140 mld_assert_bound (a -> coeffs , MLDSA_N , 0 , MLDSA_Q );
131141 mld_assert_bound (h -> coeffs , MLDSA_N , 0 , 2 );
132- #if defined(MLD_USE_NATIVE_POLY_USE_HINT_88 ) && MLD_CONFIG_PARAMETER_SET == 44
133- {
134- int ret ;
135- /* TODO: proof */
136- ret = mld_poly_use_hint_88_native (b -> coeffs , a -> coeffs , h -> coeffs );
137- if (ret == MLD_NATIVE_FUNC_SUCCESS )
138- {
139- mld_assert_bound (b -> coeffs , MLDSA_N , 0 ,
140- (MLDSA_Q - 1 ) / (2 * MLDSA_GAMMA2 ));
141- return ;
142- }
143- }
144- #elif defined(MLD_USE_NATIVE_POLY_USE_HINT_32 ) && \
145- (MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87 )
146- {
147- int ret ;
148- /* TODO: proof */
149- ret = mld_poly_use_hint_32_native (b -> coeffs , a -> coeffs , h -> coeffs );
150- if (ret == MLD_NATIVE_FUNC_SUCCESS )
151- {
152- mld_assert_bound (b -> coeffs , MLDSA_N , 0 ,
153- (MLDSA_Q - 1 ) / (2 * MLDSA_GAMMA2 ));
154- return ;
155- }
156- }
157- #endif /* !(MLD_USE_NATIVE_POLY_USE_HINT_88 && MLD_CONFIG_PARAMETER_SET == 44) \
158- && MLD_USE_NATIVE_POLY_USE_HINT_32 && (MLD_CONFIG_PARAMETER_SET == \
159- 65 || MLD_CONFIG_PARAMETER_SET == 87) */
160142
161143 for (i = 0 ; i < MLDSA_N ; ++ i )
162144 __loop__ (
@@ -169,6 +151,38 @@ void mld_poly_use_hint(mld_poly *b, const mld_poly *a, const mld_poly *h)
169151 mld_assert_bound (b -> coeffs , MLDSA_N , 0 , (MLDSA_Q - 1 ) / (2 * MLDSA_GAMMA2 ));
170152}
171153
154+ MLD_INTERNAL_API
155+ void mld_poly_use_hint (mld_poly * b , const mld_poly * a , const mld_poly * h )
156+ {
157+ #if defined(MLD_USE_NATIVE_POLY_USE_HINT_88 ) && MLD_CONFIG_PARAMETER_SET == 44
158+ int ret ;
159+ mld_assert_bound (a -> coeffs , MLDSA_N , 0 , MLDSA_Q );
160+ mld_assert_bound (h -> coeffs , MLDSA_N , 0 , 2 );
161+ /* TODO: proof */
162+ ret = mld_poly_use_hint_88_native (b -> coeffs , a -> coeffs , h -> coeffs );
163+ if (ret == MLD_NATIVE_FUNC_SUCCESS )
164+ {
165+ mld_assert_bound (b -> coeffs , MLDSA_N , 0 , (MLDSA_Q - 1 ) / (2 * MLDSA_GAMMA2 ));
166+ return ;
167+ }
168+ #elif defined(MLD_USE_NATIVE_POLY_USE_HINT_32 ) && \
169+ (MLD_CONFIG_PARAMETER_SET == 65 || MLD_CONFIG_PARAMETER_SET == 87 )
170+ int ret ;
171+ mld_assert_bound (a -> coeffs , MLDSA_N , 0 , MLDSA_Q );
172+ mld_assert_bound (h -> coeffs , MLDSA_N , 0 , 2 );
173+ /* TODO: proof */
174+ ret = mld_poly_use_hint_32_native (b -> coeffs , a -> coeffs , h -> coeffs );
175+ if (ret == MLD_NATIVE_FUNC_SUCCESS )
176+ {
177+ mld_assert_bound (b -> coeffs , MLDSA_N , 0 , (MLDSA_Q - 1 ) / (2 * MLDSA_GAMMA2 ));
178+ return ;
179+ }
180+ #endif /* !(MLD_USE_NATIVE_POLY_USE_HINT_88 && MLD_CONFIG_PARAMETER_SET == 44) \
181+ && MLD_USE_NATIVE_POLY_USE_HINT_32 && (MLD_CONFIG_PARAMETER_SET == \
182+ 65 || MLD_CONFIG_PARAMETER_SET == 87) */
183+ mld_poly_use_hint_c (b , a , h );
184+ }
185+
172186/*************************************************
173187 * Name: mld_rej_eta
174188 *
@@ -880,6 +894,7 @@ void mld_polyw1_pack(uint8_t r[MLDSA_POLYW1_PACKEDBYTES], const mld_poly *a)
880894 * Don't modify by hand -- this is auto-generated by scripts/autogen. */
881895#undef mld_rej_eta
882896#undef mld_poly_decompose_c
897+ #undef mld_poly_use_hint_c
883898#undef POLY_UNIFORM_ETA_NBLOCKS
884899#undef POLY_UNIFORM_ETA_NBLOCKS
885900#undef POLY_UNIFORM_GAMMA1_NBLOCKS
0 commit comments