Skip to content

Commit

Permalink
feat(clinet): ✨ contract to create a sandbox.genericissuer did doc (#64)
Browse files Browse the repository at this point in the history
* feat(clinet): ✨ contract to create a sandbox.genericissuer did doc

* docs(clinet): 📖 fix some typos in genericissuer readme
  • Loading branch information
matteo-cristino authored Jan 17, 2024
1 parent 641e0ab commit e1c3a12
Show file tree
Hide file tree
Showing 5 changed files with 256 additions and 0 deletions.
9 changes: 9 additions & 0 deletions client/v1/issuer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Flow

In order to create a unisgned request to send to a sandbox.genericissuer admin do:
1. `echo '{"controller": "<did doc desciption>"}' > controller.json`
2. `zenroom -a controller.json -z create-keyring.zen > keys.json`
3. `zenroom -a keys.json -z create-identity-pubkeys.zen > pks.json`
4. `zenroom -a pks.json -k request_input.json -z pubkeys-request-unsigned.zen > req.json`


30 changes: 30 additions & 0 deletions client/v1/issuer/create-identity-pubkeys.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
rule output encoding base58
Scenario 'ecdh': Create the pk
Scenario 'ethereum': Create the pk
Scenario 'reflow': Create the pk
Scenario 'eddsa' : Create the pk
Scenario 'credential': Create the pk
Scenario 'bbs': Create the pk
Scenario 'es256': Create the pk

Given my name is in a 'string' named 'controller'
and I have my 'keyring'

When I create the ecdh public key
and I create the eddsa public key
and I create the ethereum address
and I create the bitcoin public key
and I create the reflow public key
and I create the issuer public key
and I create the bbs public key
and I create the es256 public key

Then I print the 'eddsa public key'
and I print the 'ethereum address'
and I print the 'ecdh public key'
and I print the 'bitcoin public key'
and I print the 'reflow public key'
and I print the 'issuer public key' as 'compressed issuer public key'
and I print the 'bbs public key'
and I print the 'es256 public key'
and I print my name in 'identity'
22 changes: 22 additions & 0 deletions client/v1/issuer/create-keyring.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Scenario ecdh
Scenario eddsa
Scenario ethereum
Scenario reflow
Scenario es256
Scenario credential
Scenario bbs

Given I my name is in a 'string' named 'controller'

When I create the ecdh key
and I create the eddsa key
and I create the ethereum key
and I create the bitcoin key
and I create the reflow key
and I create the es256 key
and I create the issuer key
and I create the bbs key

# keyring and explicit owner identity
Then print my 'keyring'
and print my name in 'controller'
179 changes: 179 additions & 0 deletions client/v1/issuer/pubkeys-request-unsigned.zen
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
Rule input encoding base58
Rule output encoding base58

Scenario 'ecdh': Move pk in did doc
Scenario 'ethereum': Move pk in did doc
Scenario 'reflow': Move pk in did doc
Scenario 'eddsa' : Move pk in did doc
Scenario 'credential': Move pk in did doc
Scenario 'bbs': Move pk in did doc
Scenario 'es256': Move pk in did doc

# data
Given I have a 'string array' named '@context'
Given I have a 'string' named 'identity'
and I rename 'identity' to 'description'
Given I have a 'eddsa_public_key'
and I rename 'eddsa_public_key' to 'identity pk'
Given I have a 'ethereum_address'
Given I have a 'ecdh_public_key'
Given I have a 'reflow_public_key'
Given I have a 'bbs_public_key'
Given I have a 'es256_public_key'
Given I have a 'base58' named 'issuer_public_key'
Given I have a 'base58' named 'bitcoin public key'

# keys
Given I have a 'string' named 'did_spec'

### Formulate the DID creation request
When I create the 'string dictionary' named 'did document'
and I move '@context' in 'did document'
and I move 'description' in 'did document'

## did spec and id
When I set 'did:dyne:' to 'did:dyne:' as 'string'
and I append 'did_spec' to 'did:dyne:'
and I append the string ':' to 'did:dyne:'
and I append the 'base58' of 'identity pk' to 'did:dyne:'
and I copy the 'did:dyne:' to 'id' in 'did document'

## veririfcationMethod
When I create the 'string array' named 'verificationMethod'

# 1-ecdsa public key
When I create the 'string dictionary' named 'verification-key'
# pk
When I create the 'base58' string of 'ecdh public key'
When I move the 'base58' to 'publicKeyBase58' in 'verification-key'
# type
When I set 'type' to 'EcdsaSecp256k1VerificationKey2019' as 'string'
When I move 'type' in 'verification-key'
# id
When I copy 'did:dyne:' to 'id'
When I append the string '#ecdh_public_key' to 'id'
When I move 'id' in 'verification-key'
# controller
When I copy the 'did:dyne:' to 'controller' in 'verification-key'
When I move 'verification-key' in 'verificationMethod'

# 2-reflow public key
When I create the 'string dictionary' named 'verification-key'
# pk
When I create the 'base58' string of 'reflow public key'
When I move the 'base58' to 'publicKeyBase58' in 'verification-key'
# type
When I set 'type' to 'ReflowBLS12381VerificationKey' as 'string'
When I move 'type' in 'verification-key'
# id
When I copy 'did:dyne:' to 'id'
When I append the string '#reflow_public_key' to 'id'
When I move 'id' in 'verification-key'
# controller
When I copy the 'did:dyne:' to 'controller' in 'verification-key'
When I move 'verification-key' in 'verificationMethod'

# 3-bitcoin public key
When I create the 'string dictionary' named 'verification-key'
# pk
When I create the 'base58' string of 'bitcoin public key'
and I move the 'base58' to 'publicKeyBase58' in 'verification-key'
# type
When I set 'type' to 'EcdsaSecp256k1VerificationKey2019' as 'string'
When I move 'type' in 'verification-key'
# id
When I copy 'did:dyne:' to 'id'
When I append the string '#bitcoin_public_key' to 'id'
When I move 'id' in 'verification-key'
# controller
When I copy the 'did:dyne:' to 'controller' in 'verification-key'
When I move 'verification-key' in 'verificationMethod'

# 4-eddsa public key
When I create the 'string dictionary' named 'verification-key'
# pk
When I create the 'base58' string of 'identity pk'
and I move the 'base58' to 'publicKeyBase58' in 'verification-key'
# type
When I set 'type' to 'Ed25519VerificationKey2018' as 'string'
When I move 'type' in 'verification-key'
# id
When I copy 'did:dyne:' to 'id'
When I append the string '#eddsa_public_key' to 'id'
When I move 'id' in 'verification-key'
# controller
When I copy the 'did:dyne:' to 'controller' in 'verification-key'
When I move 'verification-key' in 'verificationMethod'

# 5-issuer public key
When I create the 'string dictionary' named 'verification-key'
# pk
When I create the 'base58' string of 'issuer public key'
and I move the 'base58' to 'publicKeyBase58' in 'verification-key'
# type
When I set 'type' to 'IssuerBLS12381VerificationKey' as 'string'
When I move 'type' in 'verification-key'
# id
When I copy 'did:dyne:' to 'id'
When I append the string '#issuer_public_key' to 'id'
When I move 'id' in 'verification-key'
# controller
When I copy the 'did:dyne:' to 'controller' in 'verification-key'
When I move 'verification-key' in 'verificationMethod'

# 6-bbs public key
When I create the 'string dictionary' named 'verification-key'
# pk
When I create the 'base58' string of 'bbs public key'
and I move the 'base58' to 'publicKeyBase58' in 'verification-key'
# type
When I set 'type' to 'BbsVerificationKey' as 'string'
When I move 'type' in 'verification-key'
# id
When I copy 'did:dyne:' to 'id'
When I append the string '#bbs_public_key' to 'id'
When I move 'id' in 'verification-key'
# controller
When I copy the 'did:dyne:' to 'controller' in 'verification-key'
When I move 'verification-key' in 'verificationMethod'

# 7-es256 public key
When I create the 'string dictionary' named 'verification-key'
# pk
When I create the 'base58' string of 'es256 public key'
and I move the 'base58' to 'publicKeyBase58' in 'verification-key'
# type
When I set 'type' to 'EcdsaSecp256r1VerificationKey' as 'string'
When I move 'type' in 'verification-key'
# id
When I copy 'did:dyne:' to 'id'
When I append the string '#es256_public_key' to 'id'
When I move 'id' in 'verification-key'
# controller
When I copy the 'did:dyne:' to 'controller' in 'verification-key'
When I move 'verification-key' in 'verificationMethod'

# 8-ethereum address
When I create the 'string dictionary' named 'verification-key'
# address
# this follows the CAIP-10(https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-10.md) spec
# thus it is: namespace + ":" + chain_id + ":" + address
When I set 'blockchainAccountId' to 'eip155:1:0x' as 'string'
When I append the 'hex' of 'ethereum address' to 'blockchainAccountId'
When I move 'blockchainAccountId' in 'verification-key'
# type
When I set 'type' to 'EcdsaSecp256k1RecoveryMethod2020' as 'string'
When I move 'type' in 'verification-key'
# id
When I copy 'did:dyne:' to 'id'
When I append the string '#ethereum_address' to 'id'
When I move 'id' in 'verification-key'
# controller
When I copy the 'did:dyne:' to 'controller' in 'verification-key'
When I move 'verification-key' in 'verificationMethod'

When I move 'verificationMethod' in 'did document'
### DID-Document ended

# print did document
Then print the 'did document' as 'string' in 'request'
16 changes: 16 additions & 0 deletions client/v1/issuer/request_input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"did_spec": "sandbox.genericissuer",
"@context": [
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/suites/ed25519-2018/v1",
"https://w3id.org/security/suites/secp256k1-2019/v1",
"https://w3id.org/security/suites/secp256k1-2020/v1",
"https://dyne.github.io/W3C-DID/specs/ReflowBLS12381.json",
"https://dyne.github.io/W3C-DID/specs/IssuerBLS12381.json",
"https://dyne.github.io/W3C-DID/specs/Bbs.json",
"https://dyne.github.io/W3C-DID/specs/EcdsaSecp256r1.json",
{
"description": "https://schema.org/description"
}
]
}

0 comments on commit e1c3a12

Please sign in to comment.