Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
boshevski committed Aug 30, 2016
0 parents commit 0af4e36
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Storj Rocks!

Testing GitBook and looking great so far.


8 changes: 8 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Summary

* [Introduction](README.md)
* [Getting Started](getting-started.md)
* [Upload & Download](upload-download.md)
* [Stream Audio & Video](video-audio.md)
* [Secure Registration](secure-registration.md)

41 changes: 41 additions & 0 deletions getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

# Getting Started

### 1. Create an Account

This part is really simple:

1. [**Sign Up**](https://app.storj.io/#/signup) for a Storj account.
2. Click on the activation link sent to your email.
3. Now visit [**app.storj.io**](https://app.storj.io) to login.


### 2. Creating a Bucket

We have lots of cat pictures we want to store in the cloud, so we should create a bucket. A bucket is just a logical grouping of files that we can assign permissions and limits to.

1. Click on the big green **"Create Bucket"** button.
2. Give it a descriptive name like *"Bucket of Cats"*. Don't worry, you can rename this later.


### 3. Getting Some Tools

We currently have a Javascript and Node.js client written to interface with the network and API. You must have [Node.js](https://nodejs.org) and [npm](https://www.npmjs.com/) installed. We HIGHLY recommend [nvm](https://github.com/creationix/nvm) for this. This tutorial is using a default Ubuntu 14.04 x64 machine from [Digital Ocean](https://www.digitalocean.com/).

apt-get install git -y\nnpm install -g storj

Run the `storj` program to view usage:

storj --help


### 4. Pairing a Device with Your Account

[Passwords suck](https://www.fastcompany.com/3055656/the-recommender/the-25-most-popular-passwords-of-2015-or-humans-suck) so we like to avoid them when we can. Behind the scenes, we use super secure [ECDSA](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm) keys that would take a computer the size of the sun to crack (provided you keep your keys safe).

To make this process simple, we created a pairing process. This will create a keypair on your computer and send the public key to us. It will be used for further authentication instead of the username and password.

$ storj login\n [...] > Enter your email address > [email protected]
[...] > Enter your password > ********************

[info] This device has been successfully paired.
48 changes: 48 additions & 0 deletions secure-registration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Secure Registration

You can access the Storj network using just your username and password. However, this is not secure – if you transmit your password in plaintext every time you log on to the Storj network, anyone who is eavesdropping on your traffic can intercept your password. This kind of eavesdropping has become quite common and easy to do.

Storj offers the option to authenticate with ECDSA keys instead. With ECDSA keys, you can generate a unique signature for every command to Storj. This signature verifies your identity, but can't be reused for other operations.

This tutorial will show you how to generate private and public ECDSA keys, and register them to our Storj account.

> ##### Registration Required
> This tutorial assumes you have registered with Storj using an email address and password. If not, follow the instructions [here](doc:getting-started) to do that first.
### Generating the Keys

To generate the keys, open a terminal and run these two commands in order:

openssl ecparam -genkey -name secp256k1 -noout -outform DER -out private.key
openssl ec -inform DER -in private.key -noout -text

You will see an output like this:

read EC key\nPrivate-Key: (256 bit)
priv:
8f:42:d3:b4:8b:9c:41:5c:de:fc:c3:cf:07:90:18:
8e:7b:25:bd:b9:52:d6:93:db:59:30:76:6d:g0:9a:
fe:0b
pub:
04:e5:d5:b8:33:da:56:dd:54:ba:c7:46:fc:1f:35:
6f:9c:f5:8f:dc:74:a0:11:2d:e7:c7:49:19:eb:d1:
69:a4:55:9d:fd:ee:ea:62:j2:27:ef:31:f1:0b:d1:
22:1b:46:62:n4:6b:ad:df:96:69:cf:36:38:4x:60:
e3:85:10:8c:23
ASN1 OID: secp256k1

Remove the colons and line-breaks from the public key so it looks like this:

04e5d5b833da56dd54bac746fc1f356f9cf58fdc74a0112de7c74919ebd169a4559dfdeeea62j227ef31f10bd1221b4662n46baddf9669cf36384x60e385108c23


### Generating the SHA-256 Hash of Your Password

You need to associate the public key with your Storj account. But first, you need to generate the SHA-256 hash of your Storj password. DuckDuckGo will give the SHA-256 of your password. For instance, if my password is shhdonttell, I could search [DuckDuckGo for sha-256 shhdonttell](https://duckduckgo.com/?q=sha-256+shhdonttell&ia=answer).

### Registering the Public Key with Storj

You now have the three things you need: an email registered with Storj, the SHA-256 hash of the password, and ECDSA keys. Register with Storj by inputting these values into the following command:

curl -u EMAIL:SHA256OFPASSWORD -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{\"key\":\"PUBLICECDSAKEY\"}' 'https://api.storj.io/keys'
60 changes: 60 additions & 0 deletions stream-video-audio.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

# Uploading and streaming a video or audio file

The streaming command pipes input from the Storj network to a media player program on your computer. As of July 2016, it is best tested with mplayer, though it can work with other media players like VLC.


### Uploading

First, let’s upload a media file to one of our Storj buckets. Any kind of audio or video file can be used. You can view your buckets and their IDs with the command:

storj list-buckets


Find the bucket you want to upload your file to. It will look something like this:

[Thu Jul 28 2016 22:35:45 GMT+0100 (BST)] [info] ID: 575h24d157619ba2045k769s, Name: Videos, Storage: 1, Transfer: 1",

Make a note of the bucket ID, which is ```575h24d157619ba2045k769s``` in this example.

To upload the file, put the bucket ID, and the path of the media file on your computer, into this command:

storj upload-file <bucketid> '<path>’

For our example, we're going to upload and stream the *Big Buck Bunny* trailer, which you can download [here](http://www.webmfiles.org/demo-files/) if you like. Or you can use any video or audio file you choose.

If the file name is ‘big-buck-bunny_trailer.webm’, and it is located at ‘/home/dave/Desktop/big-buck-bunny_trailer.webm’, the command would be:

storj upload-file 579aa607cb1caaa201cd6e67 '/home/dave/Desktop/big-buck-bunny_trailer.webm'

Enter your password if prompted to do so, then wait for the file to be encrypted and uploaded. At the end of the output you will see a line like this:

[Mon Aug 01 2016 23:21:29 GMT+0100 (BST)] [info] Name: big-buck-bunny_trailer.webm, Type: video/webm, Size: 2165175 bytes, ID: 579fcb69ee1e331f0359b4c1

Make a note of the file ID at the end of this output, in this case

579fcb69ee1e331f0359b4c1

Finally, stream the file using this command:

storj -k <keyringpassword> stream-file <bucketid> <fileid> | mplayer -

Where
* <keyringpassword> is the password that gives access to the ECDSA keys on your computer. You set this up when authenticating your device with Storj.
* <bucketid> and <fileid> are the IDs you found out earlier.
* mplayer is the program on your computer that plays the media file. You could replace mplayer with vlc, cvlc, cmus, or any media player of your choosing.

For example, to stream *Big Buck Bunny*, if our password is *shhdonttell*, the command would be:

storj -k shhdonttell stream-file 575h24d157619ba2045k769s 579fcb69ee1e331f0359b4c1 | mplayer -


### Troubleshooting mplayer error

If you try to streaming with mplayer, and you get an error message saying

Failed to open LIRC support

Then go to $HOME/.mplayer/ and add this line to the config file:

lirc=no
72 changes: 72 additions & 0 deletions upload-download.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Upload/Download

Now that we have a client paired with the service, we can get into some fun stuff with the tools.

### 1. Acquire a Collection of Cat Pictures

We prefer to use [free software](https://www.gnu.org/philosophy/free-sw.en.html) and also [free cats](https://www.google.com/search?site=imghp&tbm=isch&q=cats&tbs=sur:fmc).


### 2. Find Our Bucket ID

To upload our cat pictures we first have to get a bucket ID. We created a bucket before, so let´s find its bucket ID and use that. Please type the following command in your terminal or at your command prompt:

$ storj list-buckets
[info] ID: 573b4ce25da55fc8715b4c5a, Name: Test Bucket, Storage: 10, Transfer: 30

Copy the bucket ID for the next step. In my case it is `573b4ce25da55fc8715b4c5a`.


### 3. Upload a Cat

> ##### Keyring Passphrase
>The first time you try to upload a file, it will prompt you to enter a passphrase. This will be used to encrypt all your files locally, and will not be passed to any 3rd party service or server.
To upload a cat we use ```storj upload-file <bucket id> <file path>```. It is important to remember that you need to use the bucket ID, and not the name of the bucket for <bucket id>.

$ storj upload-file 573b4ce25da55fc8715b4c5a cat.jpg
[...] > Enter your passphrase to unlock your keyring > ******

[info] Generating encryption key...
[info] Encrypting file \"cat.jpg\"
[info] Encryption complete!
[info] Creating storage token...
[info] Storing file, hang tight!
[info] Encryption key saved to keyring.
[info] File successfully stored in bucket.
[info] Name: cat.jpg, Type: image/jpeg, Size: 8388624 bytes, ID: 574733fb705cbc353c48eef7


### 4. Download a Cat

To download a cat we use:

storj download-file <bucket id> <object id> <filepath>

Note that the object ID needed to download the file is listed in the output of the upload, and that you need to use the bucket ID and not the name of the bucket for <bucket id>.

$ storj download-file 573b4ce25da55fc8715b4c5a 574733fb705cbc353c48eef7 cat2.jpg
[...] > Enter your passphrase to unlock your keyring > ******

[info] Creating retrieval token...
[info] Resolving file pointer...
[info] Downloading file from 2 channels...
[info] Received 65536 bytes of data
[info] Received 65536 bytes of data
[info] Received 65536 bytes of data
[info] Received 65536 bytes of data
...
[info] Received 65536 bytes of data
[info] Received 65536 bytes of data
[info] Received 65536 bytes of data
[info] Received 65536 bytes of data
[info] Received 16 bytes of data
[info] File downloaded and written to cat2.jpg.

We have uploaded and download our cats to the cloud! Now if you uploaded the cat previously and don't know that object ID, you can look it up via the ```storj list-files <bucket id>``` command.

$ storj list-files 573b4ce25da55fc8715b4c5a
[info] Name: cat.jpg, Type: image/jpeg, Size: 8388624 bytes, ID: 574733fb705cbc353c48eef7


0 comments on commit 0af4e36

Please sign in to comment.