Skip to content

txscript: Rename OP_SHA256 to OP_BLAKE256. #840

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

Merged
merged 1 commit into from
Sep 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions txscript/data/script_invalid.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@

["NOP", "RIPEMD160", "P2SH,STRICTENC"],
["NOP", "SHA1", "P2SH,STRICTENC"],
["NOP", "SHA256", "P2SH,STRICTENC"],
["NOP", "BLAKE256", "P2SH,STRICTENC"],
["NOP", "HASH160", "P2SH,STRICTENC"],
["NOP", "HASH256", "P2SH,STRICTENC"],

Expand Down Expand Up @@ -341,7 +341,7 @@

["NOP", "RIPEMD160 1", "P2SH,STRICTENC"],
["NOP", "SHA1 1", "P2SH,STRICTENC"],
["NOP", "SHA256 1", "P2SH,STRICTENC"],
["NOP", "BLAKE256 1", "P2SH,STRICTENC"],
["NOP", "HASH160 1", "P2SH,STRICTENC"],
["NOP", "HASH256 1", "P2SH,STRICTENC"],

Expand Down
12 changes: 6 additions & 6 deletions txscript/data/script_valid.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@
["''", "SHA1 0x14 0xda39a3ee5e6b4b0d3255bfef95601890afd80709 EQUAL", "P2SH,STRICTENC"],
["'a'", "SHA1 0x14 0x86f7e437faa5a7fce15d1ddcb9eaeaea377667b8 EQUAL", "P2SH,STRICTENC"],
["'abcdefghijklmnopqrstuvwxyz'", "SHA1 0x14 0x32d10c7b8cf96570ca04ce37f2a19d84240d3a89 EQUAL", "P2SH,STRICTENC"],
["''", "SHA256 0x20 0x716f6e863f744b9ac22c97ec7b76ea5f5908bc5b2f67c61510bfc4751384ea7a EQUAL", "P2SH,STRICTENC"],
["'a'", "SHA256 0x20 0x43234ff894a9c0590d0246cfc574eb781a80958b01d7a2fa1ac73c673ba5e311 EQUAL", "P2SH,STRICTENC"],
["'abcdefghijklmnopqrstuvwxyz'", "SHA256 0x20 0x6c648655a21f704a0bc72eb367b24144c9e8a1b07efc34165b561b6c33514427 EQUAL", "P2SH,STRICTENC"],
["''", "DUP HASH160 SWAP SHA256 RIPEMD160 EQUAL", "P2SH,STRICTENC"],
["''", "DUP HASH256 SWAP SHA256 SHA256 EQUAL", "P2SH,STRICTENC"],
["''", "BLAKE256 0x20 0x716f6e863f744b9ac22c97ec7b76ea5f5908bc5b2f67c61510bfc4751384ea7a EQUAL", "P2SH,STRICTENC"],
["'a'", "BLAKE256 0x20 0x43234ff894a9c0590d0246cfc574eb781a80958b01d7a2fa1ac73c673ba5e311 EQUAL", "P2SH,STRICTENC"],
["'abcdefghijklmnopqrstuvwxyz'", "BLAKE256 0x20 0x6c648655a21f704a0bc72eb367b24144c9e8a1b07efc34165b561b6c33514427 EQUAL", "P2SH,STRICTENC"],
["''", "DUP HASH160 SWAP BLAKE256 RIPEMD160 EQUAL", "P2SH,STRICTENC"],
["''", "DUP HASH256 SWAP BLAKE256 BLAKE256 EQUAL", "P2SH,STRICTENC"],
["''", "NOP HASH160 0x14 0x413320bee32a3bdb92b145d337316739d54a9287 EQUAL", "P2SH,STRICTENC"],
["'a'", "HASH160 NOP 0x14 0x8704ae49993a1b72b8a8b28decc7f9e58be752ce EQUAL", "P2SH,STRICTENC"],
["'abcdefghijklmnopqrstuvwxyz'", "HASH160 0x4c 0x14 0x64d140650ed333a070a8ae05fac65032aebdfe5f EQUAL", "P2SH,STRICTENC"],
Expand Down Expand Up @@ -461,7 +461,7 @@

["0", "RIPEMD160", "P2SH,STRICTENC"],
["0", "SHA1", "P2SH,STRICTENC"],
["0", "SHA256", "P2SH,STRICTENC"],
["0", "BLAKE256", "P2SH,STRICTENC"],
["0", "HASH160", "P2SH,STRICTENC"],
["0", "HASH256", "P2SH,STRICTENC"],
["NOP", "1", "P2SH,STRICTENC"],
Expand Down
8 changes: 4 additions & 4 deletions txscript/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3403,17 +3403,17 @@ func TestUnparsingInvalidOpcodes(t *testing.T) {
expectedErr: ErrStackInvalidOpcode,
},
{
name: "OP_SHA256",
name: "OP_BLAKE256",
pop: &parsedOpcode{
opcode: &opcodeArray[OP_SHA256],
opcode: &opcodeArray[OP_BLAKE256],
data: nil,
},
expectedErr: nil,
},
{
name: "OP_SHA256 long",
name: "OP_BLAKE256 long",
pop: &parsedOpcode{
opcode: &opcodeArray[OP_SHA256],
opcode: &opcodeArray[OP_BLAKE256],
data: make([]byte, 1),
},
expectedErr: ErrStackInvalidOpcode,
Expand Down
22 changes: 11 additions & 11 deletions txscript/opcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const (
OP_WITHIN = 0xa5 // 165
OP_RIPEMD160 = 0xa6 // 166
OP_SHA1 = 0xa7 // 167
OP_SHA256 = 0xa8 // 168
OP_BLAKE256 = 0xa8 // 168
OP_HASH160 = 0xa9 // 169
OP_HASH256 = 0xaa // 170
OP_CODESEPARATOR = 0xab // 171
Expand Down Expand Up @@ -498,7 +498,7 @@ var opcodeArray = [256]opcode{
// Crypto opcodes.
OP_RIPEMD160: {OP_RIPEMD160, "OP_RIPEMD160", 1, opcodeRipemd160},
OP_SHA1: {OP_SHA1, "OP_SHA1", 1, opcodeSha1},
OP_SHA256: {OP_SHA256, "OP_SHA256", 1, opcodeSha256},
OP_BLAKE256: {OP_BLAKE256, "OP_BLAKE256", 1, opcodeBlake256},
OP_HASH160: {OP_HASH160, "OP_HASH160", 1, opcodeHash160},
OP_HASH256: {OP_HASH256, "OP_HASH256", 1, opcodeHash256},
OP_CODESEPARATOR: {OP_CODESEPARATOR, "OP_CODESEPARATOR", 1, opcodeDisabled}, // Disabled
Expand Down Expand Up @@ -1102,7 +1102,7 @@ func opcodeCheckLockTimeVerify(op *parsedOpcode, vm *Engine) error {
}

// opcodeCheckSequenceVerify compares the top item on the data stack to the
// LockTime field of the transaction containing the script signature
// Sequence field of the transaction containing the script signature
// validating if the transaction outputs are spendable yet. If flag
// ScriptVerifyCheckSequenceVerify is not set, the code continues as if OP_NOP3
// were executed.
Expand Down Expand Up @@ -2332,11 +2332,11 @@ func opcodeSha1(op *parsedOpcode, vm *Engine) error {
return nil
}

// opcodeSha256 treats the top item of the data stack as raw bytes and replaces
// it with hash256(data).
// opcodeBlake256 treats the top item of the data stack as raw bytes and
// replaces it with blake256(data).
//
// Stack transformation: [... x1] -> [... hash256(x1)]
func opcodeSha256(op *parsedOpcode, vm *Engine) error {
// Stack transformation: [... x1] -> [... blake256(x1)]
func opcodeBlake256(op *parsedOpcode, vm *Engine) error {
buf, err := vm.dstack.PopByteArray()
if err != nil {
return err
Expand All @@ -2348,9 +2348,9 @@ func opcodeSha256(op *parsedOpcode, vm *Engine) error {
}

// opcodeHash160 treats the top item of the data stack as raw bytes and replaces
// it with ripemd160(hash256(data)).
// it with ripemd160(blake256(data)).
//
// Stack transformation: [... x1] -> [... ripemd160(hash256(x1))]
// Stack transformation: [... x1] -> [... ripemd160(blake256(x1))]
func opcodeHash160(op *parsedOpcode, vm *Engine) error {
buf, err := vm.dstack.PopByteArray()
if err != nil {
Expand All @@ -2363,9 +2363,9 @@ func opcodeHash160(op *parsedOpcode, vm *Engine) error {
}

// opcodeHash256 treats the top item of the data stack as raw bytes and replaces
// it with hash256(hash256(data)).
// it with blake256(blake256(data)).
//
// Stack transformation: [... x1] -> [... hash256(hash256(x1))]
// Stack transformation: [... x1] -> [... blake256(blake256(x1))]
func opcodeHash256(op *parsedOpcode, vm *Engine) error {
buf, err := vm.dstack.PopByteArray()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion txscript/opcode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestOpcodeDisasm(t *testing.T) {
0x9f: "OP_LESSTHAN", 0xa0: "OP_GREATERTHAN",
0xa1: "OP_LESSTHANOREQUAL", 0xa2: "OP_GREATERTHANOREQUAL",
0xa3: "OP_MIN", 0xa4: "OP_MAX", 0xa5: "OP_WITHIN",
0xa6: "OP_RIPEMD160", 0xa7: "OP_SHA1", 0xa8: "OP_SHA256",
0xa6: "OP_RIPEMD160", 0xa7: "OP_SHA1", 0xa8: "OP_BLAKE256",
0xa9: "OP_HASH160", 0xaa: "OP_HASH256", 0xab: "OP_CODESEPARATOR",
0xac: "OP_CHECKSIG", 0xad: "OP_CHECKSIGVERIFY",
0xae: "OP_CHECKMULTISIG", 0xaf: "OP_CHECKMULTISIGVERIFY",
Expand Down