Bitcoin Forum
May 22, 2024, 05:58:19 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: script_invalid.json and MINIMALDATA test vectors  (Read 941 times)
piotr_n (OP)
Legendary
*
Offline Offline

Activity: 2053
Merit: 1354


aka tonikt


View Profile WWW
November 07, 2015, 05:23:04 PM
 #1

It's probably something I'm missing, but I haven't been able to figure out why certain test vectors with MINIMALDATA flag are expected to return FAIL, in the test suite.

I mean, I assume that all the script inside script_invalid.json are a failing ones - aren't they?

Because if so, can someone please explain me why e.g. these ones are supposed to fail:

Code:
["0x01 0x81", "DROP 1", "MINIMALDATA", "-1 minimally represented by OP_1NEGATE"],
["0x01 0x01", "DROP 1", "MINIMALDATA", "1 to 16 minimally represented by OP_1 to OP_16"],
["0x01 0x02", "DROP 1", "MINIMALDATA"],

Code:
["0x4c 0x48 0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", "DROP 1", "MINIMALDATA",
 "PUSHDATA1 of 72 bytes minimally represented by direct push"],

Which specific code triggers these failures?

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
hhanh00
Sr. Member
****
Offline Offline

Activity: 467
Merit: 266


View Profile
November 07, 2015, 08:09:14 PM
 #2

You can represent these numbers with single op_codes

Code:
["0x01 0x81"] = ["0x4f"]
["0x01 0x01"] = ["0x51"]
["0x01 0x02"] = ["0x52"]

You don't need PUSH_DATA1 for data <= 75 bytes
Code:
"0x4c 0x48 0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", 
= "0x48 0x111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"

They only fail if you pass the "MINIMALDATA" flag to the verification routine. I believe they are in to enforce BIP 62 (not yet in effect)

https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki#push-operators


Implemented at:
https://github.com/bitcoin/bitcoin/blob/923c5e93a90a6eddde3ab8589fc393da95bbc489/src/script/interpreter.cpp#L215

piotr_n (OP)
Legendary
*
Offline Offline

Activity: 2053
Merit: 1354


aka tonikt


View Profile WWW
November 08, 2015, 08:25:39 AM
Last edit: November 08, 2015, 09:09:47 AM by piotr_n
 #3

Thank you.

So, as for the code on the master branch, these tests are not supposed to pass?

Are they being run for the release cycle?

Is there any way to find out which of the vectors are not supposed to pass with the code from the current head?

Reason I ask is because I am trying to keep my script parsing implementation in sync with the core's head.
Figured that passing the core's test vectors should be a good measure of the compatibility, but apparently it isn't.

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
hhanh00
Sr. Member
****
Offline Offline

Activity: 467
Merit: 266


View Profile
November 09, 2015, 01:39:49 AM
 #4

They pass because the test driver sends the minimaldata flag. It's the last field of the test data.
Your implementation could do the same thing.

piotr_n (OP)
Legendary
*
Offline Offline

Activity: 2053
Merit: 1354


aka tonikt


View Profile WWW
November 09, 2015, 11:06:14 AM
 #5

All right, seems that I'm good now Smiley

Thanks mate, it helped me a lot!

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!