Skip to content

Commit

Permalink
Use ASN1DER for TxID hashing instead of Protobuf
Browse files Browse the repository at this point in the history
It is not guaranteed that Protobuf encoding will always generate the
same bytes for the same structure. This could lead to different hashes
for the same object that's why we should use ASN1 DER (which will surely
generate the same bytes).


Change-Id: I75420e8436fb8144490e3801c51886062a0bd2a4
Signed-off-by: Gabor Hosszu <gabor@digitalasset.com>
  • Loading branch information
gaborh-da committed Aug 22, 2016
1 parent 9de36e3 commit 64311bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions bddtests/peer_basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,6 @@ Feature: Network of Peers

# @doNotDecompose
# @wip
# sha256 = '53a54f606b9cc14ae2825cc50736b183cf8d6fd0131b9d3176997efcf77d775f'
# calculated using all the args
Scenario: chaincode map single peer content generated ID
Given we compose "docker-compose-1.yml"
When requesting "/chain" from "vp0"
Expand All @@ -366,7 +364,7 @@ Feature: Network of Peers
| a | 10 |
Then I should have received a transactionID
Then I wait up to "25" seconds for transaction to be committed to all peers
Then I check the transaction ID if it is "a97267efe0391a5c0be28f79e8cb7f841aca1b952f028ec796b61c92aef6936c"
Then I check the transaction ID if it is "73b88d92d86502eb66288f84fafae848fed0d21790f2ef1475850f4b635c47f0"

Scenario: chaincode example 01 single peer rejection message
Given we compose "docker-compose-1-exp.yml"
Expand Down
4 changes: 2 additions & 2 deletions core/devops.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (d *Devops) invokeOrQuery(ctx context.Context, chaincodeInvocationSpec *pb.
var generr error
if invoke {
if customIDgenAlg != "" {
ctorbytes, merr := proto.Marshal(chaincodeInvocationSpec.ChaincodeSpec.CtorMsg)
ctorbytes, merr := asn1.Marshal(*chaincodeInvocationSpec.ChaincodeSpec.CtorMsg)
if merr != nil {
return nil, fmt.Errorf("Error marshalling constructor: %s", merr)
}
Expand Down Expand Up @@ -456,7 +456,7 @@ func (d *Devops) EXP_ExecuteWithBinding(ctx context.Context, executeWithBinding
return &pb.Response{Status: pb.Response_FAILURE, Msg: []byte(err.Error())}, nil
}

ctorbytes, merr := proto.Marshal(executeWithBinding.ChaincodeInvocationSpec.ChaincodeSpec.CtorMsg)
ctorbytes, merr := asn1.Marshal(*executeWithBinding.ChaincodeInvocationSpec.ChaincodeSpec.CtorMsg)
if merr != nil {
return nil, fmt.Errorf("Error marshalling constructor: %s", err)
}
Expand Down

0 comments on commit 64311bc

Please sign in to comment.