Skip to content

Commit

Permalink
DID Specification 1.0
Browse files Browse the repository at this point in the history
Small adjustments to support version 1.0 of the DID specification.
  • Loading branch information
bcessa committed Jan 12, 2020
1 parent 6f282ef commit 8d8f4af
Show file tree
Hide file tree
Showing 19 changed files with 101 additions and 28 deletions.
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.DEFAULT_GOAL := help
BINARY_NAME=didctl
DOCKER_IMAGE=didctl
VERSION_TAG=0.4.0
VERSION_TAG=0.4.1

# Custom compilation tags
LD_FLAGS="\
Expand All @@ -26,6 +26,11 @@ test:
# Unit tests
go test -race -cover -v -failfast ./...

## scan: Look for knonwn vulnerabilities in the project dependencies
# https://github.com/sonatype-nexus-community/nancy
scan:
@nancy -quiet go.sum

## release: Prepare assets for a new tagged release
release:
@-rm -rf release-$(VERSION_TAG)
Expand Down Expand Up @@ -57,9 +62,9 @@ clean:
go mod vendor

## updates: List available updates for direct dependencies
# https://github.com/golang/go/wiki/Modules#how-to-upgrade-and-downgrade-dependencies
updates:
# https://github.com/golang/go/wiki/Modules#how-to-upgrade-and-downgrade-dependencies
go list -u -f '{{if (and (not (or .Main .Indirect)) .Update)}}{{.Path}}: {{.Version}} -> {{.Update.Version}}{{end}}' -m all 2> /dev/null
@go list -u -f '{{if (and (not (or .Main .Indirect)) .Update)}}{{.Path}}: {{.Version}} -> {{.Update.Version}}{{end}}' -m all 2> /dev/null

## proto: Compile protocol buffers and RPC services
proto:
Expand Down
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,21 @@ implementation. The document is organized in 3 main sections.
A Decentralized Identifier is defined as a [RFC3986](https://tools.ietf.org/html/rfc3986)
Uniform Resource Identifier, with a format based on the generic DID schema. Fore more
information you can refer to the
[original documentation](https://w3c-ccg.github.io/did-spec/#decentralized-identifiers-dids).
[original documentation](https://w3c.github.io/did-core/#generic-did-syntax).

```abnf
did-reference = did [ "/" did-path ] [ "#" did-fragment ]
did = "did:" method ":" specific-idstring
method = 1*methodchar
methodchar = %x61-7A / DIGIT
specific-idstring = idstring *( ":" idstring )
idstring = 1*idchar
idchar = ALPHA / DIGIT / "." / "-"
did = "did:" method-name ":" method-specific-id
method-name = 1*method-char
method-char = %x61-7A / DIGIT
method-specific-id = *idchar *( ":" *idchar )
idchar = ALPHA / DIGIT / "." / "-" / "_"
did-url = did *( ";" param ) path-abempty [ "?" query ]
[ "#" fragment ]
param = param-name [ "=" param-value ]
param-name = 1*param-char
param-value = *param-char
param-char = ALPHA / DIGIT / "." / "-" / "_" / ":" /
pct-encoded
```

Example of a simple Decentralized Identifier (DID).
Expand Down Expand Up @@ -218,7 +223,7 @@ At the very least, the document must include the DID subject it's referring to u

```json
{
"@context": "https://w3id.org/did/v1",
"@context": "https://www.w3.org/ns/did/v1",
"id": "did:bryk:c137:b616fca9-ad86-4be5-bc9c-0e3f8e27dc8d"
}
```
Expand Down Expand Up @@ -253,7 +258,7 @@ Example of a more complete, and useful, DID Document.
```json
{
"@context": [
"https://w3id.org/did/v1",
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/v1"
],
"id": "did:bryk:c137:eeb0c865-ce21-4ad6-baf8-5ba287ba8683",
Expand Down Expand Up @@ -550,7 +555,7 @@ The generated document will be something similar for the following example.
```json
{
"@context": [
"https://w3id.org/did/v1",
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/v1"
],
"id": "did:bryk:99dc4a30-7434-42e5-ac75-5f330be0ea0a",
Expand Down Expand Up @@ -600,7 +605,7 @@ The command will perform the required network operations and verifications.
[Mar 14 12:15:24.277] INFO integrity proof is valid
{
"@context": [
"https://w3id.org/did/v1",
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/v1"
],
"id": "did:bryk:4d81bd52-2edb-4703-b8fc-b26d514a9c56",
Expand Down
2 changes: 2 additions & 0 deletions client/cli/cmd/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ func init() {
Usage: "TCP port to use for the server",
FlagKey: "server.port",
ByDefault: 9090,
Short: "p",
},
{
Name: "storage",
Usage: "specify the directory to use for data storage",
FlagKey: "server.storage",
ByDefault: "/etc/didctl/agent",
Short: "s",
},
{
Name: "pow",
Expand Down
2 changes: 1 addition & 1 deletion client/cli/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var deleteCmd = &cobra.Command{
Use: "delete",
Short: "Permanently delete a local identifier",
Example: "didctl delete [DID reference name]",
Aliases: []string{"rm", "remove"},
Aliases: []string{"del", "rm", "remove"},
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return errors.New("you must specify a DID reference name")
Expand Down
8 changes: 4 additions & 4 deletions client/cli/cmd/details.go → client/cli/cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (
)

var didDetailsCmd = &cobra.Command{
Use: "details",
Use: "info",
Short: "Display the current information available on an existing DID",
Example: "didctl did details [DID reference name]",
Aliases: []string{"info"},
Example: "didctl info [DID reference name]",
Aliases: []string{"details", "inspect", "view", "doc"},
RunE: runDidDetailsCmd,
}

func init() {
didCmd.AddCommand(didDetailsCmd)
rootCmd.AddCommand(didDetailsCmd)
}

func runDidDetailsCmd(_ *cobra.Command, args []string) error {
Expand Down
6 changes: 5 additions & 1 deletion client/cli/cmd/key_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,28 @@ func init() {
Usage: "name to be assigned to the newly added key",
FlagKey: "key-add.name",
ByDefault: "key-#",
Short: "n",
},
{
Name: "type",
Usage: "type of cryptographic key: RSA (rsa), Ed25519 (ed) or secp256k1 (koblitz)",
FlagKey: "key-add.type",
ByDefault: "ed",
Short: "t",
},
{
Name: "encoding",
Usage: "encoding to use for key value: hex, base58, base64",
FlagKey: "key-add.encoding",
ByDefault: "hex",
ByDefault: "base58",
Short: "e",
},
{
Name: "authentication",
Usage: "enable this key for authentication purposes",
FlagKey: "key-add.authentication",
ByDefault: false,
Short: "a",
},
}
if err := cli.SetupCommandParams(addKeyCmd, params); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion client/cli/cmd/key_recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func init() {
if err := cli.SetupCommandParams(recoverKeyCmd, params); err != nil {
panic(err)
}
keyCmd.AddCommand(recoverKeyCmd)
// keyCmd.AddCommand(recoverKeyCmd)
}

func runRecoverKeyCmd(_ *cobra.Command, _ []string) error {
Expand Down
1 change: 1 addition & 0 deletions client/cli/cmd/key_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var removeKeyCmd = &cobra.Command{
Use: "remove",
Short: "Remove an existing cryptographic key for the DID",
Example: "didctl did key remove [DID reference name] [key name]",
Aliases: []string{"rm"},
RunE: runRemoveKeyCmd,
}

Expand Down
3 changes: 3 additions & 0 deletions client/cli/cmd/sign.go → client/cli/cmd/key_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@ func init() {
Usage: "contents to sign, if longer than 32 bytes a SHA3-256 will be generated",
FlagKey: "sign.input",
ByDefault: "",
Short: "i",
},
{
Name: "key",
Usage: "key to use to produce the signature",
FlagKey: "sign.key",
ByDefault: "master",
Short: "k",
},
{
Name: "domain",
Usage: "domain value to use when producing LD signatures",
FlagKey: "sign.domain",
ByDefault: didDomainValue,
Short: "d",
},
}
if err := cli.SetupCommandParams(signCmd, params); err != nil {
Expand Down
1 change: 1 addition & 0 deletions client/cli/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var listCmd = &cobra.Command{
Use: "list",
Short: "List registered DIDs",
Example: "didctl list",
Aliases: []string{"ls"},
RunE: runListCmd,
}

Expand Down
5 changes: 4 additions & 1 deletion client/cli/cmd/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,21 @@ func init() {
Usage: "choose a recovery mechanism for your primary key, 'passphrase' or 'secret-sharing'",
FlagKey: "register.recovery-mode",
ByDefault: "secret-sharing",
Short: "r",
},
{
Name: "secret-sharing",
Usage: "specify the number of shares and threshold value in the following format: shares,threshold",
FlagKey: "register.secret-sharing",
ByDefault: "3,2",
Short: "s",
},
{
Name: "tag",
Usage: "specify a tag value for the identifier instance",
FlagKey: "register.tag",
ByDefault: "",
Short: "t",
},
}
if err := cli.SetupCommandParams(registerCmd, params); err != nil {
Expand Down Expand Up @@ -97,7 +100,7 @@ func runRegisterCmd(_ *cobra.Command, args []string) error {
return err
}
ll.Debug("adding master key")
if err = id.AddExistingKey("master", pk, did.KeyTypeEd, did.EncodingHex); err != nil {
if err = id.AddExistingKey("master", pk, did.KeyTypeEd, did.EncodingBase58); err != nil {
return err
}
ll.Debug("setting master key as authentication mechanism")
Expand Down
2 changes: 1 addition & 1 deletion client/cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var rootCmd = &cobra.Command{
Reference client implementation for the "bryk" DID method. The platform allows
entities to fully manage Decentralized Identifiers as described on the version
v0.11 of the specification.
v1.0 of the specification.
For more information:
https://github.com/bryk-io/did-method`,
Expand Down
3 changes: 3 additions & 0 deletions client/cli/cmd/service_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@ func init() {
Usage: "service's reference name",
FlagKey: "service-add.name",
ByDefault: "external-service-#",
Short: "n",
},
{
Name: "type",
Usage: "type identifier for the service handler",
FlagKey: "service-add.type",
ByDefault: "identity.bryk.io.ExternalService",
Short: "t",
},
{
Name: "endpoint",
Usage: "main URL to access the service",
FlagKey: "service-add.endpoint",
ByDefault: "",
Short: "e",
},
}
if err := cli.SetupCommandParams(addServiceCmd, params); err != nil {
Expand Down
1 change: 1 addition & 0 deletions client/cli/cmd/service_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var removeServiceCmd = &cobra.Command{
Use: "remove",
Short: "Remove an existing service entry for the DID",
Example: "didctl did service remove [DID reference name] [service name]",
Aliases: []string{"rm"},
RunE: runRemoveServiceCmd,
}

Expand Down
3 changes: 3 additions & 0 deletions client/cli/cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,21 @@ func init() {
Usage: "cryptographic key to use for the sync operation",
FlagKey: "sync.key",
ByDefault: "master",
Short: "k",
},
{
Name: "deactivate",
Usage: "instruct the network agent to deactivate the identifier",
FlagKey: "sync.deactivate",
ByDefault: false,
Short: "d",
},
{
Name: "pow",
Usage: "set the required request ticket difficulty level",
FlagKey: "sync.pow",
ByDefault: 24,
Short: "p",
},
}
if err := cli.SetupCommandParams(syncCmd, params); err != nil {
Expand Down
1 change: 1 addition & 0 deletions client/cli/cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func init() {
Usage: "original contents to run the verification against",
FlagKey: "verify.input",
ByDefault: "",
Short: "i",
},
}
if err := cli.SetupCommandParams(verifyCmd, params); err != nil {
Expand Down
1 change: 0 additions & 1 deletion client/cli/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ var buildTimestamp string
var versionCmd = &cobra.Command{
Use: "version",
Short: "Display version information",
Aliases: []string{"info"},
Run: func(cmd *cobra.Command, args []string) {
var components = map[string]string{
"Version": coreVersion,
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/bryk-io/did-method
go 1.13

require (
github.com/gogo/googleapis v1.3.0
github.com/gogo/googleapis v1.3.2
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.3.2
github.com/grpc-ecosystem/grpc-gateway v1.12.1
Expand All @@ -17,7 +17,7 @@ require (
github.com/spf13/viper v1.6.1
github.com/vmihailenco/msgpack v4.0.4+incompatible
github.com/x-cray/logrus-prefixed-formatter v0.5.2
go.bryk.io/x v0.0.0-20191214162130-8a2dd183e3c9
go.bryk.io/x v0.0.0-20200112145239-9ac4ce6207cc
golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c
google.golang.org/grpc v1.25.1
google.golang.org/grpc v1.26.0
)
Loading

0 comments on commit 8d8f4af

Please sign in to comment.