Skip to content

Replace name & use contract data with an ipfs hash#3

Open
johnbayne wants to merge 1 commit intojsaur:masterfrom
johnbayne:ipfs-for-name-and-use
Open

Replace name & use contract data with an ipfs hash#3
johnbayne wants to merge 1 commit intojsaur:masterfrom
johnbayne:ipfs-for-name-and-use

Conversation

@johnbayne
Copy link

Do not merge. Just PRing to share my solution to the weekly coding challenge

This PR replaces the name & use fields in LoanContract.sol with an ipfs hash. That ipfs hash points to a file containing the same name & use data stored on the interplanetary file system.

As currently implemented, the solution provides negligible privacy for name/use data, because the ifpsHash is stored in the public blockchain. Once we decide whether to:

  • Run a private ipfs network
  • Encrypt the ipfsHash
  • Something else(?)

the ipfsHash will obfuscate name/use data from nosey members of the public.

A few other notes:

  • The README.md now suggests using ganache-cli instead of the current testrpc. This is in line with testrpc's own recommendations
  • I appropriated a few of my own preferences into .gitIgnore. Can take these out if preferred

Also, there are no tests for this code. Probably worth discussing testing strategy at some point.

```
[sudo] npm install -g truffle // Version 3.0.5+ required.
[sudo] npm install -g ethereumjs-testrpc
[sudo] npm install -g ganache-cli

Choose a reason for hiding this comment

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

@jsaur what do you think about us defaulting to ganache? seems useful. @johnbayne You've found ganache really useful for getting up to speed, right?

Copy link
Owner

Choose a reason for hiding this comment

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

Sounds good, it seems like there's not much of a difference but that ganache is what truffle is going with now

Copy link
Author

Choose a reason for hiding this comment

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

@coderintherye @jsaur Yes, absolutely. TestRPC redirects to ganache-cli these days - I think ganache has officially superseded it.

Last week we used ganache as opposed to ganache-cli, the above recommends the CLI. Same backend, less mouseclicks, more portability.


addNameUseHash (name, use) {
// TODO: Discuss 'salt' with team. Has pros & cons
const ipfsData = JSON.stringify({name: name, use: use, salt: Math.random()})

Choose a reason for hiding this comment

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

@johnbayne I like this approach, @jsaur what do you think?
Either way agreed that we'll want the IPFS data to be represented in JSON

Copy link
Owner

Choose a reason for hiding this comment

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

+1

Copy link
Author

Choose a reason for hiding this comment

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

Great, glad to hear. We can salt elsewhere down the line, but I wanted to introduce it here to ensure we didn't forget to do so. IPFS sends blocks of identical content to the same hash, so if a borrower put the same use for multiple loans, anyone who had access to the name/use of one loan could see all that borrower's loans that shared the same use.

On one hand, the salt protects against that. On the other, well - it seems slightly overkill. I'm happy either way. :-)

selenium-debug.log


build/contracts/
Copy link
Owner

Choose a reason for hiding this comment

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

+1

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.

3 participants