This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: feat: SDS EDV provider skeleton
Signed-off-by: Derek Trider <Derek.Trider@securekey.com>
- Loading branch information
Derek Trider
committed
Sep 30, 2020
1 parent
e42562d
commit dba30a6
Showing
10 changed files
with
247 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package edvstore | ||
|
||
import ( | ||
"github.com/hyperledger/aries-framework-go/pkg/storage" | ||
"github.com/hyperledger/aries-framework-go/pkg/storage/encryptedstorage/sds/edv/encrypteddocumentprocessor" | ||
) | ||
|
||
type Provider struct { | ||
underlyingProvider storage.Provider | ||
encryptedDocumentProcessor encrypteddocumentprocessor.EncryptedDocumentProcessor | ||
} | ||
|
||
func New(underlyingProvider storage.Provider, | ||
encryptedDocumentProcessor encrypteddocumentprocessor.EncryptedDocumentProcessor) (Provider, error) { | ||
return Provider{ | ||
underlyingProvider: underlyingProvider, | ||
encryptedDocumentProcessor: encryptedDocumentProcessor, | ||
}, nil | ||
} | ||
|
||
func (p Provider) OpenStore(name string) (Store, error) { | ||
panic("implement me") | ||
} | ||
|
||
func (p Provider) CloseStore(name string) error { | ||
panic("implement me") | ||
} | ||
|
||
func (p Provider) Close() error { | ||
panic("implement me") | ||
} | ||
|
||
type Store struct { | ||
underlyingStore storage.Store | ||
encryptedDocumentProcessor encrypteddocumentprocessor.EncryptedDocumentProcessor | ||
} | ||
|
||
func (s Store) Put(k string, v []byte) error { | ||
// Use encrypted document processor to take the raw data v and convert it into an encrypted document. | ||
// Then, we'll marshal it back into bytes and put it in the underlying store. | ||
|
||
panic("implement me") | ||
} | ||
|
||
func (s Store) Get(k string) ([]byte, error) { | ||
// Get the encrypted document from the underlying store. Then, feed it into the processor to get the original | ||
// raw data back. Then, marshal back to bytes so we can return it back. | ||
|
||
panic("implement me") | ||
} | ||
|
||
func (s Store) Iterator(startKey, endKey string) storage.StoreIterator { | ||
panic("implement me") | ||
} | ||
|
||
func (s Store) Delete(k string) error { | ||
panic("implement me") | ||
} | ||
|
||
func (s Store) Query(query string) ([]string, error) { | ||
panic("implement me") | ||
} |
32 changes: 32 additions & 0 deletions
32
...ypteddocumentprocessor/ariesencrypteddocumentprocessor/ariesencrypteddocumentprocessor.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package ariesencrypteddocumentprocessor | ||
|
||
import ( | ||
"github.com/hyperledger/aries-framework-go/pkg/doc/jose" | ||
"github.com/hyperledger/aries-framework-go/pkg/storage/encryptedstorage/sds/edv" | ||
) | ||
|
||
type EncryptedDocumentProcessor struct { | ||
jweEncryptor jose.Encrypter | ||
jweDecryptor jose.Decrypter | ||
} | ||
|
||
func New(jweEncryptor jose.Encrypter, jweDecryptor jose.Decrypter) (EncryptedDocumentProcessor, error) { | ||
return EncryptedDocumentProcessor{ | ||
jweEncryptor: jweEncryptor, | ||
jweDecryptor: jweDecryptor, | ||
}, nil | ||
} | ||
|
||
func (e EncryptedDocumentProcessor) Encrypt(bytes []byte) (edvstore.EncryptedDocument, error) { | ||
panic("implement me") | ||
} | ||
|
||
func (e EncryptedDocumentProcessor) Decrypt(document edvstore.EncryptedDocument) ([]byte, error) { | ||
panic("implement me") | ||
} |
14 changes: 14 additions & 0 deletions
14
...storage/encryptedstorage/sds/edv/encrypteddocumentprocessor/encrypteddocumentprocessor.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package encrypteddocumentprocessor | ||
|
||
import "github.com/hyperledger/aries-framework-go/pkg/storage/encryptedstorage/sds/edv" | ||
|
||
type EncryptedDocumentProcessor interface { | ||
Encrypt([]byte) (edvstore.EncryptedDocument, error) | ||
Decrypt(edvstore.EncryptedDocument) ([]byte, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package edvstore | ||
|
||
import "encoding/json" | ||
|
||
// DataVaultConfiguration represents a Data Vault Configuration. | ||
type DataVaultConfiguration struct { | ||
Sequence int `json:"sequence"` | ||
Controller string `json:"controller"` | ||
Invoker string `json:"invoker"` | ||
Delegator string `json:"delegator"` | ||
ReferenceID string `json:"referenceId"` | ||
KEK IDTypePair `json:"kek"` | ||
HMAC IDTypePair `json:"hmac"` | ||
} | ||
|
||
// StructuredDocument represents a Structured Document. | ||
type StructuredDocument struct { | ||
ID string `json:"id"` | ||
Meta map[string]interface{} `json:"meta"` | ||
Content map[string]interface{} `json:"content"` | ||
} | ||
|
||
// EncryptedDocument represents an Encrypted Document. | ||
type EncryptedDocument struct { | ||
ID string `json:"id"` | ||
Sequence int `json:"sequence"` | ||
IndexedAttributeCollections []IndexedAttributeCollection `json:"indexed,omitempty"` | ||
JWE json.RawMessage `json:"jwe"` | ||
} | ||
|
||
// IndexedAttributeCollection represents a collection of indexed attributes, | ||
// all of which share a common MAC algorithm and key. | ||
type IndexedAttributeCollection struct { | ||
Sequence int `json:"sequence"` | ||
HMAC IDTypePair `json:"hmac"` | ||
IndexedAttributes []IndexedAttribute `json:"attributes"` | ||
} | ||
|
||
// IndexedAttribute represents a single indexed attribute. | ||
type IndexedAttribute struct { | ||
Name string `json:"name"` | ||
Value string `json:"value"` | ||
Unique bool `json:"unique"` | ||
} | ||
|
||
// IDTypePair represents an ID+Type pair. | ||
type IDTypePair struct { | ||
ID string `json:"id"` | ||
Type string `json:"type"` | ||
} | ||
|
||
// Query represents a name+value pair that can be used to query the encrypted indices for specific data. | ||
// The format of the "equals" part does not seem to be fully defined in the spec currently, hence why in this | ||
// model it was left as a general json.RawMessage for now. | ||
// https://github.com/decentralized-identity/secure-data-store/issues/34 | ||
type Query struct { | ||
Name string `json:"index"` | ||
Value json.RawMessage `json:"equals"` | ||
} |
48 changes: 48 additions & 0 deletions
48
pkg/storage/encryptedstorage/sds/edv/restprovider/restprovider.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package restprovider | ||
|
||
import "github.com/hyperledger/aries-framework-go/pkg/storage" | ||
|
||
// Talks to an SDS EDV server via REST calls. | ||
type RESTProvider struct { | ||
} | ||
|
||
func (R RESTProvider) OpenStore(name string) (storage.Store, error) { | ||
panic("implement me") | ||
} | ||
|
||
func (R RESTProvider) CloseStore(name string) error { | ||
panic("implement me") | ||
} | ||
|
||
func (R RESTProvider) Close() error { | ||
panic("implement me") | ||
} | ||
|
||
type RESTStore struct { | ||
} | ||
|
||
func (R RESTStore) Put(k string, v []byte) error { | ||
panic("implement me") | ||
} | ||
|
||
func (R RESTStore) Get(k string) ([]byte, error) { | ||
panic("implement me") | ||
} | ||
|
||
func (R RESTStore) Iterator(startKey, endKey string) storage.StoreIterator { | ||
panic("implement me") | ||
} | ||
|
||
func (R RESTStore) Delete(k string) error { | ||
panic("implement me") | ||
} | ||
|
||
func (R RESTStore) Query(query string) (storage.StoreIterator, error) { | ||
panic("implement me") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters