MCPcopy Create free account
hub / github.com/BitVM/BitVM / public_key_for_digit

Function public_key_for_digit

bitvm/src/signatures/winternitz.rs:88–102  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

86
87/// Returns the public key of a given digit, requires the digit index to modify the secret key for each digit
88fn 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
105pub fn generate_public_key(ps: &Parameters, secret_key: &SecretKey) -> PublicKey {

Callers 1

generate_public_keyFunction · 0.85

Calls 3

secret_key_for_digitFunction · 0.85
max_digitMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected