txscript: Rename OP_SHA256 to OP_BLAKE256.

Decred updated the semantics of this opcode to use blake256, but did not
rename the opcode to reflect that.  This renames the opcode so that it
is clear that a blake256 hash is produced instead of a sha256 hash.
This commit is contained in:
Dave Collins 2017-09-07 18:31:29 -05:00
parent 5115a422f0
commit 7c3ff8279e
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2
5 changed files with 24 additions and 24 deletions

View File

@ -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"],
@ -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"],

View File

@ -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"],
@ -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"],

View File

@ -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,

View File

@ -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
@ -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
@ -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.
@ -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
@ -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 {
@ -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 {

View File

@ -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",