Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

private-data go chaincode now sets the Asset owner as client identity certificate string #374

Merged

Conversation

sijocherian
Copy link
Contributor

  • go chaincode now sets the Asset owner as client identity certificate string (instead of base64 str)
  • Reason for the update: "GetClientIdentity().GetID()" api in go chaincode returns base64 string, while same api in java chaincode returns the same data as string
  • go vs java chaincode : Not sure why we have different behavior in go vs java chaincode
    • also noticed that the cert string returned by java api has different spacing between the elements compare to that from go api x509::CN=${Org1UserId},OU=client+OU=org1+OU=department1::CN=ca.org1.example.com,O=org1.example.com,L=Durham,ST=North Carolina,C=US
  • the go chaincode & java chaincode (Adding java chaincode for private-data sample #345 ) now behaves similar , in setting owner string
  • updated js app verify method

@sijocherian sijocherian requested a review from a team as a code owner November 19, 2020 15:48
…string (instead of base64 str)

go chaincode now sets the Asset owner as client identity certificate string (instead of base64 str)
Reason for the update: "GetClientIdentity().GetID()" api in go chaincode returns base64 string, while same api in java chaincode returns the same data as string
go & java chaincode sets same owner string
updated js app verify method

Signed-off-by: Sijo Cherian <sijo@ibm.com>
@sijocherian sijocherian force-pushed the asset-privatedata.fix-ownerdecoding branch from d22ec02 to cba6d85 Compare November 19, 2020 15:49
[Using Private Data tutorial](https://hyperledger-fabric.readthedocs.io/en/latest/private_data_tutorial.html)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no diff here

@nikhil550
Copy link
Contributor

This a good update, and I will use it for the auction samples. However, there are some updates to the tutorial that need to be made. Now that all the tutorials use these samples, we may need to put in more effort to keep the branches and samples tags in sync:

{"objectType":"asset","assetID":"asset1","color":"green","size":20,"owner":"eDUwOTo6Q049b3JnMWFkbWluLE9VPWFkbWluLE89SHlwZXJsZWRnZXIsU1Q9Tm9ydGggQ2Fyb2xpbmEsQz1VUzo6Q049Y2Eub3JnMS5leGFtcGxlLmNvbSxPPW9yZzEuZXhhbXBsZS5jb20sTD1EdXJoYW0sU1Q9Tm9ydGggQ2Fyb2xpbmEsQz1VUw=="}

The "owner" of the asset is the identity that created the asset by invoking the smart contract. The private data smart contract uses the GetClientIdentity().GetID() API to read the name and issuer of the identity certificate.
You can see that information by decoding the owner string out of base64 format:

    echo eDUwOTo6Q049b3JnMWFkbWluLE9VPWFkbWluLE89SHlwZXJsZWRnZXIsU1Q9Tm9ydGggQ2Fyb2xpbmEsQz1VUzo6Q049Y2Eub3JnMS5leGFtcGxlLmNvbSxPPW9yZzEuZXhhbXBsZS5jb20sTD1EdXJoYW0sU1Q9Tm9ydGggQ2Fyb2xpbmEsQz1VUw== | base64 --decode

The result will show the name and issuer of the owner certificate:

 x509::CN=org1admin,OU=admin,O=Hyperledger,ST=North Carolina,C=US::CN=ca.org1.example.com,O=org1.example.com,L=Durham,ST=North Carolina,C=US

@sijocherian
Copy link
Contributor Author

sijocherian commented Nov 23, 2020

@nikhil550 I will send a PR soon to update private-data tutorial in fab repo. Is there any other changes your are suggesting?

This is just a tutorial change in steps for validating Asset Owner visually.
If this is important enough to change tutorial in LTS version, we can back-port the change to 2.2LTS branch. Opinions?

@nikhil550
Copy link
Contributor

@nikhil550 I will send a PR soon to update private-data tutorial in fab repo. Is there any other changes your are suggesting?

This is just a tutorial change in steps for validating Asset Owner visually.
If this is important enough to change tutorial in LTS version, we can back-port the change to 2.2LTS branch. Opinions?

No other changes, just making a note.

sijocherian pushed a commit to sijocherian/fabric that referenced this pull request Nov 24, 2020
 go chaincode now sets the Asset owner as client identity certificate string (instead of base64 str)
 ref hyperledger/fabric-samples#374
 better PDC description

Signed-off-by: Sijo Cherian <sijo@ibm.com>
Copy link
Contributor

@denyeart denyeart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I'll merge this and the doc PR and Fabric repo.

@denyeart denyeart merged commit 8c9fd98 into hyperledger:master Nov 26, 2020
denyeart pushed a commit to hyperledger/fabric that referenced this pull request Nov 26, 2020
 go chaincode now sets the Asset owner as client identity certificate string (instead of base64 str)
 ref hyperledger/fabric-samples#374
 better PDC description

Signed-off-by: Sijo Cherian <sijo@ibm.com>
mergify bot pushed a commit to hyperledger/fabric that referenced this pull request Nov 26, 2020
 go chaincode now sets the Asset owner as client identity certificate string (instead of base64 str)
 ref hyperledger/fabric-samples#374
 better PDC description

Signed-off-by: Sijo Cherian <sijo@ibm.com>
(cherry picked from commit 3406c35)
mergify bot pushed a commit to hyperledger/fabric that referenced this pull request Nov 26, 2020
 go chaincode now sets the Asset owner as client identity certificate string (instead of base64 str)
 ref hyperledger/fabric-samples#374
 better PDC description

Signed-off-by: Sijo Cherian <sijo@ibm.com>
(cherry picked from commit 3406c35)
denyeart pushed a commit to hyperledger/fabric that referenced this pull request Nov 26, 2020
 go chaincode now sets the Asset owner as client identity certificate string (instead of base64 str)
 ref hyperledger/fabric-samples#374
 better PDC description

Signed-off-by: Sijo Cherian <sijo@ibm.com>
(cherry picked from commit 3406c35)
denyeart pushed a commit to hyperledger/fabric that referenced this pull request Nov 26, 2020
 go chaincode now sets the Asset owner as client identity certificate string (instead of base64 str)
 ref hyperledger/fabric-samples#374
 better PDC description

Signed-off-by: Sijo Cherian <sijo@ibm.com>
(cherry picked from commit 3406c35)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants