Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize over basic types, expose more methods for VCs #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion factom-did-client/factom-did-client.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: 669bafb72e32ffedafa3914b1407c80a3d4bd8fa9d989d607fb1fb5ad6388d00
-- hash: 2127389cadcc6740c83d20d2a4dbacf358746f058e50b4132ba8ff49c98ba8b2

name: factom-did-client
version: 0.1.0.0
Expand Down Expand Up @@ -38,12 +38,14 @@ library
, api-rpc-factom
, base >=4.7 && <5
, syb
, text
default-language: Haskell2010

test-suite factom-did-haskell-test
type: exitcode-stdio-1.0
main-is: Spec.hs
other-modules:
Validate
Paths_factom_did_client
hs-source-dirs:
test
Expand All @@ -54,4 +56,5 @@ test-suite factom-did-haskell-test
, base >=4.7 && <5
, factom-did-client
, syb
, text
default-language: Haskell2010
1 change: 1 addition & 0 deletions factom-did-client/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies:
- api-rpc-factom # library to work Factom blockchain
- aeson
- syb
- text

library:
source-dirs: src
Expand Down
35 changes: 26 additions & 9 deletions factom-did-client/src/Lib.hs
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
{-# LANGUAGE OverloadedStrings #-}

module Lib
( id
, getChain
( getChain
, create
, update
, deactivate
, addPurpose
, convertToSchema
, convertToRevIdSchema
, deactivate
, createMGMKey
, createDIDKey
) where

import qualified Data.Text as T

import Types

--------------------------------------------------------------------------------
--

id :: IO ()
id = putStrLn "id"

getChain :: IO ()
getChain = putStrLn "getChain"
create :: IO ()
create = putStrLn "create-did"

update :: IO ()
update = putStrLn "update"

deactivate :: IO ()
deactivate = putStrLn "update"

getChain :: IO ()
getChain = putStrLn "getChain"

addPurpose :: IO ()
addPurpose =
addPurpose = undefined

convertToSchema :: IO ()
convertToSchema =

convertToSchema = undefined

convertToRevIdSchema :: IO ()
convertToRevIdSchema =
convertToRevIdSchema = undefined

createMGMKey = undefined
createDIDKey = undefined
48 changes: 42 additions & 6 deletions factom-did-client/src/Types.hs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}

module Types where

import Data.Generics
import Data.List
import Data.Generics
import Data.List
import qualified Data.Text as T

import Types.Keys

--------------------------------------------------------------------------------

Expand All @@ -20,7 +23,7 @@ didEntrySizeLimit = 10275
--------------------------------------------------------------------------------
-- Representation Types

-- |
-- | Identify type of cryptographic keys used
--
data KeyType =
EdDSA
Expand Down Expand Up @@ -73,3 +76,36 @@ instance Read NetworkType where
"testnet" -> [(TestNet, str)]
"local" -> [(Local , str)]
_ -> [(Unknown, str)]

--------------------------------------------------------------------------------
--

data Service =
Service
{ srvAlias :: T.Text
-- ^ A human-readable nickname for the service endpoint. It should be unique across the services defined in the DID doc.
, srvType :: T.Text
-- ^ Type of the service endpoint.
, srvEndpoint :: T.Text
-- ^ A service endpoint may represent any type of service the subject wishes to advertise, including
, srvPriorityReq :: Maybe Int
-- ^ A non-negative integer showing the minimum hierarchical level a key must have in order to remove thisservice.
, srvCustom :: [(T.Text, T.Text)]
-- ^ A dictionary containing custom fields (e.g "description": "My public social inbox").
} deriving (Eq, Show)

-- | Enables the construction of a DID document,
-- by facilitating the construction of management keys and DID keys and the
-- addition of services. Allows exporting of the resulting DID object into a format suitable
-- for recording on the Factom blockchain.
--
-- Provides encryption functionality of private keys for the DID and their export to a string or to a JSON file
--
data DID =
DID
{ did :: Maybe T.Text -- ^ The decentralized identifier, a 32 byte hexadecimal string
, didKeysMGM :: Maybe [ManagementKey] -- ^ A list of management keys
, didKeys :: Maybe [AbstractKey] -- ^ A list of DID keys
, didServices :: Maybe [Service] -- ^ A list of services
, didSpecVer :: T.Text -- ^ used specification version
} deriving (Eq, Show)
26 changes: 18 additions & 8 deletions factom-did-client/src/Types/Keys.hs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE TypeFamilies #-}

module Types.Keys where

import Data.Generics
import Data.List
import qualified Data.Text as T

-----------------------------------------------------

Expand Down Expand Up @@ -42,17 +44,24 @@ class DIDKey a where

data ApplicationKey =
ApplicationKey
{ pubKey :: String
, privKey :: String
{ pubKey :: T.Text
, privKey :: T.Text
-- , keyType
}
} deriving(Eq, Show)

data ManagementKey =
ManagementKey
{ pubKey :: String
, privKey :: String
{ pubKey :: T.Text
, privKey :: T.Text
-- , keyType
} deriving(Eq, Show)

data AbstractKey =
AbstractKey
{ pubKey :: T.Text
, privKey :: T.Text
-- , keyType
}
} deriving(Eq, Show)

-- | Application-level key that can be used for authentication, signing, encryption, decryption, etc.
instance DIDKey ApplicationKey where
Expand All @@ -62,6 +71,7 @@ instance DIDKey ApplicationKey where
instance DIDKey ManagementKey where
verify _ = undefined


-- other keys
-- ECDSASecp256k1Key
-- Ed25519Key
Expand Down
6 changes: 3 additions & 3 deletions factom-did-client/stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ packages:
extra-deps:
- aeson-1.4.7.1@sha256:6d8d2fd959b7122a1df9389cf4eca30420a053d67289f92cdc0dbc0dab3530ba,7098
- base-compat-0.10.5@sha256:d49e174ed0daecd059c52d13d4f4de87b5609c81212a22adbb92431f9cd58fff,6941
- git: git@github.com:kompendium-ano/factom-haskell-client.git
commit: 98385860c6d4102c3d72fc885591f05bc2b8fc3d
- git: 'https://github.com/kompendium-ano/factom-haskell-client'
commit: ba6c29e0f6bbf9e3f7eaa61923849fb9cb53adc9
- git: 'https://github.com/sigrlami/remote-json'
commit: 'd9e38be7955306418a3a6bc3fff8d15746f23ea0'
subdirs:
- .
- remote-json-client
- git: 'https://github.com/ku-fpg/remote-monad'
commit: '79d22ea2bde876e6640a25472d90fc3d7dd82a3a'
commit: '79d22ea2bde876e6640a25472d90fc3d7dd82a3a'