Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bloomingpeach committed Oct 21, 2024
1 parent aeb0fc0 commit 7ea91db
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
3 changes: 2 additions & 1 deletion packages/engine/src/opcodes/crypto.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ pub fn opcode_checksig<
let err = res.unwrap_err();
if err == Error::SCRIPT_ERR_SIG_DER
|| err == Error::PUBKEYTYPE
|| err == Error::SIG_HASHTYPE {
|| err == Error::SIG_HASHTYPE
|| err == Error::SIG_HIGH_S {
return Result::Err(err);
};
engine.dstack.push_bool(false);
Expand Down
26 changes: 5 additions & 21 deletions packages/engine/src/signature/signature.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -567,31 +567,15 @@ pub fn remove_signature(script: @ByteArray, sig_bytes: @ByteArray) -> @ByteArray

let script_len = script.len();
while i < script_len {
let push_data: u8 = script[i];
if push_data >= 8 && push_data <= 72 {
let mut len: usize = push_data.into();
let mut found: bool = false;
if len == sig_bytes.len() {
found = compare_data(script, sig_bytes, i, push_data);
}

if i + len <= script.len() {
i += len;
} else {
i += 1;
}
let opcode = script[i];
let data_len = parser::data_len(script, i).unwrap();
let end = i + data_len + 1;
if data_len == sig_bytes.len() {
let mut found = compare_data(script, sig_bytes, i, opcode);
if found {
i = end;
continue;
}

processed_script.append_byte(push_data);
while len != 0 && i - len < script_len {
processed_script.append_byte(script[i - len + 1]);
len -= 1;
};
} else {
processed_script.append_byte(push_data);
}
while i != end {
processed_script.append_byte(script[i]);
Expand Down
2 changes: 1 addition & 1 deletion tests/run-core-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ jq -c '.[]' $SCRIPT_TESTS_JSON | {
elif echo "$RESULT" | grep -q "$INVALID_SIG_FMT"; then
SCRIPT_RESULT="SIG_DER"
elif echo "$RESULT" | grep -q "$INVALID_HASH_TYPE"; then
SCRIPT_RESULT="SIG_DER"
SCRIPT_RESULT="SIG_HASHTYPE"
elif echo "$RESULT" | grep -q "$NONZERO_NULLFAIL"; then
SCRIPT_RESULT="NULLFAIL"
elif echo "$RESULT" | grep -q "$SIG_NULLFAIL"; then
Expand Down

0 comments on commit 7ea91db

Please sign in to comment.