ff: PrimeField::{is_even, is_odd}

This commit is contained in:
Jack Grigg
2020-04-21 19:05:19 +12:00
parent 232f0a50b8
commit 1fdca393bb
10 changed files with 54 additions and 8 deletions

View File

@@ -2182,6 +2182,18 @@ fn test_fq_display() {
);
}
#[test]
fn test_fq_is_odd() {
assert!(!Fq::from(0).is_odd());
assert!(Fq::from(0).is_even());
assert!(Fq::from(1).is_odd());
assert!(!Fq::from(1).is_even());
assert!(!Fq::from(324834872).is_odd());
assert!(Fq::from(324834872).is_even());
assert!(Fq::from(324834873).is_odd());
assert!(!Fq::from(324834873).is_even());
}
#[test]
fn test_fq_num_bits() {
assert_eq!(Fq::NUM_BITS, 381);

View File

@@ -950,6 +950,18 @@ fn test_fr_display() {
);
}
#[test]
fn test_fr_is_odd() {
assert!(!Fr::from(0).is_odd());
assert!(Fr::from(0).is_even());
assert!(Fr::from(1).is_odd());
assert!(!Fr::from(1).is_even());
assert!(!Fr::from(324834872).is_odd());
assert!(Fr::from(324834872).is_even());
assert!(Fr::from(324834873).is_odd());
assert!(!Fr::from(324834873).is_even());
}
#[test]
fn test_fr_num_bits() {
assert_eq!(Fr::NUM_BITS, 255);