-
Notifications
You must be signed in to change notification settings - Fork 179
Description
Currently the pool role (and presumably other roles) incorrectly verifies the Template Provider authority key (and presumable other upstream keys).
The checks happen here:
stratum/protocols/v2/noise-sv2/src/signature_message.rs
Lines 26 to 40 in 3f07a6a
| impl SignatureNoiseMessage { | |
| pub fn verify(self, pk: &XOnlyPublicKey) -> bool { | |
| let now = SystemTime::now() | |
| .duration_since(SystemTime::UNIX_EPOCH) | |
| .unwrap() | |
| .as_secs() as u32; | |
| if self.valid_from <= now && self.not_valid_after >= now { | |
| let secp = Secp256k1::verification_only(); | |
| let (m, s) = self.split(); | |
| let m = Message::from_hashed_data::<sha256::Hash>(&m[0..10]); | |
| let s = match Signature::from_slice(&s) { | |
| Ok(s) => s, | |
| _ => return false, | |
| }; | |
| secp.verify_schnorr(&s, &m, pk).is_ok() |
-
The spec requires that
server_public_key(the upstream static key) is included in the signature hash, butmonly covers the 10 bytes of theSIGNATURE_NOISE_MESSAGE. It needs to append the server static public. -
The message should be signed by the authority key, but it's actually being checked against the static key.
The Template Provider in Bitcoin Core generated signatures with the same two issues. I fixed the bug, but then put in a workaround to re-introduce the bug. That way things keep working.
A fix for the Bitcoin Core side is here: Sjors/bitcoin#29
I'll merge that once the SRI-side is fixed.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status