1use super::*;
17
18impl<E: Environment, I: IntegerType> Cast<Address<E>> for Integer<E, I> {
19 #[inline]
27 fn cast(&self) -> Address<E> {
28 let field: Field<E> = self.cast();
29 field.cast()
30 }
31}
32
33impl<E: Environment, I: IntegerType> Cast<Boolean<E>> for Integer<E, I> {
34 #[inline]
38 fn cast(&self) -> Boolean<E> {
39 let is_one = self.is_one();
40 E::assert(self.is_zero().bitor(&is_one));
41 is_one
42 }
43}
44
45impl<E: Environment, I: IntegerType> Cast<Field<E>> for Integer<E, I> {
46 #[inline]
48 fn cast(&self) -> Field<E> {
49 self.to_field()
50 }
51}
52
53impl<E: Environment, I: IntegerType> Cast<Group<E>> for Integer<E, I> {
54 #[inline]
61 fn cast(&self) -> Group<E> {
62 let field: Field<E> = self.cast();
63 field.cast()
64 }
65}
66
67impl<E: Environment, I0: IntegerType, I1: IntegerType> Cast<Integer<E, I1>> for Integer<E, I0> {
68 #[inline]
70 fn cast(&self) -> Integer<E, I1> {
71 let mut bits_le = self.to_bits_le();
72 match (I0::is_signed(), I1::is_signed()) {
73 (false, false) => Integer::<E, I1>::from_bits_le(&bits_le),
75 (false, true) => match I0::BITS < I1::BITS {
77 true => Integer::<E, I1>::from_bits_le(&bits_le),
79 false => {
82 Boolean::assert_bits_are_zero(&bits_le[(I1::BITS.saturating_sub(1) as usize)..]);
83 Integer::<E, I1>::from_bits_le(&bits_le[..(I1::BITS as usize)])
84 }
85 },
86 (true, false) => match I0::BITS <= I1::BITS {
88 true => {
91 E::assert(!&bits_le[I0::BITS.saturating_sub(1) as usize]);
92 Integer::<E, I1>::from_bits_le(&bits_le)
93 }
94 false => {
97 Boolean::assert_bits_are_zero(&bits_le[(I1::BITS as usize)..]);
98 Integer::<E, I1>::from_bits_le(&bits_le[..(I1::BITS as usize)])
99 }
100 },
101 (true, true) => match I0::BITS <= I1::BITS {
103 true => {
106 bits_le.resize(I1::BITS as usize, self.msb().clone());
107 Integer::<E, I1>::from_bits_le(&bits_le)
108 }
109 false => {
112 let msb = match bits_le.pop() {
114 Some(bit) => bit,
115 None => E::halt("Failed to extract the MSB from the integer."),
116 };
117 let upper_bits = bits_le.iter().skip(I1::BITS.saturating_sub(1) as usize);
119 for bit in upper_bits {
120 E::assert_eq(&msb, bit);
121 }
122 let mut lower_bits: Vec<_> =
124 bits_le.into_iter().take(I1::BITS.saturating_sub(1) as usize).collect();
125 lower_bits.push(msb);
126 Integer::<E, I1>::from_bits_le(&lower_bits)
127 }
128 },
129 }
130 }
131}
132
133impl<E: Environment, I: IntegerType> Cast<Scalar<E>> for Integer<E, I> {
134 #[inline]
136 fn cast(&self) -> Scalar<E> {
137 let bits_le = self.to_bits_le();
138 Scalar::<E>::from_bits_le(&bits_le)
139 }
140}
141
142#[cfg(test)]
143mod tests {
144 use super::*;
145 use console::Cast as _;
146 use console_root::{
147 network::MainnetV0,
148 prelude::{One, TestRng, Uniform, Zero},
149 };
150 use snarkvm_circuit_types::environment::{Circuit, Eject, Inject, Mode, UpdatableCount, count_is, count_less_than};
151
152 use std::fmt::Debug;
153
154 const ITERATIONS: usize = 1000;
155
156 fn sample_values<I: IntegerType>(
157 i: usize,
158 mode: Mode,
159 rng: &mut TestRng,
160 ) -> (console_root::types::integers::Integer<MainnetV0, I>, Integer<Circuit, I>) {
161 let console_value = match i {
162 0 => console_root::types::integers::Integer::<MainnetV0, I>::zero(),
163 1 => console_root::types::integers::Integer::<MainnetV0, I>::one(),
164 2 => console_root::types::integers::Integer::<MainnetV0, I>::new(I::MAX),
165 3 => console_root::types::integers::Integer::<MainnetV0, I>::new(I::MIN),
166 4 if I::is_signed() => -console_root::types::integers::Integer::<MainnetV0, I>::one(),
167 _ => Uniform::rand(rng),
168 };
169 let circuit_value = Integer::<Circuit, I>::new(mode, console_value);
170 (console_value, circuit_value)
171 }
172
173 mod i8 {
174 use super::*;
175
176 fn sample_values(i: usize, mode: Mode, rng: &mut TestRng) -> (console_root::types::I8<MainnetV0>, I8<Circuit>) {
177 super::sample_values(i, mode, rng)
178 }
179
180 impl_check_cast!(cast, I8<Circuit>, console_root::types::I8<MainnetV0>);
181
182 #[test]
183 fn test_i8_to_address() {
184 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
185 Mode::Constant,
186 count_less_than!(11, 0, 0, 0),
187 );
188 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
189 Mode::Public,
190 count_is!(4, 0, 13, 13),
191 );
192 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
193 Mode::Private,
194 count_is!(4, 0, 13, 13),
195 );
196 }
197
198 #[test]
199 fn test_i8_to_boolean() {
200 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
201 Mode::Constant,
202 count_is!(16, 0, 0, 0),
203 );
204 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
205 Mode::Public,
206 count_is!(16, 0, 5, 6),
207 );
208 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
209 Mode::Private,
210 count_is!(16, 0, 5, 6),
211 );
212 }
213
214 #[test]
215 fn test_i8_to_field() {
216 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
217 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
218 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
219 }
220
221 #[test]
222 fn test_i8_to_group() {
223 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(
224 Mode::Constant,
225 count_less_than!(11, 0, 0, 0),
226 );
227 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Public, count_is!(4, 0, 13, 13));
228 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Private, count_is!(4, 0, 13, 13));
229 }
230
231 #[test]
232 fn test_i8_to_i8() {
233 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
234 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
235 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
236 }
237
238 #[test]
239 fn test_i8_to_i16() {
240 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
241 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
242 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
243 }
244
245 #[test]
246 fn test_i8_to_i32() {
247 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
248 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
249 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
250 }
251
252 #[test]
253 fn test_i8_to_i64() {
254 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
255 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
256 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
257 }
258
259 #[test]
260 fn test_i8_to_i128() {
261 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
262 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
263 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
264 }
265
266 #[test]
267 fn test_i8_to_scalar() {
268 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(
269 Mode::Constant,
270 count_is!(0, 0, 0, 0),
271 );
272 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
273 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
274 }
275
276 #[test]
277 fn test_i8_to_u8() {
278 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
279 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
280 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
281 }
282
283 #[test]
284 fn test_i8_to_u16() {
285 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
286 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
287 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
288 }
289
290 #[test]
291 fn test_i8_to_u32() {
292 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
293 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
294 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
295 }
296
297 #[test]
298 fn test_i8_to_u64() {
299 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
300 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
301 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
302 }
303
304 #[test]
305 fn test_i8_to_u128() {
306 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
307 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
308 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
309 }
310 }
311
312 mod i16 {
313 use super::*;
314
315 fn sample_values(
316 i: usize,
317 mode: Mode,
318 rng: &mut TestRng,
319 ) -> (console_root::types::I16<MainnetV0>, I16<Circuit>) {
320 super::sample_values(i, mode, rng)
321 }
322
323 impl_check_cast!(cast, I16<Circuit>, console_root::types::I16<MainnetV0>);
324
325 #[test]
326 fn test_i16_to_address() {
327 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
328 Mode::Constant,
329 count_less_than!(11, 0, 0, 0),
330 );
331 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
332 Mode::Public,
333 count_is!(4, 0, 13, 13),
334 );
335 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
336 Mode::Private,
337 count_is!(4, 0, 13, 13),
338 );
339 }
340
341 #[test]
342 fn test_i16_to_boolean() {
343 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
344 Mode::Constant,
345 count_is!(32, 0, 0, 0),
346 );
347 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
348 Mode::Public,
349 count_is!(32, 0, 5, 6),
350 );
351 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
352 Mode::Private,
353 count_is!(32, 0, 5, 6),
354 );
355 }
356
357 #[test]
358 fn test_i16_to_field() {
359 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
360 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
361 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
362 }
363
364 #[test]
365 fn test_i16_to_group() {
366 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(
367 Mode::Constant,
368 count_less_than!(11, 0, 0, 0),
369 );
370 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Public, count_is!(4, 0, 13, 13));
371 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Private, count_is!(4, 0, 13, 13));
372 }
373
374 #[test]
375 fn test_i16_to_i8() {
376 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
377 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 8));
378 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 8));
379 }
380
381 #[test]
382 fn test_i16_to_i16() {
383 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
384 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
385 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
386 }
387
388 #[test]
389 fn test_i16_to_i32() {
390 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
391 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
392 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
393 }
394
395 #[test]
396 fn test_i16_to_i64() {
397 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
398 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
399 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
400 }
401
402 #[test]
403 fn test_i16_to_i128() {
404 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
405 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
406 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
407 }
408
409 #[test]
410 fn test_i16_to_scalar() {
411 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(
412 Mode::Constant,
413 count_is!(0, 0, 0, 0),
414 );
415 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
416 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
417 }
418
419 #[test]
420 fn test_i16_to_u8() {
421 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
422 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
423 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
424 }
425
426 #[test]
427 fn test_i16_to_u16() {
428 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
429 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
430 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
431 }
432
433 #[test]
434 fn test_i16_to_u32() {
435 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
436 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
437 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
438 }
439
440 #[test]
441 fn test_i16_to_u64() {
442 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
443 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
444 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
445 }
446
447 #[test]
448 fn test_i16_to_u128() {
449 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
450 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
451 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
452 }
453 }
454
455 mod i32 {
456 use super::*;
457
458 fn sample_values(
459 i: usize,
460 mode: Mode,
461 rng: &mut TestRng,
462 ) -> (console_root::types::I32<MainnetV0>, I32<Circuit>) {
463 super::sample_values(i, mode, rng)
464 }
465
466 impl_check_cast!(cast, I32<Circuit>, console_root::types::I32<MainnetV0>);
467
468 #[test]
469 fn test_i32_to_address() {
470 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
471 Mode::Constant,
472 count_less_than!(11, 0, 0, 0),
473 );
474 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
475 Mode::Public,
476 count_is!(4, 0, 13, 13),
477 );
478 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
479 Mode::Private,
480 count_is!(4, 0, 13, 13),
481 );
482 }
483
484 #[test]
485 fn test_i32_to_boolean() {
486 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
487 Mode::Constant,
488 count_is!(64, 0, 0, 0),
489 );
490 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
491 Mode::Public,
492 count_is!(64, 0, 5, 6),
493 );
494 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
495 Mode::Private,
496 count_is!(64, 0, 5, 6),
497 );
498 }
499
500 #[test]
501 fn test_i32_to_field() {
502 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
503 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
504 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
505 }
506
507 #[test]
508 fn test_i32_to_group() {
509 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(
510 Mode::Constant,
511 count_less_than!(11, 0, 0, 0),
512 );
513 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Public, count_is!(4, 0, 13, 13));
514 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Private, count_is!(4, 0, 13, 13));
515 }
516
517 #[test]
518 fn test_i32_to_i8() {
519 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
520 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 24));
521 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 24));
522 }
523
524 #[test]
525 fn test_i32_to_i16() {
526 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
527 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 16));
528 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 16));
529 }
530
531 #[test]
532 fn test_i32_to_i32() {
533 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
534 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
535 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
536 }
537
538 #[test]
539 fn test_i32_to_i64() {
540 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
541 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
542 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
543 }
544
545 #[test]
546 fn test_i32_to_i128() {
547 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
548 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
549 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
550 }
551
552 #[test]
553 fn test_i32_to_scalar() {
554 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(
555 Mode::Constant,
556 count_is!(0, 0, 0, 0),
557 );
558 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
559 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
560 }
561
562 #[test]
563 fn test_i32_to_u8() {
564 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
565 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
566 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
567 }
568
569 #[test]
570 fn test_i32_to_u16() {
571 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
572 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
573 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
574 }
575
576 #[test]
577 fn test_i32_to_u32() {
578 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
579 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
580 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
581 }
582
583 #[test]
584 fn test_i32_to_u64() {
585 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
586 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
587 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
588 }
589
590 #[test]
591 fn test_i32_to_u128() {
592 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
593 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
594 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
595 }
596 }
597
598 mod i64 {
599 use super::*;
600
601 fn sample_values(
602 i: usize,
603 mode: Mode,
604 rng: &mut TestRng,
605 ) -> (console_root::types::I64<MainnetV0>, I64<Circuit>) {
606 super::sample_values(i, mode, rng)
607 }
608
609 impl_check_cast!(cast, I64<Circuit>, console_root::types::I64<MainnetV0>);
610
611 #[test]
612 fn test_i64_to_address() {
613 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
614 Mode::Constant,
615 count_less_than!(11, 0, 0, 0),
616 );
617 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
618 Mode::Public,
619 count_is!(4, 0, 13, 13),
620 );
621 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
622 Mode::Private,
623 count_is!(4, 0, 13, 13),
624 );
625 }
626
627 #[test]
628 fn test_i64_to_boolean() {
629 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
630 Mode::Constant,
631 count_is!(128, 0, 0, 0),
632 );
633 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
634 Mode::Public,
635 count_is!(128, 0, 5, 6),
636 );
637 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
638 Mode::Private,
639 count_is!(128, 0, 5, 6),
640 );
641 }
642
643 #[test]
644 fn test_i64_to_field() {
645 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
646 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
647 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
648 }
649
650 #[test]
651 fn test_i64_to_group() {
652 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(
653 Mode::Constant,
654 count_less_than!(11, 0, 0, 0),
655 );
656 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Public, count_is!(4, 0, 13, 13));
657 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Private, count_is!(4, 0, 13, 13));
658 }
659
660 #[test]
661 fn test_i64_to_i8() {
662 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
663 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 56));
664 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 56));
665 }
666
667 #[test]
668 fn test_i64_to_i16() {
669 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
670 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 48));
671 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 48));
672 }
673
674 #[test]
675 fn test_i64_to_i32() {
676 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
677 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 32));
678 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 32));
679 }
680
681 #[test]
682 fn test_i64_to_i64() {
683 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
684 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
685 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
686 }
687
688 #[test]
689 fn test_i64_to_i128() {
690 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
691 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
692 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
693 }
694
695 #[test]
696 fn test_i64_to_scalar() {
697 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(
698 Mode::Constant,
699 count_is!(0, 0, 0, 0),
700 );
701 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
702 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
703 }
704
705 #[test]
706 fn test_i64_to_u8() {
707 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
708 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
709 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
710 }
711
712 #[test]
713 fn test_i64_to_u16() {
714 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
715 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
716 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
717 }
718
719 #[test]
720 fn test_i64_to_u32() {
721 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
722 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
723 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
724 }
725
726 #[test]
727 fn test_i64_to_u64() {
728 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
729 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
730 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
731 }
732
733 #[test]
734 fn test_i64_to_u128() {
735 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
736 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
737 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
738 }
739 }
740
741 mod i128 {
742 use super::*;
743
744 fn sample_values(
745 i: usize,
746 mode: Mode,
747 rng: &mut TestRng,
748 ) -> (console_root::types::I128<MainnetV0>, I128<Circuit>) {
749 super::sample_values(i, mode, rng)
750 }
751
752 impl_check_cast!(cast, I128<Circuit>, console_root::types::I128<MainnetV0>);
753
754 #[test]
755 fn test_i128_to_address() {
756 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
757 Mode::Constant,
758 count_less_than!(11, 0, 0, 0),
759 );
760 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
761 Mode::Public,
762 count_is!(4, 0, 13, 13),
763 );
764 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
765 Mode::Private,
766 count_is!(4, 0, 13, 13),
767 );
768 }
769
770 #[test]
771 fn test_i128_to_boolean() {
772 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
773 Mode::Constant,
774 count_is!(256, 0, 0, 0),
775 );
776 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
777 Mode::Public,
778 count_is!(256, 0, 5, 6),
779 );
780 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
781 Mode::Private,
782 count_is!(256, 0, 5, 6),
783 );
784 }
785
786 #[test]
787 fn test_i128_to_field() {
788 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
789 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
790 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
791 }
792
793 #[test]
794 fn test_i128_to_group() {
795 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(
796 Mode::Constant,
797 count_less_than!(11, 0, 0, 0),
798 );
799 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Public, count_is!(4, 0, 13, 13));
800 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Private, count_is!(4, 0, 13, 13));
801 }
802
803 #[test]
804 fn test_i128_to_i8() {
805 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
806 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 120));
807 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 120));
808 }
809
810 #[test]
811 fn test_i128_to_i16() {
812 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
813 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 112));
814 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 112));
815 }
816
817 #[test]
818 fn test_i128_to_i32() {
819 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
820 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 96));
821 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 96));
822 }
823
824 #[test]
825 fn test_i128_to_i64() {
826 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
827 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 64));
828 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 64));
829 }
830
831 #[test]
832 fn test_i128_to_i128() {
833 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
834 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
835 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
836 }
837
838 #[test]
839 fn test_i128_to_scalar() {
840 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(
841 Mode::Constant,
842 count_is!(0, 0, 0, 0),
843 );
844 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
845 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
846 }
847
848 #[test]
849 fn test_i128_to_u8() {
850 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
851 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
852 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
853 }
854
855 #[test]
856 fn test_i128_to_u16() {
857 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
858 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
859 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
860 }
861
862 #[test]
863 fn test_i128_to_u32() {
864 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
865 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
866 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
867 }
868
869 #[test]
870 fn test_i128_to_u64() {
871 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
872 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
873 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
874 }
875
876 #[test]
877 fn test_i128_to_u128() {
878 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
879 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
880 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
881 }
882 }
883
884 mod u8 {
885 use super::*;
886
887 fn sample_values(i: usize, mode: Mode, rng: &mut TestRng) -> (console_root::types::U8<MainnetV0>, U8<Circuit>) {
888 super::sample_values(i, mode, rng)
889 }
890
891 impl_check_cast!(cast, U8<Circuit>, console_root::types::U8<MainnetV0>);
892
893 #[test]
894 fn test_u8_to_address() {
895 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
896 Mode::Constant,
897 count_less_than!(11, 0, 0, 0),
898 );
899 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
900 Mode::Public,
901 count_is!(4, 0, 13, 13),
902 );
903 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
904 Mode::Private,
905 count_is!(4, 0, 13, 13),
906 );
907 }
908
909 #[test]
910 fn test_u8_to_boolean() {
911 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
912 Mode::Constant,
913 count_is!(16, 0, 0, 0),
914 );
915 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
916 Mode::Public,
917 count_is!(16, 0, 5, 6),
918 );
919 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
920 Mode::Private,
921 count_is!(16, 0, 5, 6),
922 );
923 }
924
925 #[test]
926 fn test_u8_to_field() {
927 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
928 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
929 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
930 }
931
932 #[test]
933 fn test_u8_to_group() {
934 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(
935 Mode::Constant,
936 count_less_than!(11, 0, 0, 0),
937 );
938 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Public, count_is!(4, 0, 13, 13));
939 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Private, count_is!(4, 0, 13, 13));
940 }
941
942 #[test]
943 fn test_u8_to_i8() {
944 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
945 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
946 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
947 }
948
949 #[test]
950 fn test_u8_to_i16() {
951 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
952 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
953 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
954 }
955
956 #[test]
957 fn test_u8_to_i32() {
958 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
959 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
960 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
961 }
962
963 #[test]
964 fn test_u8_to_i64() {
965 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
966 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
967 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
968 }
969
970 #[test]
971 fn test_u8_to_i128() {
972 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
973 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
974 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
975 }
976
977 #[test]
978 fn test_u8_to_scalar() {
979 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(
980 Mode::Constant,
981 count_is!(0, 0, 0, 0),
982 );
983 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
984 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
985 }
986
987 #[test]
988 fn test_u8_to_u8() {
989 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
990 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
991 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
992 }
993
994 #[test]
995 fn test_u8_to_u16() {
996 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
997 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
998 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
999 }
1000
1001 #[test]
1002 fn test_u8_to_u32() {
1003 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1004 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1005 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1006 }
1007
1008 #[test]
1009 fn test_u8_to_u64() {
1010 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1011 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1012 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1013 }
1014
1015 #[test]
1016 fn test_u8_to_u128() {
1017 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1018 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1019 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1020 }
1021 }
1022
1023 mod u16 {
1024 use super::*;
1025
1026 fn sample_values(
1027 i: usize,
1028 mode: Mode,
1029 rng: &mut TestRng,
1030 ) -> (console_root::types::U16<MainnetV0>, U16<Circuit>) {
1031 super::sample_values(i, mode, rng)
1032 }
1033
1034 impl_check_cast!(cast, U16<Circuit>, console_root::types::U16<MainnetV0>);
1035
1036 #[test]
1037 fn test_u16_to_address() {
1038 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
1039 Mode::Constant,
1040 count_less_than!(11, 0, 0, 0),
1041 );
1042 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
1043 Mode::Public,
1044 count_is!(4, 0, 13, 13),
1045 );
1046 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
1047 Mode::Private,
1048 count_is!(4, 0, 13, 13),
1049 );
1050 }
1051
1052 #[test]
1053 fn test_u16_to_boolean() {
1054 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
1055 Mode::Constant,
1056 count_is!(32, 0, 0, 0),
1057 );
1058 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
1059 Mode::Public,
1060 count_is!(32, 0, 5, 6),
1061 );
1062 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
1063 Mode::Private,
1064 count_is!(32, 0, 5, 6),
1065 );
1066 }
1067
1068 #[test]
1069 fn test_u16_to_field() {
1070 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1071 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1072 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1073 }
1074
1075 #[test]
1076 fn test_u16_to_group() {
1077 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(
1078 Mode::Constant,
1079 count_less_than!(11, 0, 0, 0),
1080 );
1081 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Public, count_is!(4, 0, 13, 13));
1082 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Private, count_is!(4, 0, 13, 13));
1083 }
1084
1085 #[test]
1086 fn test_u16_to_i8() {
1087 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1088 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1089 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1090 }
1091
1092 #[test]
1093 fn test_u16_to_i16() {
1094 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1095 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1096 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1097 }
1098
1099 #[test]
1100 fn test_u16_to_i32() {
1101 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1102 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1103 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1104 }
1105
1106 #[test]
1107 fn test_u16_to_i64() {
1108 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1109 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1110 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1111 }
1112
1113 #[test]
1114 fn test_u16_to_i128() {
1115 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1116 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1117 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1118 }
1119
1120 #[test]
1121 fn test_u16_to_scalar() {
1122 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(
1123 Mode::Constant,
1124 count_is!(0, 0, 0, 0),
1125 );
1126 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1127 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1128 }
1129
1130 #[test]
1131 fn test_u16_to_u8() {
1132 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1133 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1134 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1135 }
1136
1137 #[test]
1138 fn test_u16_to_u16() {
1139 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1140 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1141 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1142 }
1143
1144 #[test]
1145 fn test_u16_to_u32() {
1146 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1147 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1148 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1149 }
1150
1151 #[test]
1152 fn test_u16_to_u64() {
1153 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1154 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1155 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1156 }
1157
1158 #[test]
1159 fn test_u16_to_u128() {
1160 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1161 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1162 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1163 }
1164 }
1165
1166 mod u32 {
1167 use super::*;
1168
1169 fn sample_values(
1170 i: usize,
1171 mode: Mode,
1172 rng: &mut TestRng,
1173 ) -> (console_root::types::U32<MainnetV0>, U32<Circuit>) {
1174 super::sample_values(i, mode, rng)
1175 }
1176
1177 impl_check_cast!(cast, U32<Circuit>, console_root::types::U32<MainnetV0>);
1178
1179 #[test]
1180 fn test_u32_to_address() {
1181 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
1182 Mode::Constant,
1183 count_less_than!(11, 0, 0, 0),
1184 );
1185 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
1186 Mode::Public,
1187 count_is!(4, 0, 13, 13),
1188 );
1189 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
1190 Mode::Private,
1191 count_is!(4, 0, 13, 13),
1192 );
1193 }
1194
1195 #[test]
1196 fn test_u32_to_boolean() {
1197 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
1198 Mode::Constant,
1199 count_is!(64, 0, 0, 0),
1200 );
1201 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
1202 Mode::Public,
1203 count_is!(64, 0, 5, 6),
1204 );
1205 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
1206 Mode::Private,
1207 count_is!(64, 0, 5, 6),
1208 );
1209 }
1210
1211 #[test]
1212 fn test_u32_to_field() {
1213 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1214 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1215 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1216 }
1217
1218 #[test]
1219 fn test_u32_to_group() {
1220 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(
1221 Mode::Constant,
1222 count_less_than!(11, 0, 0, 0),
1223 );
1224 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Public, count_is!(4, 0, 13, 13));
1225 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Private, count_is!(4, 0, 13, 13));
1226 }
1227
1228 #[test]
1229 fn test_u32_to_i8() {
1230 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1231 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1232 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1233 }
1234
1235 #[test]
1236 fn test_u32_to_i16() {
1237 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1238 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1239 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1240 }
1241
1242 #[test]
1243 fn test_u32_to_i32() {
1244 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1245 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1246 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1247 }
1248
1249 #[test]
1250 fn test_u32_to_i64() {
1251 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1252 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1253 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1254 }
1255
1256 #[test]
1257 fn test_u32_to_i128() {
1258 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1259 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1260 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1261 }
1262
1263 #[test]
1264 fn test_u32_to_scalar() {
1265 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(
1266 Mode::Constant,
1267 count_is!(0, 0, 0, 0),
1268 );
1269 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1270 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1271 }
1272
1273 #[test]
1274 fn test_u32_to_u8() {
1275 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1276 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1277 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1278 }
1279
1280 #[test]
1281 fn test_u32_to_u16() {
1282 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1283 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1284 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1285 }
1286
1287 #[test]
1288 fn test_u32_to_u32() {
1289 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1290 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1291 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1292 }
1293
1294 #[test]
1295 fn test_u32_to_u64() {
1296 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1297 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1298 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1299 }
1300
1301 #[test]
1302 fn test_u32_to_u128() {
1303 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1304 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1305 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1306 }
1307 }
1308
1309 mod u64 {
1310 use super::*;
1311
1312 fn sample_values(
1313 i: usize,
1314 mode: Mode,
1315 rng: &mut TestRng,
1316 ) -> (console_root::types::U64<MainnetV0>, U64<Circuit>) {
1317 super::sample_values(i, mode, rng)
1318 }
1319
1320 impl_check_cast!(cast, U64<Circuit>, console_root::types::U64<MainnetV0>);
1321
1322 #[test]
1323 fn test_u64_to_address() {
1324 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
1325 Mode::Constant,
1326 count_less_than!(11, 0, 0, 0),
1327 );
1328 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
1329 Mode::Public,
1330 count_is!(4, 0, 13, 13),
1331 );
1332 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
1333 Mode::Private,
1334 count_is!(4, 0, 13, 13),
1335 );
1336 }
1337
1338 #[test]
1339 fn test_u64_to_boolean() {
1340 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
1341 Mode::Constant,
1342 count_is!(128, 0, 0, 0),
1343 );
1344 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
1345 Mode::Public,
1346 count_is!(128, 0, 5, 6),
1347 );
1348 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
1349 Mode::Private,
1350 count_is!(128, 0, 5, 6),
1351 );
1352 }
1353
1354 #[test]
1355 fn test_u64_to_field() {
1356 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1357 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1358 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1359 }
1360
1361 #[test]
1362 fn test_u64_to_group() {
1363 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(
1364 Mode::Constant,
1365 count_less_than!(11, 0, 0, 0),
1366 );
1367 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Public, count_is!(4, 0, 13, 13));
1368 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Private, count_is!(4, 0, 13, 13));
1369 }
1370
1371 #[test]
1372 fn test_u64_to_i8() {
1373 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1374 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1375 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1376 }
1377
1378 #[test]
1379 fn test_u64_to_i16() {
1380 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1381 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1382 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1383 }
1384
1385 #[test]
1386 fn test_u64_to_i32() {
1387 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1388 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1389 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1390 }
1391
1392 #[test]
1393 fn test_u64_to_i64() {
1394 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1395 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1396 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1397 }
1398
1399 #[test]
1400 fn test_u64_to_i128() {
1401 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1402 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1403 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1404 }
1405
1406 #[test]
1407 fn test_u64_to_scalar() {
1408 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(
1409 Mode::Constant,
1410 count_is!(0, 0, 0, 0),
1411 );
1412 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1413 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1414 }
1415
1416 #[test]
1417 fn test_u64_to_u8() {
1418 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1419 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1420 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1421 }
1422
1423 #[test]
1424 fn test_u64_to_u16() {
1425 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1426 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1427 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1428 }
1429
1430 #[test]
1431 fn test_u64_to_u32() {
1432 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1433 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1434 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1435 }
1436
1437 #[test]
1438 fn test_u64_to_u64() {
1439 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1440 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1441 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1442 }
1443
1444 #[test]
1445 fn test_u64_to_u128() {
1446 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1447 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1448 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1449 }
1450 }
1451
1452 mod u128 {
1453 use super::*;
1454
1455 fn sample_values(
1456 i: usize,
1457 mode: Mode,
1458 rng: &mut TestRng,
1459 ) -> (console_root::types::U128<MainnetV0>, U128<Circuit>) {
1460 super::sample_values(i, mode, rng)
1461 }
1462
1463 impl_check_cast!(cast, U128<Circuit>, console_root::types::U128<MainnetV0>);
1464
1465 #[test]
1466 fn test_u128_to_address() {
1467 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
1468 Mode::Constant,
1469 count_less_than!(11, 0, 0, 0),
1470 );
1471 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
1472 Mode::Public,
1473 count_is!(4, 0, 13, 13),
1474 );
1475 check_cast::<Address<Circuit>, console_root::types::Address<MainnetV0>>(
1476 Mode::Private,
1477 count_is!(4, 0, 13, 13),
1478 );
1479 }
1480
1481 #[test]
1482 fn test_u128_to_boolean() {
1483 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
1484 Mode::Constant,
1485 count_is!(256, 0, 0, 0),
1486 );
1487 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
1488 Mode::Public,
1489 count_is!(256, 0, 5, 6),
1490 );
1491 check_cast::<Boolean<Circuit>, console_root::types::Boolean<MainnetV0>>(
1492 Mode::Private,
1493 count_is!(256, 0, 5, 6),
1494 );
1495 }
1496
1497 #[test]
1498 fn test_u128_to_field() {
1499 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1500 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1501 check_cast::<Field<Circuit>, console_root::types::Field<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1502 }
1503
1504 #[test]
1505 fn test_u128_to_group() {
1506 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(
1507 Mode::Constant,
1508 count_less_than!(11, 0, 0, 0),
1509 );
1510 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Public, count_is!(4, 0, 13, 13));
1511 check_cast::<Group<Circuit>, console_root::types::Group<MainnetV0>>(Mode::Private, count_is!(4, 0, 13, 13));
1512 }
1513
1514 #[test]
1515 fn test_u128_to_i8() {
1516 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1517 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1518 check_cast::<I8<Circuit>, console_root::types::I8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1519 }
1520
1521 #[test]
1522 fn test_u128_to_i16() {
1523 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1524 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1525 check_cast::<I16<Circuit>, console_root::types::I16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1526 }
1527
1528 #[test]
1529 fn test_u128_to_i32() {
1530 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1531 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1532 check_cast::<I32<Circuit>, console_root::types::I32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1533 }
1534
1535 #[test]
1536 fn test_u128_to_i64() {
1537 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1538 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1539 check_cast::<I64<Circuit>, console_root::types::I64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1540 }
1541
1542 #[test]
1543 fn test_u128_to_i128() {
1544 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1545 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1546 check_cast::<I128<Circuit>, console_root::types::I128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1547 }
1548
1549 #[test]
1550 fn test_u128_to_scalar() {
1551 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(
1552 Mode::Constant,
1553 count_is!(0, 0, 0, 0),
1554 );
1555 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1556 check_cast::<Scalar<Circuit>, console_root::types::Scalar<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1557 }
1558
1559 #[test]
1560 fn test_u128_to_u8() {
1561 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1562 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1563 check_cast::<U8<Circuit>, console_root::types::U8<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1564 }
1565
1566 #[test]
1567 fn test_u128_to_u16() {
1568 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1569 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1570 check_cast::<U16<Circuit>, console_root::types::U16<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1571 }
1572
1573 #[test]
1574 fn test_u128_to_u32() {
1575 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1576 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1577 check_cast::<U32<Circuit>, console_root::types::U32<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1578 }
1579
1580 #[test]
1581 fn test_u128_to_u64() {
1582 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1583 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 1));
1584 check_cast::<U64<Circuit>, console_root::types::U64<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 1));
1585 }
1586
1587 #[test]
1588 fn test_u128_to_u128() {
1589 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Constant, count_is!(0, 0, 0, 0));
1590 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Public, count_is!(0, 0, 0, 0));
1591 check_cast::<U128<Circuit>, console_root::types::U128<MainnetV0>>(Mode::Private, count_is!(0, 0, 0, 0));
1592 }
1593 }
1594}