Returns the public key of a given digit, requires the digit index to modify the secret key for each digit
(ps: &Parameters, secret_key: &SecretKey, digit_index: u32)
| 86 | |
| 87 | /// Returns the public key of a given digit, requires the digit index to modify the secret key for each digit |
| 88 | fn public_key_for_digit(ps: &Parameters, secret_key: &SecretKey, digit_index: u32) -> HashOut { |
| 89 | let mut hash = secret_key_for_digit(secret_key, digit_index); |
| 90 | let mut all_possible_digits = vec![hash]; |
| 91 | for _ in 0..ps.max_digit() { |
| 92 | hash = hash160::Hash::hash(&hash[..]); |
| 93 | all_possible_digits.push(hash) |
| 94 | } |
| 95 | all_possible_digits.sort(); |
| 96 | for i in 0..ps.max_digit() as usize { |
| 97 | if all_possible_digits[i] == all_possible_digits[i + 1] { |
| 98 | eprintln!("WARNING: Given secret key has repetitive hashes for digit {}, it won't work with brute force verifier", digit_index); |
| 99 | } |
| 100 | } |
| 101 | *hash.as_byte_array() |
| 102 | } |
| 103 | |
| 104 | /// Returns the public key for the given secret key and the parameters |
| 105 | pub fn generate_public_key(ps: &Parameters, secret_key: &SecretKey) -> PublicKey { |
no test coverage detected