Skip to content

Commit 22ec03f

Browse files
author
Srinivasan Muralidharan
committed
remove remaining security fields from chaincode.proto
https://jira.hyperledger.org/browse/FAB-1722 Change-Id: I1f8466f7eae6b290c13606e67c6c05dcf4068f8c Signed-off-by: Srinivasan Muralidharan <[email protected]>
1 parent 81d5152 commit 22ec03f

File tree

8 files changed

+124
-188
lines changed

8 files changed

+124
-188
lines changed

examples/chaincode/go/asset_management_interactive/app1/app1_internal.go

+14-25
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ import (
3838
var (
3939
confidentialityOn bool
4040

41-
confidentialityLevel pb.ConfidentialityLevel
42-
chaincodeName string
41+
chaincodeName string
4342
)
4443

4544
func initNVP() (err error) {
@@ -121,12 +120,6 @@ func processTransaction(tx *pb.Transaction) (*pb.Response, error) {
121120

122121
func confidentiality(enabled bool) {
123122
confidentialityOn = enabled
124-
125-
if confidentialityOn {
126-
confidentialityLevel = pb.ConfidentialityLevel_CONFIDENTIAL
127-
} else {
128-
confidentialityLevel = pb.ConfidentialityLevel_PUBLIC
129-
}
130123
}
131124

132125
func deployInternal(deployer crypto.Client, adminCert crypto.CertificateHandler) (resp *pb.Response, err error) {
@@ -135,9 +128,8 @@ func deployInternal(deployer crypto.Client, adminCert crypto.CertificateHandler)
135128
Type: 1,
136129
ChaincodeID: &pb.ChaincodeID{Path: "github.com/hyperledger/fabric/examples/chaincode/go/asset_management"},
137130
//ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
138-
Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("init")},
139-
Metadata: adminCert.GetCertificate(),
140-
ConfidentialityLevel: confidentialityLevel,
131+
Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("init")},
132+
Metadata: adminCert.GetCertificate(),
141133
}
142134

143135
// First build the deployment spec
@@ -194,11 +186,10 @@ func assignOwnershipInternal(invoker crypto.Client, invokerCert crypto.Certifica
194186

195187
// Prepare spec and submit
196188
spec := &pb.ChaincodeSpec{
197-
Type: 1,
198-
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
199-
CtorMsg: chaincodeInput,
200-
Metadata: sigma, // Proof of identity
201-
ConfidentialityLevel: confidentialityLevel,
189+
Type: 1,
190+
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
191+
CtorMsg: chaincodeInput,
192+
Metadata: sigma, // Proof of identity
202193
}
203194

204195
chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec}
@@ -245,11 +236,10 @@ func transferOwnershipInternal(owner crypto.Client, ownerCert crypto.Certificate
245236

246237
// Prepare spec and submit
247238
spec := &pb.ChaincodeSpec{
248-
Type: 1,
249-
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
250-
CtorMsg: chaincodeInput,
251-
Metadata: sigma, // Proof of identity
252-
ConfidentialityLevel: confidentialityLevel,
239+
Type: 1,
240+
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
241+
CtorMsg: chaincodeInput,
242+
Metadata: sigma, // Proof of identity
253243
}
254244

255245
chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec}
@@ -269,10 +259,9 @@ func whoIsTheOwner(invoker crypto.Client, asset string) (transaction *pb.Transac
269259

270260
// Prepare spec and submit
271261
spec := &pb.ChaincodeSpec{
272-
Type: 1,
273-
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
274-
CtorMsg: chaincodeInput,
275-
ConfidentialityLevel: confidentialityLevel,
262+
Type: 1,
263+
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
264+
CtorMsg: chaincodeInput,
276265
}
277266

278267
chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec}

examples/chaincode/go/asset_management_interactive/app2/app2_internal.go

+14-25
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ import (
4242
var (
4343
confidentialityOn bool
4444

45-
confidentialityLevel pb.ConfidentialityLevel
46-
chaincodeName string
45+
chaincodeName string
4746
)
4847

4948
func initNVP() (err error) {
@@ -195,12 +194,6 @@ func processTransaction(tx *pb.Transaction) (*pb.Response, error) {
195194

196195
func confidentiality(enabled bool) {
197196
confidentialityOn = enabled
198-
199-
if confidentialityOn {
200-
confidentialityLevel = pb.ConfidentialityLevel_CONFIDENTIAL
201-
} else {
202-
confidentialityLevel = pb.ConfidentialityLevel_PUBLIC
203-
}
204197
}
205198

206199
func deployInternal(deployer crypto.Client, adminCert crypto.CertificateHandler) (resp *pb.Response, err error) {
@@ -209,9 +202,8 @@ func deployInternal(deployer crypto.Client, adminCert crypto.CertificateHandler)
209202
Type: 1,
210203
ChaincodeID: &pb.ChaincodeID{Path: "github.com/hyperledger/fabric/examples/chaincode/go/asset_management"},
211204
//ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
212-
Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("init")},
213-
Metadata: adminCert.GetCertificate(),
214-
ConfidentialityLevel: confidentialityLevel,
205+
Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("init")},
206+
Metadata: adminCert.GetCertificate(),
215207
}
216208

217209
// First build the deployment spec
@@ -268,11 +260,10 @@ func assignOwnershipInternal(invoker crypto.Client, invokerCert crypto.Certifica
268260

269261
// Prepare spec and submit
270262
spec := &pb.ChaincodeSpec{
271-
Type: 1,
272-
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
273-
Input: chaincodeInput,
274-
Metadata: sigma, // Proof of identity
275-
ConfidentialityLevel: confidentialityLevel,
263+
Type: 1,
264+
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
265+
Input: chaincodeInput,
266+
Metadata: sigma, // Proof of identity
276267
}
277268

278269
chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec}
@@ -319,11 +310,10 @@ func transferOwnershipInternal(owner crypto.Client, ownerCert crypto.Certificate
319310

320311
// Prepare spec and submit
321312
spec := &pb.ChaincodeSpec{
322-
Type: 1,
323-
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
324-
Input: chaincodeInput,
325-
Metadata: sigma, // Proof of identity
326-
ConfidentialityLevel: confidentialityLevel,
313+
Type: 1,
314+
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
315+
Input: chaincodeInput,
316+
Metadata: sigma, // Proof of identity
327317
}
328318

329319
chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec}
@@ -343,10 +333,9 @@ func whoIsTheOwner(invoker crypto.Client, asset string) (transaction *pb.Transac
343333

344334
// Prepare spec and submit
345335
spec := &pb.ChaincodeSpec{
346-
Type: 1,
347-
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
348-
Input: chaincodeInput,
349-
ConfidentialityLevel: confidentialityLevel,
336+
Type: 1,
337+
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
338+
Input: chaincodeInput,
350339
}
351340

352341
chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec}

examples/chaincode/go/asset_management_interactive/app3/app3_internal.go

+15-26
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ import (
4242
var (
4343
confidentialityOn bool
4444

45-
confidentialityLevel pb.ConfidentialityLevel
46-
chaincodeName string
47-
user string
45+
chaincodeName string
46+
user string
4847
)
4948

5049
func initNVP() (err error) {
@@ -183,12 +182,6 @@ func processTransaction(tx *pb.Transaction) (*pb.Response, error) {
183182

184183
func confidentiality(enabled bool) {
185184
confidentialityOn = enabled
186-
187-
if confidentialityOn {
188-
confidentialityLevel = pb.ConfidentialityLevel_CONFIDENTIAL
189-
} else {
190-
confidentialityLevel = pb.ConfidentialityLevel_PUBLIC
191-
}
192185
}
193186

194187
func deployInternal(deployer crypto.Client, adminCert crypto.CertificateHandler) (resp *pb.Response, err error) {
@@ -197,9 +190,8 @@ func deployInternal(deployer crypto.Client, adminCert crypto.CertificateHandler)
197190
Type: 1,
198191
ChaincodeID: &pb.ChaincodeID{Path: "github.com/hyperledger/fabric/examples/chaincode/go/asset_management"},
199192
//ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
200-
Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("init")},
201-
Metadata: adminCert.GetCertificate(),
202-
ConfidentialityLevel: confidentialityLevel,
193+
Input: &pb.ChaincodeInput{Args: util.ToChaincodeArgs("init")},
194+
Metadata: adminCert.GetCertificate(),
203195
}
204196

205197
// First build the deployment spec
@@ -256,11 +248,10 @@ func assignOwnershipInternal(invoker crypto.Client, invokerCert crypto.Certifica
256248

257249
// Prepare spec and submit
258250
spec := &pb.ChaincodeSpec{
259-
Type: 1,
260-
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
261-
Input: chaincodeInput,
262-
Metadata: sigma, // Proof of identity
263-
ConfidentialityLevel: confidentialityLevel,
251+
Type: 1,
252+
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
253+
Input: chaincodeInput,
254+
Metadata: sigma, // Proof of identity
264255
}
265256

266257
chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec}
@@ -307,11 +298,10 @@ func transferOwnershipInternal(owner crypto.Client, ownerCert crypto.Certificate
307298

308299
// Prepare spec and submit
309300
spec := &pb.ChaincodeSpec{
310-
Type: 1,
311-
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
312-
Input: chaincodeInput,
313-
Metadata: sigma, // Proof of identity
314-
ConfidentialityLevel: confidentialityLevel,
301+
Type: 1,
302+
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
303+
Input: chaincodeInput,
304+
Metadata: sigma, // Proof of identity
315305
}
316306

317307
chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec}
@@ -331,10 +321,9 @@ func whoIsTheOwner(invoker crypto.Client, asset string) (transaction *pb.Transac
331321

332322
// Prepare spec and submit
333323
spec := &pb.ChaincodeSpec{
334-
Type: 1,
335-
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
336-
Input: chaincodeInput,
337-
ConfidentialityLevel: confidentialityLevel,
324+
Type: 1,
325+
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
326+
Input: chaincodeInput,
338327
}
339328

340329
chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec}

peer/chaincode/chaincode.go

+9-12
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ func AddFlags(cmd *cobra.Command) {
3838
fmt.Sprintf("Language the %s is written in", chainFuncName))
3939
flags.StringVarP(&chaincodeCtorJSON, "ctor", "c", "{}",
4040
fmt.Sprintf("Constructor message for the %s in JSON format", chainFuncName))
41-
flags.StringVarP(&chaincodeAttributesJSON, "attributes", "a", "[]",
42-
fmt.Sprintf("User attributes for the %s in JSON format", chainFuncName))
4341
flags.StringVarP(&chaincodePath, "path", "p", common.UndefinedParamValue,
4442
fmt.Sprintf("Path to %s", chainFuncName))
4543
flags.StringVarP(&chaincodeName, "name", "n", common.UndefinedParamValue,
@@ -66,16 +64,15 @@ func Cmd(cf *ChaincodeCmdFactory) *cobra.Command {
6664

6765
// Chaincode-related variables.
6866
var (
69-
chaincodeLang string
70-
chaincodeCtorJSON string
71-
chaincodePath string
72-
chaincodeName string
73-
chaincodeUsr string
74-
chaincodeQueryRaw bool
75-
chaincodeQueryHex bool
76-
chaincodeAttributesJSON string
77-
customIDGenAlg string
78-
chainID string
67+
chaincodeLang string
68+
chaincodeCtorJSON string
69+
chaincodePath string
70+
chaincodeName string
71+
chaincodeUsr string
72+
chaincodeQueryRaw bool
73+
chaincodeQueryHex bool
74+
customIDGenAlg string
75+
chainID string
7976
)
8077

8178
var chaincodeCmd = &cobra.Command{

peer/chaincode/common.go

-14
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,11 @@ func getChaincodeSpecification(cmd *cobra.Command) (*pb.ChaincodeSpec, error) {
8484
return spec, fmt.Errorf("Chaincode argument error: %s", err)
8585
}
8686

87-
var attributes []string
88-
if err := json.Unmarshal([]byte(chaincodeAttributesJSON), &attributes); err != nil {
89-
return spec, fmt.Errorf("Chaincode argument error: %s", err)
90-
}
91-
9287
chaincodeLang = strings.ToUpper(chaincodeLang)
9388
spec = &pb.ChaincodeSpec{
9489
Type: pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value[chaincodeLang]),
9590
ChaincodeID: &pb.ChaincodeID{Path: chaincodePath, Name: chaincodeName},
9691
Input: input,
97-
Attributes: attributes,
9892
}
9993
return spec, nil
10094
}
@@ -166,14 +160,6 @@ func checkChaincodeCmdParams(cmd *cobra.Command) error {
166160
return errors.New("Empty JSON chaincode parameters must contain the following keys: 'Args' or 'Function' and 'Args'")
167161
}
168162

169-
if chaincodeAttributesJSON != "[]" {
170-
var f interface{}
171-
err := json.Unmarshal([]byte(chaincodeAttributesJSON), &f)
172-
if err != nil {
173-
return fmt.Errorf("Chaincode argument error: %s", err)
174-
}
175-
}
176-
177163
return nil
178164
}
179165

peer/chaincode/common_test.go

-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
)
2626

2727
func TestCheckChaincodeCmdParamsWithNewCallingSchema(t *testing.T) {
28-
chaincodeAttributesJSON = "[]"
2928
chaincodeCtorJSON = `{ "Args":["func", "param"] }`
3029
chaincodePath = "some/path"
3130
chaincodeName = "somename"
@@ -36,7 +35,6 @@ func TestCheckChaincodeCmdParamsWithNewCallingSchema(t *testing.T) {
3635
}
3736

3837
func TestCheckChaincodeCmdParamsWithOldCallingSchema(t *testing.T) {
39-
chaincodeAttributesJSON = "[]"
4038
chaincodeCtorJSON = `{ "Function":"func", "Args":["param"] }`
4139
chaincodePath = "some/path"
4240
chaincodeName = "somename"
@@ -47,7 +45,6 @@ func TestCheckChaincodeCmdParamsWithOldCallingSchema(t *testing.T) {
4745
}
4846

4947
func TestCheckChaincodeCmdParamsWithoutName(t *testing.T) {
50-
chaincodeAttributesJSON = "[]"
5148
chaincodeCtorJSON = `{ "Function":"func", "Args":["param"] }`
5249
chaincodePath = "some/path"
5350
chaincodeName = ""
@@ -58,7 +55,6 @@ func TestCheckChaincodeCmdParamsWithoutName(t *testing.T) {
5855
}
5956

6057
func TestCheckChaincodeCmdParamsWithFunctionOnly(t *testing.T) {
61-
chaincodeAttributesJSON = "[]"
6258
chaincodeCtorJSON = `{ "Function":"func" }`
6359
chaincodePath = "some/path"
6460
chaincodeName = "somename"
@@ -69,7 +65,6 @@ func TestCheckChaincodeCmdParamsWithFunctionOnly(t *testing.T) {
6965
}
7066

7167
func TestCheckChaincodeCmdParamsEmptyCtor(t *testing.T) {
72-
chaincodeAttributesJSON = "[]"
7368
chaincodeCtorJSON = `{}`
7469
chaincodePath = "some/path"
7570
chaincodeName = "somename"

0 commit comments

Comments
 (0)