Tools for building identity, trust and interoperability into connected devices.
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github chore: add mrinalwadhwa to CODEOWNERS Jan 15, 2019
chain feat: make Node interface embed Chain interface Jan 9, 2019
claim feat: sign claims and add entity attributes Jan 9, 2019
cmd/ockam feat(cmd/ockam): implement entity add and register Jan 10, 2019
entity feat: sign claims and add entity attributes Jan 9, 2019
example feat: sign claims and add entity attributes Jan 9, 2019
key/ed25519 feat(key/ed25519): expose private key Jan 10, 2019
log feat: add Logger interface, a simple logger and ConsoleFormatter Jan 4, 2019
node style: move dynamic verifier to node directory Jan 10, 2019
random feat(random): add functions to get random strings Jan 5, 2019
test docs: fix misspelling in test.Assert function's documentation Dec 13, 2018
.dockerignore build: add a vagrant based build machine Dec 2, 2018
.editorconfig build: fix linting errors Jan 10, 2019
.gitattributes style: specify conventions for charset, spacing, indentation etcetera Nov 30, 2018
.gitignore build: support lint, test, build and install of go code Dec 4, 2018
.goreleaser.yml build: add goreleaser tool and config Dec 29, 2018
CODE_OF_CONDUCT.md docs: add project code of conduct Dec 7, 2018
CONTRIBUTING.md docs: describe requirements for signing commits Jan 4, 2019
Dockerfile build: add goreleaser tool and config Dec 29, 2018
LICENSE docs: add apache license 2.0 Dec 7, 2018
NOTICE feat(entity): add support for generating DIDs Jan 5, 2019
README.md docs: add to TOC and fix typos in README Jan 10, 2019
Vagrantfile build: override vbox default nic type only in vagrant newer than v2.2.2 Dec 4, 2018
azure-pipelines.yml ci: run full build in azure pipeline instead of just lint Dec 4, 2018
build build: fix linting errors Jan 10, 2019
commitlint.config.js build: add build script and linters Nov 30, 2018
go.mod build: go mod tidy Jan 10, 2019
go.sum build: go mod tidy Jan 10, 2019
godownloader-ockam.sh feat: add downloader script Jan 10, 2019
logo.png docs: replace SVG logo in README with PNG and remove tagline Dec 13, 2018
ockam.go feat: bump version to 0.2.5 Jan 10, 2019
register.gif docs: add animated GIF of ockam register command Jan 10, 2019

README.md

Ockam

Apache 2.0 License Apache 2.0 License GoDoc Discuss Ockam

ockam register

Overview

Ockam is a decentralized and open platform for easily adding identity, trust and interoperability to connected devices.

This repository contains:

  1. The ockam command line program for simple interactions with the Ockam Network.
  2. The github.com/ockam-network/ockam Go package to develop Go applications that programatically interact with the Ockam Network.

In the near future, we plan to add ockam packages for other programming languages.

Go Package

You can add the ockam Golang package to your project using go get:

go get github.com/ockam-network/ockam

We require Go version 1.11+.

Hello Ockam

Here is some simple Go code to connect with the Ockam TestNet:

// create a lightweight local ockam node and give it a way to find peers on the ockam test network
ockamNode, err := node.New(node.PeerDiscoverer(http.Discoverer("test.ockam.network", 26657)))
if err != nil {
	log.Fatal(err)
}

// ask the local node to find peers and sync with network state
err = ockamNode.Sync()
if err != nil {
	log.Fatal(err)
}

// print the id of the chain that the network is maintaining.
ockamChain := ockamNode.Chain()
fmt.Printf("Chain ID: %s\n", ockamChain.ID())

A runnable version of the above example can be found in the example directory. You may run it by calling:

go run -mod=vendor example/01_hello_ockam.go

Note: The Ockam Testnet is provided and maintained by the Ockam team to help you build and experiment with applications that interact with Ockam. The TestNet has no service level guarantees, may have intermittent availability, may be down for maintenance, and may be restarted at anytime. If your application needs a production ready network, please email the Ockam team at hello@ockam.io

Register an Entity

In Ockam, things are modeled as entities. Each Entity has a DID that begins with did:ockam: and uses the ockam DID method.

An example ockam DID, looks like this: did:ockam:2QyqWz4xWB5o4Pr9G9fcZjXTE2ej5

// create a new ed25519 signer
signer, err := ed25519.New()
if err != nil {
	log.Fatal(err)
}

// create a new ockam entity to represent a temperature sensor
temperatureSensor, err := entity.New(
	entity.Attributes{
		"name":         "Temperature Sensor",
		"manufacturer": "Element 14",
		"model":        "Raspberry Pi 3 Model B+",
	},
	entity.Signer(signer),
)
if err != nil {
	log.Fatal(err)
}

// register the entity by creating a signed registration claim
registrationClaim, err := ockamChain.Register(temperatureSensor)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("registrationClaim - %s\n", registrationClaim.ID())

A runnable version of the above example can be found in the example directory. You may run it by calling:

go run -mod=vendor example/02_register_entity.go

The above program generates a new ed25519 signer, then creates a new entity and assigns it that signer. The above code also adds some attributes to the entity, like its manufacturer's name.

Finally the code above, as part of the Register method generates an EntityRegistrationClaim. This verifiable registration claim embeds the DID Document that represents this newly created entity.

The claim is then cryprographically signed using the entity's signer and then subitted to the network.

An example EntityRegistrationClaim claim looks like this:

{
	"@context": [
		"https://w3id.org/identity/v1",
		"https://w3id.org/security/v1"
	],
	"id": "did:ockam:2QyqWz4xWB5o4Pr9G9fcZjXTE2ej5/claim/1brpf2pkh6",
	"type": [
		"EntityRegistrationClaim"
	],
	"issuer": "did:ockam:2QyqWz4xWB5o4Pr9G9fcZjXTE2ej5",
	"issued": "2019-01-10",
	"claim": {
		"authentication": [
			{
				"publicKey": "did:ockam:2QyqWz4xWB5o4Pr9G9fcZjXTE2ej5#key-1",
				"type": "Ed25519SignatureAuthentication2018"
			}
		],
		"id": "did:ockam:2QyqWz4xWB5o4Pr9G9fcZjXTE2ej5",
		"manufacturer": "Element 14",
		"model": "Raspberry Pi 3 Model B+",
		"name": "Temperature Sensor",
		"publicKey": [
			{
				"id": "did:ockam:2QyqWz4xWB5o4Pr9G9fcZjXTE2ej5#key-1",
				"publicKeyHex": "3c93f446990ecd3ce64bcf9a5f949423d2e348948ee3aeb1c78924490f6b50f9",
				"type": "Ed25519VerificationKey2018"
			}
		],
		"registrationClaim": "did:ockam:2QyqWz4xWB5o4Pr9G9fcZjXTE2ej5/claim/1brpf2pkh6"
	},
	"signatures": [
		{
			"created": "2019-01-10T07:53:25Z",
			"creator": "did:ockam:2QyqWz4xWB5o4Pr9G9fcZjXTE2ej5#key-1",
			"domain": "ockam",
			"nonce": "1brpf2pkh6",
			"signatureValue": "4v3cTB5u0/nA/xxrGU3gQ38IaP1MJJ7tQyPQtBtZmVLE36M96d2XRo0ArFyxQV2CsDMtP57n/vnvZWN88Du+Bg==",
			"type": "Ed25519Signature2018"
		}
	]
}

Submit a Claim

Once an entity is registered, it can make signed verifiable claims about itself or other entities.

Here is some code to create and submit a new signed claim that includes a temperature reading:

// create a temperature claim with this new sensor entity as both the issuer and the subject of the claim
temperatureClaim, err := claim.New(
	claim.Data{"temperature": 100},
	claim.Issuer(temperatureSensor),
	claim.Subject(temperatureSensor),
)
if err != nil {
	log.Fatal(err)
}

// submit the claim to be
err = ockamChain.Submit(temperatureClaim)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("Submitted - " + temperatureClaim.ID())

A runnable version of the above example can be found in the example directory. You may run it by calling:

go run -mod=vendor example/03_submit_claim.go

The above code generates a signed claim of the following form:

{
	"@context": [
		"https://w3id.org/identity/v1",
		"https://w3id.org/security/v1"
	],
	"id": "did:ockam:2PdDcphFfkW5eU1C1mFB1i9H8ZsgC/claim/iu5aczbwnt",
	"type": [
		""
	],
	"issuer": "did:ockam:2PdDcphFfkW5eU1C1mFB1i9H8ZsgC",
	"issued": "2019-01-10",
	"claim": {
		"id": "did:ockam:2PdDcphFfkW5eU1C1mFB1i9H8ZsgC",
		"temperature": 100
	},
	"signatures": [
		{
			"created": "2019-01-10T08:00:31Z",
			"creator": "did:ockam:2PdDcphFfkW5eU1C1mFB1i9H8ZsgC#key-1",
			"domain": "ockam",
			"nonce": "iu5aczbwnt",
			"signatureValue": "UpCPc/Z6bGwUXfgNgRFxpQU2kSt8HBoe8E94JyvlAKG1yBNBfqb4oUKdPZPHOQH37JtiIFap9eGS4qMBP35DDA==",
			"type": "Ed25519Signature2018"
		}
	]
}

Command Line

The ockam command is a useful tool to interact with the Ockam Network. You can install the commad for your operating system from our release bundles or using this simple script:

curl -L https://git.io/fhZgf | sh

This will download the command to ./bin/ockam in your current directory. The binary is self contained, so if you wish to you can copy it to somewhere more convenient in your system path, for example:

cp ./bin/ockam /usr/local/bin/

Once the command is in you path, you can run:

ockam --version

Next you may call:

ockam register

which will generate a unique ockam decentralized identity for your computer and register that identity on the Ockam TestNet.

Build

To build and run ockam from source:

./build && ./build install && ockam --version

This requires recent versions of Bash and Docker installed on your development machine.

You may also work within a Vagrant and Virtualbox environment, a Vagrnatfile is included. Our Contributing Guide has more details on how to build and contribute to Ockam.

Contributing to Ockam

Contributors

License and attributions

This code is licensed under the terms of the Apache License 2.0

This code depends on other open source packages, attributions for those packages are in the NOTICE file