Skip to content

Commit

Permalink
Allow high s in eth lock
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanson committed Aug 2, 2024
1 parent 74355f4 commit 962fc9d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion checksums.txt
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions contracts/ccc-eth-lock/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion contracts/ccc-eth-lock/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub enum Error {
WrongSignatureFormat,
InvalidRecoverId,
CanNotRecover,
SignatureIsNotLowS,
}

impl From<HelperError> for Error {
Expand Down
5 changes: 3 additions & 2 deletions tests/src/test_eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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]
Expand Down

0 comments on commit 962fc9d

Please sign in to comment.