From ce4856a09a7ed94e331f114efeffa836488a1e43 Mon Sep 17 00:00:00 2001 From: Mohanson Date: Wed, 17 Jul 2024 09:51:24 +0800 Subject: [PATCH] Automatic conversion of recid (#2) --- checksums.txt | 2 +- contracts/ccc-btc-lock/src/entry.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/checksums.txt b/checksums.txt index bb02645..f1c2fae 100644 --- a/checksums.txt +++ b/checksums.txt @@ -1 +1 @@ -90ac5917faf6acad047e217b14181869dc7801044223d58d5c7dfdb4cbd07672 build/release/ccc-btc-lock +bef047973a601d7bab6bcbf638f4c92a41a471fa53d5bf44f7233d3340b30e01 build/release/ccc-btc-lock diff --git a/contracts/ccc-btc-lock/src/entry.rs b/contracts/ccc-btc-lock/src/entry.rs index ccbc3a8..6c3e982 100644 --- a/contracts/ccc-btc-lock/src/entry.rs +++ b/contracts/ccc-btc-lock/src/entry.rs @@ -45,7 +45,11 @@ pub fn entry() -> Result<(), Error> { if sig.len() != 65 { return Err(Error::WrongSignatureFormat); } - let rec_id = sig[0]; + let rec_id = match sig[0] { + 31 | 32 | 33 | 34 => sig[0] - 31, + 39 | 40 | 41 | 42 => sig[0] - 39, + _ => sig[0], + }; let rec_id = RecoveryId::try_from(rec_id).map_err(|_| Error::InvalidRecoverId)?; let signature = Signature::from_slice(&sig[1..]).map_err(|_| Error::WrongSignatureFormat)?; let recovered_key = VerifyingKey::recover_from_prehash(&msg, &signature, rec_id)