Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix usage of NegateSignatureS in script_tests #5784

Merged
merged 2 commits into from
Feb 18, 2015

Conversation

sdaftuar
Copy link
Member

NegateSignatureS is called with a signature which has not yet had the hashtype appended to it, yet the function assumed a hashtype was there and was incorrectly saving and then appending the last byte of its input (ie the last byte of the original S instead of a hashtype).

Only one pair of the test scripts was triggering this bug ("P2PK with high S"), which was actually causing the invalid version of the test to fail in the wrong place -- it was failing in the IsValidSignatureEncoding function rather than further down in IsLowDERSignature where the S value is checked. Fixing NegateSignatureS causes this test to change so that IsLowDERSignature is now being tested as I believe was intended.

Fixing that test resulted in there no longer being code coverage for the check in IsValidSignatureEncoding relating to extra bytes after the S, so the second commit here adds a pair of tests to exercise that check.

NegateSignatureS is called with a signature without a hashtype, so
do not save the last byte and append it after S negation.

Updates the two tests which were affected by this bug.
The fix to NegateSignatureS caused a test which had been failing
in IsValidSignatureEncoding to then fail in IsLowDERSignature.
Add new test so the original check remains exercised.
@sipa
Copy link
Member

sipa commented Feb 14, 2015

ACK

1 similar comment
@gmaxwell
Copy link
Contributor

ACK

@laanwj laanwj merged commit 78c6bed into bitcoin:master Feb 18, 2015
laanwj added a commit that referenced this pull request Feb 18, 2015
78c6bed Add test for DER-encoding edge case (Suhas Daftuar)
6f50dbd Fix NegateSignatureS to not duplicate last byte of S (Suhas Daftuar)
random-zebra referenced this pull request in PIVX-Project/PIVX Sep 15, 2021
a6d09a9 Policy: clean zc txs from the standard policies. (furszy)
fcf8c87 Get rid of inaccurate ScriptSigArgsExpected (Pieter Wuille)
08c2874 Fix invalid memory access in CScript::operator+= (Anthony Towns)
a01ee06 Adding P2SH(p2pkh) script test case (Chris Stewart)
1dab098 script_tests.json: 0xd1 and 0xd2 are reserved opcodes. (furszy)
8cdde3c Merge script_valid and script_invalid tests (Pieter Wuille)
67ccfda Get rid of expect in script_tests as it's implied by scripterror (Pieter Wuille)
555b146 Make script_error a mandatory 4th field for script_tests (Pieter Wuille)
ca14c77 Fix some misconstructed tests (Pieter Wuille)
8b88936 Fix formatting of NOPs for generated script tests (Pieter Wuille)
587aef8 Fix JSON pretty printing in script_tests (Pieter Wuille)
da4ef2b test: script_tests.cpp update. (furszy)
7e051a3 clarify obscure uses of EvalScript() (furszy)
4ee696c Make SCRIPT_VERIFY_CLEANSTACK a standardness requirement (furszy)
1f604ea Add SCRIPT_VERIFY_CLEANSTACK (BIP62 rule 6) (Pieter Wuille)
533edfa No semantic change: reuse stack variable in P2SH evaluation (Pieter Wuille)
ce30d7b Add test for DER-encoding edge case (Suhas Daftuar)
7faeeb8 Fix NegateSignatureS to not duplicate last byte of S (Suhas Daftuar)
395ecb1 Document standard.h functions. (furszy)
9f4e950 Extract CSipHasher to it's own file in crypto/ directory.  This is a move-only commit with the exception of changes to includes. (Jim Posen)

Pull request description:

  We are way too behind in terms of the script unit tests, this PR pushes us further into upstream's direction.

  Back ported PRs:
  * dashpay#5143
  * dashpay#5617
  * dashpay#5784
  * dashpay#5952 (de236f5 only)
  * dashpay#6075
  * bitcoin#7387
  * bitcoin#7517
  * bitcoin#7818
  * bitcoin#8090
  * bitcoin#11284
  * And 4fb789e

ACKs for top commit:
  random-zebra:
    utACK a6d09a9
  Fuzzbawls:
    ACK a6d09a9

Tree-SHA512: 60ee3e774f8e1c3cebf11d028442697725c93a61940c50b9776407ee3dd5a80bbfcca01eea5c6be43c78f4c215d4b238a6dcb640641e86e123b19bf1b7c33350
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants