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

fix: use apollo for secp256k1 in shared-crypto #971

Merged
merged 1 commit into from
Apr 17, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -423,24 +423,22 @@ object ManagedDIDServiceSpec
testDIDSvc <- ZIO.service[TestDIDService]
did <- initPublishedDID
_ <- testDIDSvc.setResolutionResult(Some(resolutionResult()))
_ <- ZIO.foreach(1 to 5) { _ =>
val actions = Seq(UpdateManagedDIDAction.RemoveKey("key-1"))
_ <- ZIO.foreach(1 to 5) { i =>
val actions = Seq(UpdateManagedDIDAction.RemoveKey(s"key-$i"))
svc.updateManagedDID(did, actions)
}
_ <- ZIO.foreach(1 to 5) { _ =>
_ <- ZIO.foreach(1 to 5) { i =>
val actions =
Seq(UpdateManagedDIDAction.AddKey(DIDPublicKeyTemplate("key-1", VerificationRelationship.Authentication)))
Seq(
UpdateManagedDIDAction.AddKey(DIDPublicKeyTemplate(s"key-$i", VerificationRelationship.Authentication))
)
svc.updateManagedDID(did, actions)
}
lineage <- svc.nonSecretStorage.listUpdateLineage(None, None)
} yield {
// There are a total of 10 updates: 5 add-key updates & 5 remove-key updates.
// There should be 10 unique operationId (randomness in signature) and
// 6 unique operationHash since remove-key update all have the same content
// and add-key all have different content (randomness in key generation).
assert(lineage)(hasSize(equalTo(10)))
&& assert(lineage.map(_.operationId).toSet)(hasSize(equalTo(10)))
&& assert(lineage.map(_.operationHash).toSet)(hasSize(equalTo(6)))
&& assert(lineage.map(_.operationHash).toSet)(hasSize(equalTo(10)))
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ trait Apollo {
object Apollo {
def layer: ULayer[Apollo] = ZLayer.succeed(default)

// TODO: migrate to KMP Apollo and support other key types
def default: Apollo = new {
override def secp256k1: Secp256k1KeyOps = Prism14Secp256k1Ops
override def secp256k1: Secp256k1KeyOps = KmpSecp256k1KeyOps
override def ed25519: Ed25519KeyOps = ???
override def x25519: X25519KeyOps = ???
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,6 @@ object ApolloSpec extends ZIOSpecDefault {
signature = privateKey.sign(message)
} yield assert(publicKey.verify(message, signature))(isFailure)
},
test("sign the same message multiple time should produce different signature") {
val message = BigInt("42").toByteArray
for {
apollo <- ZIO.service[Apollo]
keyPair <- apollo.secp256k1.generateKeyPair
privateKey = keyPair.privateKey
signature1 = privateKey.sign(message)
signature2 = privateKey.sign(message)
} yield assert(signature1)(not(equalTo(signature2)))
}
)

private val secp256k1Spec = suite("Secp256k1Ops")(
Expand Down

This file was deleted.

Loading