1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use crate::;
/// [`test_point_has_small_order()`] ensures [`WEAK_KEYS`] are considered to have
/// a small order
// TODO: fix this test
//use super::constants::PRIME;
// /// [`test_point_is_canonical()`] ensures that elements `>= p` are considered
// /// non canonical
// #[test]
// fn test_point_is_canonical() {
// // buffer stores the candidate points (in little endian) that we'll test
// // against, starting with `PRIME`
// let mut buffer = PRIME.to_bytes_le().1;
// // Iterate over the 19*2 finite field elements
// let mut p = Point::new();
// let mut actual_non_canonical_count = 0;
// let expected_non_canonical_count = 24;
// for i in 0..19 {
// buffer[0] = (237 + i) as u8;
// buffer[31] = 127_u8;
// // Check if it's a valid point on the curve that's
// // not canonical
// match p.unmarshal_binary(&buffer) {
// Ok(_) => (),
// Err(_) => if !p.is_canonical(&buffer) {
// actual_non_canonical_count += 1;
// },
// }
// // flip bit
// buffer[31] |= 128;
// // Check if it's a valid point on the curve that's
// // not canonical
// match p.unmarshal_binary(&buffer) {
// Ok(_) => (),
// Err(_) => if !p.is_canonical(&buffer) {
// actual_non_canonical_count += 1;
// },
// }
// }
// assert_eq!(expected_non_canonical_count, actual_non_canonical_count, "incorrect number of non canonical points detected")
// }