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

Method sign_digits

bitvm/src/signatures/winternitz.rs:150–162  ·  view source on GitHub ↗

Creates a Winternitz signature for the given `secret_key` and `digits`. ## Output format - `hash(digits[0])` - `digits[0]` - `hash(digits[1])` - `digits[1]` - ... - `hash(digits[n + m - 1])` - `digits[n + m - 1]` There are `n` message digits followed by `m` checksum digits. The checksum is computed internally.

(ps: &Parameters, secret_key: &SecretKey, message_digits: Vec<u32>)

Source from the content-addressed store, hash-verified

148 /// There are `n` message digits followed by `m` checksum digits.
149 /// The checksum is computed internally.
150 fn sign_digits(ps: &Parameters, secret_key: &SecretKey, message_digits: Vec<u32>) -> Witness {
151 let digits = add_message_checksum(ps, message_digits);
152 let mut result = Witness::new();
153 for i in 0..ps.total_digit_len() {
154 let sig = digit_signature(secret_key, i, digits[i as usize]);
155 // FIXME: Do trailing zeroes violate Bitcoin Script's minimum data push requirement?
156 // Maybe the script! macro removes the zeroes.
157 // There is a 1/256 chance that a signature contains a trailing zero.
158 result.push(sig);
159 result.push(bitcoin_representation(digits[i as usize] as i32));
160 }
161 result
162 }
163
164 /// Returns a Bitcoin script that verifies a Winternitz signature for the given `public_key`.
165 ///

Callers

nothing calls this directly

Implementers 1

winternitz.rsbitvm/src/signatures/winternitz.rs

Calls 5

add_message_checksumFunction · 0.85
digit_signatureFunction · 0.85
bitcoin_representationFunction · 0.85
total_digit_lenMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected