From 962fc9ddc51093335fd291f1f47f62261469c221 Mon Sep 17 00:00:00 2001 From: mohanson Date: Fri, 2 Aug 2024 10:10:01 +0800 Subject: [PATCH] Allow high s in eth lock --- checksums.txt | 2 +- contracts/ccc-eth-lock/src/entry.rs | 3 --- contracts/ccc-eth-lock/src/error.rs | 1 - tests/src/test_eth.rs | 5 +++-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/checksums.txt b/checksums.txt index a3e78d3..a289ca2 100644 --- a/checksums.txt +++ b/checksums.txt @@ -1,3 +1,3 @@ 3d659b15f2aad5f9350f55ce471806c6d6ad4f51a555a82b7918e9d88f84f04a build/release/ccc-btc-lock -4ae08bd7ed954997dcbca5ff88700bf7f949b1080c2bd1cb024f15c8b0436396 build/release/ccc-eth-lock +a1744f76c77b3ec3f780db12c77b5dab024d3878e8ccc0bcde266e300c3c8de5 build/release/ccc-eth-lock 66bbb7041a10a0b2a2fd51ae2aa9394e9f7ee6e8b2b32dd5d3e4d37c0d4a64b8 build/release/ccc-sol-lock diff --git a/contracts/ccc-eth-lock/src/entry.rs b/contracts/ccc-eth-lock/src/entry.rs index c890751..d1e6d22 100644 --- a/contracts/ccc-eth-lock/src/entry.rs +++ b/contracts/ccc-eth-lock/src/entry.rs @@ -69,9 +69,6 @@ pub fn entry() -> Result<(), Error> { } let rec_id = RecoveryId::try_from(rec_id).map_err(|_| Error::InvalidRecoverId)?; let sig = Signature::from_slice(&sig_raw[..64]).map_err(|_| Error::WrongSignatureFormat)?; - if sig.normalize_s().is_some() { - return Err(Error::SignatureIsNotLowS); - } let pubkey_result = &recover_from_prehash(&digest_hash, &sig, rec_id) .map_err(|_| Error::CanNotRecover)? .to_encoded_point(false) diff --git a/contracts/ccc-eth-lock/src/error.rs b/contracts/ccc-eth-lock/src/error.rs index 27b63fa..7f2f989 100644 --- a/contracts/ccc-eth-lock/src/error.rs +++ b/contracts/ccc-eth-lock/src/error.rs @@ -14,7 +14,6 @@ pub enum Error { WrongSignatureFormat, InvalidRecoverId, CanNotRecover, - SignatureIsNotLowS, } impl From for Error { diff --git a/tests/src/test_eth.rs b/tests/src/test_eth.rs index 551e731..bfcf9ff 100644 --- a/tests/src/test_eth.rs +++ b/tests/src/test_eth.rs @@ -191,7 +191,7 @@ fn test_failure_recid() { } #[test] -fn test_failure_sig_use_high_s() { +fn test_success_sig_use_high_s() { let mut dl = Resource::default(); let mut px = Pickaxer::default(); let tx = default_tx(&mut dl, &mut px); @@ -201,13 +201,14 @@ fn test_failure_sig_use_high_s() { let l_s = k256::NonZeroScalar::try_from(&wa_lock[32..64]).unwrap(); let h_s = -l_s; wa_lock[32..64].copy_from_slice(&h_s.to_bytes().as_slice()); + wa_lock[64] = 55 - wa_lock[64]; let wa = wa.as_builder().lock(Some(ckb_types::bytes::Bytes::from(wa_lock)).pack()).build(); let tx = tx.as_advanced_builder().set_witnesses(vec![wa.as_bytes().pack()]).build(); let tx_resolved = ckb_types::core::cell::resolve_transaction(tx, &mut std::collections::HashSet::new(), &dl, &dl).unwrap(); let verifier = Verifier::default(); - assert_script_error(verifier.verify(&tx_resolved, &dl).unwrap_err(), 37); + verifier.verify(&tx_resolved, &dl).unwrap(); } #[test]