Skip to content

Commit

Permalink
chore: pr cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Pat Losoponkul committed Jun 9, 2023
1 parent 9be58fb commit 43f13f4
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ object AppModule {

val manageDIDServiceLayer: TaskLayer[ManagedDIDService] = {
val vaultClientLayer = RepoModule.vaultClientLayer
// val jdbcSecretStorageLayer = (RepoModule.agentTransactorLayer ++ apolloLayer) >>> JdbcDIDSecretStorage.layer
val secretStorageLayer = vaultClientLayer >>> VaultDIDSecretStorage.layer
val nonSecretStorageLayer = RepoModule.agentTransactorLayer >>> JdbcDIDNonSecretStorage.layer
val seedResolverLayer =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ class DIDUpdateHandler(
(operation, hdKey) = result
signedOperation <- publicationHandler.signOperationWithMasterKey[UpdateManagedDIDError](state, operation)
} yield HdKeyUpdateMaterial(secretStorage, nonSecretStorage)(operation, signedOperation, state, hdKey)
// case KeyManagementMode.Random =>
// for {
// result <- operationFactory
// .makeUpdateOperationRandKey(did, previousOperationHash, actions)
// (operation, randKey) = result
// signedOperation <- publicationHandler.signOperationWithMasterKey[UpdateManagedDIDError](state, operation)
// } yield RandKeyUpdateMaterial(secretStorage, nonSecretStorage)(operation, signedOperation, state, randKey)
}
}
}
Expand Down Expand Up @@ -85,28 +78,6 @@ trait DIDUpdateMaterial {

}

// class RandKeyUpdateMaterial(secretStorage: DIDSecretStorage, nonSecretStorage: DIDNonSecretStorage)(
// val operation: PrismDIDOperation.Update,
// val signedOperation: SignedPrismDIDOperation,
// val state: ManagedDIDState,
// randKey: UpdateDIDRandKey
// ) extends DIDUpdateMaterial {

// private def persistKeyMaterial: Task[Unit] = {
// val did = operation.did
// val operationHash = operation.toAtalaOperationHash
// ZIO.foreachDiscard(randKey.newKeyPairs) { case (keyId, keyPair) =>
// secretStorage.insertKey(did, keyId, keyPair, operationHash)
// }
// }

// override def persist: Task[Unit] =
// for {
// _ <- persistKeyMaterial
// _ <- persistUpdateLineage(nonSecretStorage)
// } yield ()
// }

class HdKeyUpdateMaterial(secretStorage: DIDSecretStorage, nonSecretStorage: DIDNonSecretStorage)(
val operation: PrismDIDOperation.Update,
val signedOperation: SignedPrismDIDOperation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,64 +42,6 @@ class JdbcDIDSecretStorage(xa: Transactor[Task], apollo: Apollo) extends DIDSecr
given octetKeyPairGet: Get[OctetKeyPair] = Get[String].map(OctetKeyPair.parse)
given octetKeyPairPut: Put[OctetKeyPair] = Put[String].contramap(_.toJSONString)

// override def getKey(did: PrismDID, keyId: String): Task[Option[ECKeyPair]] = {
// // By specification, it is possible to have multiple unconfirmed operation_id with
// // the same operation_hash (same content different signature).
// // However, there can be only 1 confirmed operation_id per operation_hash.
// val status: ScheduledDIDOperationStatus = ScheduledDIDOperationStatus.Confirmed
// val cxnIO = sql"""
// | SELECT
// | sc.key_pair
// | FROM public.prism_did_secret_storage sc
// | LEFT JOIN public.prism_did_wallet_state ws ON sc.did = ws.did
// | LEFT JOIN public.prism_did_update_lineage ul ON sc.operation_hash = ul.operation_hash
// | WHERE
// | sc.did = $did
// | AND sc.key_id = $keyId
// | AND (ul.status = $status OR (ul.status IS NULL AND sc.operation_hash = sha256(ws.atala_operation_content)))
// """.stripMargin
// .query[ECKeyPair]
// .option

// cxnIO.transact(xa)
// }

// override def insertKey(did: PrismDID, keyId: String, keyPair: ECKeyPair, operationHash: Array[Byte]): Task[Int] = {
// val cxnIO = (now: Instant) => sql"""
// | INSERT INTO public.prism_did_secret_storage(
// | did,
// | created_at,
// | key_id,
// | key_pair,
// | operation_hash
// | ) values (
// | ${did},
// | ${now},
// | ${keyId},
// | ${keyPair},
// | ${operationHash}
// | )
// """.stripMargin.update

// Clock.instant.flatMap(cxnIO(_).run.transact(xa))
// }

// override def listKeys(did: PrismDID): Task[Seq[(String, ArraySeq[Byte], ECKeyPair)]] = {
// val cxnIO = sql"""
// | SELECT
// | key_id,
// | operation_hash,
// | key_pair
// | FROM public.prism_did_secret_storage
// | WHERE
// | did = $did
// """.stripMargin
// .query[(String, ArraySeq[Byte], ECKeyPair)]
// .to[List]

// cxnIO.transact(xa)
// }

override def getKey(did: DidId, keyId: String): Task[Option[OctetKeyPair]] = {
val cxnIO = sql"""
| SELECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,9 @@ package object sql {
"PRISM_DID_KEY_MODE",
{
case "HD" => KeyManagementMode.HD
// case "RANDOM" => KeyManagementMode.Random
case s => throw InvalidEnum[KeyManagementMode](s)
},
{ case KeyManagementMode.HD =>
"HD"
// case KeyManagementMode.Random => "RANDOM"
}
{ case KeyManagementMode.HD => "HD" }
)

given Meta[PublicationStatusType] = pgEnumString(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class KeyResolver(apollo: Apollo, nonSecretStorage: DIDNonSecretStorage, secretS
def getKey(did: PrismDID, keyMode: KeyManagementMode, keyId: String): Task[Option[ECKeyPair]] = {
keyMode match {
case KeyManagementMode.HD => resolveHdKey(did, keyId)
// case KeyManagementMode.Random => secretStorage.getKey(did, keyId)
}
}

Expand Down

0 comments on commit 43f13f4

Please sign in to comment.