Skip to content

Commit 64311bc

Browse files
committed
Use ASN1DER for TxID hashing instead of Protobuf
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 <[email protected]>
1 parent 9de36e3 commit 64311bc

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

bddtests/peer_basic.feature

+1-3
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,6 @@ Feature: Network of Peers
349349

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

371369
Scenario: chaincode example 01 single peer rejection message
372370
Given we compose "docker-compose-1-exp.yml"

core/devops.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func (d *Devops) invokeOrQuery(ctx context.Context, chaincodeInvocationSpec *pb.
215215
var generr error
216216
if invoke {
217217
if customIDgenAlg != "" {
218-
ctorbytes, merr := proto.Marshal(chaincodeInvocationSpec.ChaincodeSpec.CtorMsg)
218+
ctorbytes, merr := asn1.Marshal(*chaincodeInvocationSpec.ChaincodeSpec.CtorMsg)
219219
if merr != nil {
220220
return nil, fmt.Errorf("Error marshalling constructor: %s", merr)
221221
}
@@ -456,7 +456,7 @@ func (d *Devops) EXP_ExecuteWithBinding(ctx context.Context, executeWithBinding
456456
return &pb.Response{Status: pb.Response_FAILURE, Msg: []byte(err.Error())}, nil
457457
}
458458

459-
ctorbytes, merr := proto.Marshal(executeWithBinding.ChaincodeInvocationSpec.ChaincodeSpec.CtorMsg)
459+
ctorbytes, merr := asn1.Marshal(*executeWithBinding.ChaincodeInvocationSpec.ChaincodeSpec.CtorMsg)
460460
if merr != nil {
461461
return nil, fmt.Errorf("Error marshalling constructor: %s", err)
462462
}

0 commit comments

Comments
 (0)