Skip to content

Commit

Permalink
Merge pull request #5 from tokenized/develop
Browse files Browse the repository at this point in the history
Technical Standards Committee specification version 1
  • Loading branch information
KarlTheProgrammer committed Mar 15, 2022
2 parents b7366a3 + 511219b commit 0af0532
Show file tree
Hide file tree
Showing 15 changed files with 609 additions and 47 deletions.
3 changes: 1 addition & 2 deletions Makefile
Expand Up @@ -10,11 +10,10 @@ tools:
go get golang.org/x/tools/cmd/goimports

test:
@mkdir tmp || echo "tmp already exists"
go test ./...

format:
goimports -w ./

protoc:
protoc --proto_path=api --go_opt=paths=source_relative --go_out=pkg/golang/envelope/v0/protobuf --js_out=library=protobuf,binary:pkg/typescript/v0 api/envelope.proto
protoc --proto_path=api --go_opt=paths=source_relative --go_out=pkg/golang/envelope/v0/protobuf --js_out=library=protobuf,binary:pkg/typescript/v0 api/envelope.proto --python_out=pkg/python
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -107,7 +107,7 @@ Envelope uses its own integrated encryption scheme because it is designed to be

The `EncryptionType` field of encrypted payload is 0. The `Sender` and `Receivers` fields are used to derive the encryption key.

Direct encryption is a method of encryption using an encryption key that can be derived from the public keys either in the transaction inputs and outputs or referenced by hashes in the inputs and outputs. The encryption key is derived using and a private key for one of those public keys and at least one of those public keys
Direct encryption is a method of encryption using an encryption key that can be derived from the public keys either in the transaction inputs and outputs or referenced by hashes in the inputs and outputs. The encryption key is derived using a private key for one of those public keys and at least one of those public keys.

#### Private

Expand Down
4 changes: 1 addition & 3 deletions go.mod
Expand Up @@ -3,9 +3,7 @@ module github.com/tokenized/envelope
go 1.14

require (
github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e // indirect
github.com/golang/protobuf v1.3.2
github.com/pkg/errors v0.9.1
github.com/tokenized/pkg v0.2.0
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 // indirect
github.com/tokenized/pkg v0.4.0
)
15 changes: 13 additions & 2 deletions go.sum
Expand Up @@ -5,6 +5,7 @@ github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec h1:1Qb69m
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec/go.mod h1:CD8UlnlLDiqb36L110uqiP2iSflVjx9g/3U9hCI4q2U=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/aws/aws-sdk-go v1.31.6/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/aws/aws-sdk-go v1.35.3/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48=
github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw=
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
Expand All @@ -27,11 +28,15 @@ github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/gomodule/redigo v1.8.2/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
Expand All @@ -44,20 +49,22 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/scottjbarr/redis v0.0.1/go.mod h1:HIzxEkRRpIDMZHOU/iavqyd+uQeQwqQncXoYpqJdGgM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/tokenized/pkg v0.2.0 h1:iF4W7SjiqyjaGlHbieN7a9rFSST3vmqEwYIu30+ETbY=
github.com/tokenized/config v0.0.4-0.20220304163631-6373c9a80410/go.mod h1:+8nT8o80nFsxk7Qt5utgfAkEIFNHFtb26hD56hMlSZE=
github.com/tokenized/pkg v0.2.0/go.mod h1:QJIVlpGu5AUytmnjmMGEZGJo59LUOG4xpi/PUN9RLLg=
github.com/tokenized/pkg v0.4.0 h1:htH1pvsWmA4SSN8BxzBGbnxO5lYGP9qG8pCQYBcQjv4=
github.com/tokenized/pkg v0.4.0/go.mod h1:prKrxFdsqeaXEoIQOyke4alF6bptYJP+663XDxlzw6k=
github.com/tyler-smith/go-bip32 v0.0.0-20170922074101-2c9cfd177564 h1:NXXyQVeRVLK8Xu27/hkkjwVOZLk5v4ZBEvvMtqMqznM=
github.com/tyler-smith/go-bip32 v0.0.0-20170922074101-2c9cfd177564/go.mod h1:0/YuQQF676+d4CMNclTqGUam1EDwz0B8o03K9pQqA3c=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
Expand All @@ -83,6 +90,8 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
Expand All @@ -97,6 +106,8 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 h1:Izowp2XBH6Ya6rv+hqbceQyw/gSGoXfH/UPoTGduL54=
launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM=
39 changes: 23 additions & 16 deletions pkg/golang/envelope/envelope.go
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"

v0 "github.com/tokenized/envelope/pkg/golang/envelope/v0"
v1 "github.com/tokenized/envelope/pkg/golang/envelope/v1"
"github.com/tokenized/pkg/bitcoin"

"github.com/pkg/errors"
Expand All @@ -14,7 +15,7 @@ const (
ProtocolIDTokenized = "tokenized"
ProtocolIDTokenizedTest = "test.tokenized"
ProtocolIDFlag = "flag"
ProtocolIDUUID = "uuid" // Protocol id for Universally Unique IDentifiers
ProtocolIDUUID = "uuid" // Protocol ID for Universally Unique IDentifiers
)

var (
Expand All @@ -23,16 +24,11 @@ var (
)

type BaseMessage interface {
EnvelopeVersion() uint8 // Envelope protocol version
PayloadProtocol() []byte // Protocol ID of payload. (recommended to be ascii text)
PayloadVersion() uint64 // Protocol specific version for the payload.
PayloadType() []byte // Data type of payload.
PayloadIdentifier() []byte // Protocol specific identifier for the payload. (i.e. message type, data name)
Payload() []byte
EnvelopeVersion() uint8 // Envelope protocol version
PayloadProtocols() [][]byte // Protocol IDs of payloads. (recommended to be ascii text)

SetPayloadType([]byte)

SetPayloadIdentifier([]byte)
PayloadCount() int
PayloadAt(offset int) []byte

// Serialize creates an OP_RETURN script in the "envelope" format containing the specified data.
Serialize(buf *bytes.Buffer) error
Expand All @@ -50,7 +46,7 @@ func Deserialize(buf *bytes.Reader) (BaseMessage, error) {

b, err = buf.ReadByte()
if err != nil {
return nil, errors.Wrap(err, "Failed to read op return")
return nil, errors.Wrap(err, "read op return")
}

if b != bitcoin.OP_RETURN {
Expand All @@ -60,7 +56,7 @@ func Deserialize(buf *bytes.Reader) (BaseMessage, error) {

b, err = buf.ReadByte()
if err != nil {
return nil, errors.Wrap(err, "Failed to read op return")
return nil, errors.Wrap(err, "read op return")
}

if b != bitcoin.OP_RETURN {
Expand All @@ -71,20 +67,31 @@ func Deserialize(buf *bytes.Reader) (BaseMessage, error) {
// Envelope Protocol ID
_, protocolID, err := bitcoin.ParsePushDataScript(buf)
if err != nil {
return nil, errors.Wrap(err, "Failed to parse protocol ID")
return nil, errors.Wrap(err, "parse protocol ID")
}
if len(protocolID) != 2 {
return nil, ErrNotEnvelope
}
if protocolID[0] != 0xbd {
return nil, ErrNotEnvelope
}
if protocolID[1] != 0 {

// Version 0 for backwards compatibility
if protocolID[1] == 0 {
result, err := v0.Deserialize(buf)
if err == v0.ErrNotEnvelope {
return nil, ErrNotEnvelope
}
return result, err
}

if protocolID[1] != 1 {
return nil, ErrUnknownVersion
}

result, err := v0.Deserialize(buf)
if err == v0.ErrNotEnvelope {
// Version 1
result, err := v1.Deserialize(buf)
if err == v1.ErrNotEnvelope {
return nil, ErrNotEnvelope
}
return result, err
Expand Down
Expand Up @@ -67,25 +67,35 @@ func TestRetention(t *testing.T) {
}

reader := bytes.NewReader(buf.Bytes())
read, err := Deserialize(reader)
readBase, err := Deserialize(reader)
if err != nil {
t.Fatalf("Test %d Failed Deserialize : %s", i, err)
}

read, ok := readBase.(*v0.Message)
if !ok {
t.Fatalf("Wrong message type")
}

if !bytes.Equal(test.protocol, read.PayloadProtocol()) {
t.Fatalf("Test %d protocol wasn't retained : want 0x%x, got 0x%x", i+1, test.protocol, read.PayloadProtocol())
t.Fatalf("Test %d protocol wasn't retained : want 0x%x, got 0x%x", i+1, test.protocol,
read.PayloadProtocol())
}
if test.version != read.PayloadVersion() {
t.Fatalf("Test %d version wasn't retained : want %d, got %d", i+1, test.version, read.PayloadVersion())
t.Fatalf("Test %d version wasn't retained : want %d, got %d", i+1, test.version,
read.PayloadVersion())
}
if !bytes.Equal(test.payloadType, read.PayloadType()) {
t.Fatalf("Test %d payload type wasn't retained : want 0x%x, got 0x%x", i+1, test.payloadType, read.PayloadType())
t.Fatalf("Test %d payload type wasn't retained : want 0x%x, got 0x%x", i+1,
test.payloadType, read.PayloadType())
}
if !bytes.Equal(test.identifier, read.PayloadIdentifier()) {
t.Fatalf("Test %d identifier wasn't retained : want 0x%x, got 0x%x", i+1, test.identifier, read.PayloadIdentifier())
t.Fatalf("Test %d identifier wasn't retained : want 0x%x, got 0x%x", i+1,
test.identifier, read.PayloadIdentifier())
}
if !bytes.Equal(test.payload, read.Payload()) {
t.Fatalf("Test %d payload wasn't retained : want 0x%x, got 0x%x", i+1, test.payload, read.Payload())
t.Fatalf("Test %d payload wasn't retained : want 0x%x, got 0x%x", i+1, test.payload,
read.Payload())
}
}
}
Expand Down Expand Up @@ -421,7 +431,7 @@ func addFakeInput(tx *wire.MsgTx, key bitcoin.Key) error {
return err
}
tx.TxIn = append(tx.TxIn, &wire.TxIn{
SignatureScript: fakeScriptBuf.Bytes(),
UnlockingScript: fakeScriptBuf.Bytes(),
Sequence: 0xffffffff,
})
return nil
Expand All @@ -446,8 +456,8 @@ func addFakeOutput(tx *wire.MsgTx, key bitcoin.Key) error {
return err
}
tx.TxOut = append(tx.TxOut, &wire.TxOut{
PkScript: script,
Value: 100,
LockingScript: script,
Value: 100,
})
return nil
}
83 changes: 83 additions & 0 deletions pkg/golang/envelope/envelope_v1_test.go
@@ -0,0 +1,83 @@
package envelope

import (
"bytes"
"testing"

v1 "github.com/tokenized/envelope/pkg/golang/envelope/v1"
)

var v1RetentionTests = []struct {
protocolIDs [][]byte
payloads [][]byte
}{
{
protocolIDs: [][]byte{[]byte("tokenized")},
payloads: [][]byte{[]byte("T1"), []byte("Test data 1")},
},
{
protocolIDs: [][]byte{[]byte("test")},
payloads: [][]byte{[]byte("5")},
},
{
protocolIDs: [][]byte{[]byte{0xbe, 0xef}},
payloads: nil,
},
{
protocolIDs: [][]byte{[]byte{0xbe, 0xef}},
payloads: nil,
},
}

func TestRetentionV1(t *testing.T) {
for i, test := range v1RetentionTests {
message := v1.NewMessage(test.protocolIDs, test.payloads)

var buf bytes.Buffer
err := message.Serialize(&buf)
if err != nil {
t.Fatalf("Test %d Failed Serialize : %s", i, err)
}

reader := bytes.NewReader(buf.Bytes())
readBase, err := Deserialize(reader)
if err != nil {
t.Fatalf("Test %d Failed Deserialize : %s", i, err)
}

read, ok := readBase.(*v1.Message)
if !ok {
t.Fatalf("Wrong message type")
}

protocolIDs := read.PayloadProtocols()
if len(protocolIDs) != len(test.protocolIDs) {
t.Fatalf("Wrong protocol ID count : got %d, want %d", len(protocolIDs),
len(test.protocolIDs))
}

payloadCount := read.PayloadCount()
if payloadCount != len(test.payloads) {
t.Fatalf("Wrong payload count : got %d, want %d", payloadCount, len(test.payloads))
}

for i, protocolID := range protocolIDs {
if !bytes.Equal(protocolID, test.protocolIDs[i]) {
t.Errorf("Wrong protocol ID %d : \ngot : %x\nwant : %x", i, protocolID,
test.protocolIDs[i])
}

t.Logf("Verified protocol ID %d : %x", i, protocolID)
}

for i := 0; i < payloadCount; i++ {
payload := read.PayloadAt(i)
if !bytes.Equal(payload, test.payloads[i]) {
t.Errorf("Wrong payload %d : \ngot : %x\nwant : %x", i, payload,
test.payloads[i])
}

t.Logf("Verified payload %d : %x", i, payload)
}
}
}
12 changes: 6 additions & 6 deletions pkg/golang/envelope/v0/decryption.go
Expand Up @@ -24,7 +24,7 @@ func (ep *EncryptedPayload) SenderPublicKey(tx *wire.MsgTx) (bitcoin.PublicKey,
len(tx.TxIn))
}

spk, err := bitcoin.PublicKeyFromUnlockingScript(tx.TxIn[ep.sender].SignatureScript)
spk, err := bitcoin.PublicKeyFromUnlockingScript(tx.TxIn[ep.sender].UnlockingScript)
if err != nil {
return bitcoin.PublicKey{}, err
}
Expand All @@ -40,7 +40,7 @@ func (ep *EncryptedPayload) ReceiverAddresses(tx *wire.MsgTx) ([]bitcoin.RawAddr
len(tx.TxOut))
}

ra, err := bitcoin.RawAddressFromLockingScript(tx.TxOut[receiver.index].PkScript)
ra, err := bitcoin.RawAddressFromLockingScript(tx.TxOut[receiver.index].LockingScript)
if err != nil {
continue
}
Expand Down Expand Up @@ -76,7 +76,7 @@ func (ep *EncryptedPayload) SenderDecryptKey(tx *wire.MsgTx, senderKey bitcoin.K
return nil, bitcoin.Hash32{}, errors.New("Sender index out of range")
}

senderPubKeyData, err := bitcoin.PublicKeyFromUnlockingScript(tx.TxIn[ep.sender].SignatureScript)
senderPubKeyData, err := bitcoin.PublicKeyFromUnlockingScript(tx.TxIn[ep.sender].UnlockingScript)
if err != nil {
return nil, bitcoin.Hash32{}, err
}
Expand Down Expand Up @@ -107,7 +107,7 @@ func (ep *EncryptedPayload) SenderDecryptKey(tx *wire.MsgTx, senderKey bitcoin.K
continue
}

rawAddress, err := bitcoin.RawAddressFromLockingScript(tx.TxOut[receiver.index].PkScript)
rawAddress, err := bitcoin.RawAddressFromLockingScript(tx.TxOut[receiver.index].LockingScript)
if err != nil {
continue
}
Expand Down Expand Up @@ -185,7 +185,7 @@ func (ep *EncryptedPayload) ReceiverDecryptKey(tx *wire.MsgTx, receiverKey bitco
return nil, bitcoin.Hash32{}, errors.New("Sender index out of range")
}

senderPubKeyData, err := bitcoin.PublicKeyFromUnlockingScript(tx.TxIn[ep.sender].SignatureScript)
senderPubKeyData, err := bitcoin.PublicKeyFromUnlockingScript(tx.TxIn[ep.sender].UnlockingScript)
if err != nil {
return nil, bitcoin.Hash32{}, err
}
Expand All @@ -203,7 +203,7 @@ func (ep *EncryptedPayload) ReceiverDecryptKey(tx *wire.MsgTx, receiverKey bitco
continue
}

rawAddress, err := bitcoin.RawAddressFromLockingScript(tx.TxOut[receiver.index].PkScript)
rawAddress, err := bitcoin.RawAddressFromLockingScript(tx.TxOut[receiver.index].LockingScript)
if err != nil {
continue
}
Expand Down

0 comments on commit 0af0532

Please sign in to comment.