Skip to content

Commit

Permalink
remove remaining security fields from chaincode.proto
Browse files Browse the repository at this point in the history
https://jira.hyperledger.org/browse/FAB-1722

Change-Id: I1f8466f7eae6b290c13606e67c6c05dcf4068f8c
Signed-off-by: Srinivasan Muralidharan <muralisr@us.ibm.com>
  • Loading branch information
Srinivasan Muralidharan committed Jan 18, 2017
1 parent 81d5152 commit 22ec03f
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ import (
var (
confidentialityOn bool

confidentialityLevel pb.ConfidentialityLevel
chaincodeName string
chaincodeName string
)

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

func confidentiality(enabled bool) {
confidentialityOn = enabled

if confidentialityOn {
confidentialityLevel = pb.ConfidentialityLevel_CONFIDENTIAL
} else {
confidentialityLevel = pb.ConfidentialityLevel_PUBLIC
}
}

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

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

// Prepare spec and submit
spec := &pb.ChaincodeSpec{
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
CtorMsg: chaincodeInput,
Metadata: sigma, // Proof of identity
ConfidentialityLevel: confidentialityLevel,
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
CtorMsg: chaincodeInput,
Metadata: sigma, // Proof of identity
}

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

// Prepare spec and submit
spec := &pb.ChaincodeSpec{
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
CtorMsg: chaincodeInput,
Metadata: sigma, // Proof of identity
ConfidentialityLevel: confidentialityLevel,
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
CtorMsg: chaincodeInput,
Metadata: sigma, // Proof of identity
}

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

// Prepare spec and submit
spec := &pb.ChaincodeSpec{
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
CtorMsg: chaincodeInput,
ConfidentialityLevel: confidentialityLevel,
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
CtorMsg: chaincodeInput,
}

chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ import (
var (
confidentialityOn bool

confidentialityLevel pb.ConfidentialityLevel
chaincodeName string
chaincodeName string
)

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

func confidentiality(enabled bool) {
confidentialityOn = enabled

if confidentialityOn {
confidentialityLevel = pb.ConfidentialityLevel_CONFIDENTIAL
} else {
confidentialityLevel = pb.ConfidentialityLevel_PUBLIC
}
}

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

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

// Prepare spec and submit
spec := &pb.ChaincodeSpec{
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
Input: chaincodeInput,
Metadata: sigma, // Proof of identity
ConfidentialityLevel: confidentialityLevel,
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
Input: chaincodeInput,
Metadata: sigma, // Proof of identity
}

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

// Prepare spec and submit
spec := &pb.ChaincodeSpec{
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
Input: chaincodeInput,
Metadata: sigma, // Proof of identity
ConfidentialityLevel: confidentialityLevel,
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
Input: chaincodeInput,
Metadata: sigma, // Proof of identity
}

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

// Prepare spec and submit
spec := &pb.ChaincodeSpec{
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
Input: chaincodeInput,
ConfidentialityLevel: confidentialityLevel,
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
Input: chaincodeInput,
}

chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ import (
var (
confidentialityOn bool

confidentialityLevel pb.ConfidentialityLevel
chaincodeName string
user string
chaincodeName string
user string
)

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

func confidentiality(enabled bool) {
confidentialityOn = enabled

if confidentialityOn {
confidentialityLevel = pb.ConfidentialityLevel_CONFIDENTIAL
} else {
confidentialityLevel = pb.ConfidentialityLevel_PUBLIC
}
}

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

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

// Prepare spec and submit
spec := &pb.ChaincodeSpec{
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
Input: chaincodeInput,
Metadata: sigma, // Proof of identity
ConfidentialityLevel: confidentialityLevel,
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
Input: chaincodeInput,
Metadata: sigma, // Proof of identity
}

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

// Prepare spec and submit
spec := &pb.ChaincodeSpec{
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
Input: chaincodeInput,
Metadata: sigma, // Proof of identity
ConfidentialityLevel: confidentialityLevel,
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
Input: chaincodeInput,
Metadata: sigma, // Proof of identity
}

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

// Prepare spec and submit
spec := &pb.ChaincodeSpec{
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
Input: chaincodeInput,
ConfidentialityLevel: confidentialityLevel,
Type: 1,
ChaincodeID: &pb.ChaincodeID{Name: chaincodeName},
Input: chaincodeInput,
}

chaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: spec}
Expand Down
21 changes: 9 additions & 12 deletions peer/chaincode/chaincode.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ func AddFlags(cmd *cobra.Command) {
fmt.Sprintf("Language the %s is written in", chainFuncName))
flags.StringVarP(&chaincodeCtorJSON, "ctor", "c", "{}",
fmt.Sprintf("Constructor message for the %s in JSON format", chainFuncName))
flags.StringVarP(&chaincodeAttributesJSON, "attributes", "a", "[]",
fmt.Sprintf("User attributes for the %s in JSON format", chainFuncName))
flags.StringVarP(&chaincodePath, "path", "p", common.UndefinedParamValue,
fmt.Sprintf("Path to %s", chainFuncName))
flags.StringVarP(&chaincodeName, "name", "n", common.UndefinedParamValue,
Expand All @@ -66,16 +64,15 @@ func Cmd(cf *ChaincodeCmdFactory) *cobra.Command {

// Chaincode-related variables.
var (
chaincodeLang string
chaincodeCtorJSON string
chaincodePath string
chaincodeName string
chaincodeUsr string
chaincodeQueryRaw bool
chaincodeQueryHex bool
chaincodeAttributesJSON string
customIDGenAlg string
chainID string
chaincodeLang string
chaincodeCtorJSON string
chaincodePath string
chaincodeName string
chaincodeUsr string
chaincodeQueryRaw bool
chaincodeQueryHex bool
customIDGenAlg string
chainID string
)

var chaincodeCmd = &cobra.Command{
Expand Down
14 changes: 0 additions & 14 deletions peer/chaincode/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,11 @@ func getChaincodeSpecification(cmd *cobra.Command) (*pb.ChaincodeSpec, error) {
return spec, fmt.Errorf("Chaincode argument error: %s", err)
}

var attributes []string
if err := json.Unmarshal([]byte(chaincodeAttributesJSON), &attributes); err != nil {
return spec, fmt.Errorf("Chaincode argument error: %s", err)
}

chaincodeLang = strings.ToUpper(chaincodeLang)
spec = &pb.ChaincodeSpec{
Type: pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value[chaincodeLang]),
ChaincodeID: &pb.ChaincodeID{Path: chaincodePath, Name: chaincodeName},
Input: input,
Attributes: attributes,
}
return spec, nil
}
Expand Down Expand Up @@ -166,14 +160,6 @@ func checkChaincodeCmdParams(cmd *cobra.Command) error {
return errors.New("Empty JSON chaincode parameters must contain the following keys: 'Args' or 'Function' and 'Args'")
}

if chaincodeAttributesJSON != "[]" {
var f interface{}
err := json.Unmarshal([]byte(chaincodeAttributesJSON), &f)
if err != nil {
return fmt.Errorf("Chaincode argument error: %s", err)
}
}

return nil
}

Expand Down
5 changes: 0 additions & 5 deletions peer/chaincode/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
)

func TestCheckChaincodeCmdParamsWithNewCallingSchema(t *testing.T) {
chaincodeAttributesJSON = "[]"
chaincodeCtorJSON = `{ "Args":["func", "param"] }`
chaincodePath = "some/path"
chaincodeName = "somename"
Expand All @@ -36,7 +35,6 @@ func TestCheckChaincodeCmdParamsWithNewCallingSchema(t *testing.T) {
}

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

func TestCheckChaincodeCmdParamsWithoutName(t *testing.T) {
chaincodeAttributesJSON = "[]"
chaincodeCtorJSON = `{ "Function":"func", "Args":["param"] }`
chaincodePath = "some/path"
chaincodeName = ""
Expand All @@ -58,7 +55,6 @@ func TestCheckChaincodeCmdParamsWithoutName(t *testing.T) {
}

func TestCheckChaincodeCmdParamsWithFunctionOnly(t *testing.T) {
chaincodeAttributesJSON = "[]"
chaincodeCtorJSON = `{ "Function":"func" }`
chaincodePath = "some/path"
chaincodeName = "somename"
Expand All @@ -69,7 +65,6 @@ func TestCheckChaincodeCmdParamsWithFunctionOnly(t *testing.T) {
}

func TestCheckChaincodeCmdParamsEmptyCtor(t *testing.T) {
chaincodeAttributesJSON = "[]"
chaincodeCtorJSON = `{}`
chaincodePath = "some/path"
chaincodeName = "somename"
Expand Down
Loading

0 comments on commit 22ec03f

Please sign in to comment.