From 64311bc1ab9b71622817559b6895698a835ccfcc Mon Sep 17 00:00:00 2001 From: Gabor Hosszu Date: Thu, 18 Aug 2016 10:51:09 +0200 Subject: [PATCH] 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 --- bddtests/peer_basic.feature | 4 +--- core/devops.go | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/bddtests/peer_basic.feature b/bddtests/peer_basic.feature index 80ed9f548ec..2d88bf93575 100644 --- a/bddtests/peer_basic.feature +++ b/bddtests/peer_basic.feature @@ -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" @@ -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" diff --git a/core/devops.go b/core/devops.go index 3b65c01ddbe..497f9a44c58 100644 --- a/core/devops.go +++ b/core/devops.go @@ -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) } @@ -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) }