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

Updating to JsonWebKey #220

Closed
wants to merge 2 commits into from
Closed
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 @@ -20,7 +20,7 @@ import web5.sdk.dids.Did
import web5.sdk.dids.extensions.load
import web5.sdk.dids.methods.ion.CreateDidIonOptions
import web5.sdk.dids.methods.ion.DidIon
import web5.sdk.dids.methods.ion.JsonWebKey2020VerificationMethod
import web5.sdk.dids.methods.ion.JsonWebKeyVerificationMethod
import web5.sdk.dids.methods.key.DidKey
import web5.sdk.testing.TestVectors
import java.io.File
Expand Down Expand Up @@ -123,7 +123,7 @@ class VerifiableCredentialTest {
//Create an ION DID without an assertionMethod
val alias = keyManager.generatePrivateKey(AlgorithmId.secp256k1)
val verificationJwk = keyManager.getPublicKey(alias)
val key = JsonWebKey2020VerificationMethod(
val key = JsonWebKeyVerificationMethod(
id = UUID.randomUUID().toString(),
publicKeyJwk = verificationJwk,
relationships = emptyList() //No assertionMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import web5.sdk.crypto.AlgorithmId
import web5.sdk.crypto.InMemoryKeyManager
import web5.sdk.dids.methods.ion.CreateDidIonOptions
import web5.sdk.dids.methods.ion.DidIon
import web5.sdk.dids.methods.ion.JsonWebKey2020VerificationMethod
import web5.sdk.dids.methods.ion.JsonWebKeyVerificationMethod
import web5.sdk.dids.methods.key.DidKey
import java.security.SignatureException
import java.text.ParseException
Expand Down Expand Up @@ -231,7 +231,7 @@ class VerifiablePresentationTest {
//Create an ION DID without an assertionMethod
val alias = keyManager.generatePrivateKey(AlgorithmId.secp256k1)
val verificationJwk = keyManager.getPublicKey(alias)
val key = JsonWebKey2020VerificationMethod(
val key = JsonWebKeyVerificationMethod(
id = UUID.randomUUID().toString(),
publicKeyJwk = verificationJwk,
relationships = emptyList() //No assertionMethod
Expand Down
6 changes: 3 additions & 3 deletions dids/src/main/kotlin/web5/sdk/dids/methods/ion/DidIon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -817,14 +817,14 @@ public class VerificationMethodCreationParams(
*
* The [id] property cannot be over 50 chars and must only use characters from the Base64URL character set.
*/
public class JsonWebKey2020VerificationMethod(
public class JsonWebKeyVerificationMethod(
public val id: String,
public val controller: String? = null,
public val publicKeyJwk: JWK,
public val relationships: Iterable<PublicKeyPurpose> = emptySet()
) : VerificationMethodSpec, VerificationMethodGenerator {
override fun generate(): Pair<String?, PublicKey> {
return Pair(null, PublicKey(id, "JsonWebKey2020", controller, publicKeyJwk, relationships))
return Pair(null, PublicKey(id, "JsonWebKey", controller, publicKeyJwk, relationships))
}
}

Expand Down Expand Up @@ -859,7 +859,7 @@ internal class VerificationMethodKeyManagerGenerator(
alias,
PublicKey(
id = UUID.randomUUID().toString(),
type = "JsonWebKey2020",
type = "JsonWebKey",
publicKeyJwk = publicKeyJwk,
purposes = params.relationships,
)
Expand Down
2 changes: 1 addition & 1 deletion dids/src/main/kotlin/web5/sdk/dids/methods/jwk/DidJwk.kt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public class DidJwk(uri: String, keyManager: KeyManager) : Did(uri, keyManager)
.id(verificationMethodId)
.publicKeyJwk(publicKeyJwk.toJSONObject())
.controller(URI(did))
.type("JsonWebKey2020")
.type("JsonWebKey")
.build()

val verificationMethodRef = VerificationMethod.builder()
Expand Down
2 changes: 1 addition & 1 deletion dids/src/main/kotlin/web5/sdk/dids/methods/key/DidKey.kt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public class DidKey(uri: String, keyManager: KeyManager) : Did(uri, keyManager)
.id(verificationMethodId)
.publicKeyJwk(publicKeyJwk.toJSONObject())
.controller(URI(did))
.type("JsonWebKey2020")
.type("JsonWebKey")
.build()

val verificationMethodRef = VerificationMethod.builder()
Expand Down
14 changes: 7 additions & 7 deletions dids/src/test/kotlin/web5/sdk/dids/methods/ion/DidIonTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class DidIonTest {
InMemoryKeyManager(),
CreateDidIonOptions(
verificationMethodsToAdd = listOf(
JsonWebKey2020VerificationMethod(
JsonWebKeyVerificationMethod(
id = "space is not part of the base64 url chars",
publicKeyJwk = verificationKey
)
Expand Down Expand Up @@ -150,7 +150,7 @@ class DidIonTest {
InMemoryKeyManager(),
CreateDidIonOptions(
verificationMethodsToAdd = listOf(
JsonWebKey2020VerificationMethod(
JsonWebKeyVerificationMethod(
id = "something_thats_really_really_really_really_really_really_long",
publicKeyJwk = verificationKey
)
Expand Down Expand Up @@ -179,7 +179,7 @@ class DidIonTest {
}
val opts = CreateDidIonOptions(
verificationMethodsToAdd = listOf(
JsonWebKey2020VerificationMethod(
JsonWebKeyVerificationMethod(
id = verificationKey.keyID,
publicKeyJwk = verificationKey,
relationships = listOf(PublicKeyPurpose.AUTHENTICATION),
Expand Down Expand Up @@ -273,7 +273,7 @@ class DidIonTest {
),
TestCase(
publicKeys = listOf(
JsonWebKey2020VerificationMethod(
JsonWebKeyVerificationMethod(
id = "#publicKey1",
publicKeyJwk = publicKey,
)
Expand All @@ -282,12 +282,12 @@ class DidIonTest {
),
TestCase(
publicKeys = listOf(
JsonWebKey2020VerificationMethod(
JsonWebKeyVerificationMethod(
id = "publicKey1",
publicKeyJwk = publicKey,
),

JsonWebKey2020VerificationMethod(
JsonWebKeyVerificationMethod(
id = "publicKey1",
publicKeyJwk = publicKey,
)
Expand All @@ -296,7 +296,7 @@ class DidIonTest {
),
TestCase(
publicKeys = listOf(
JsonWebKey2020VerificationMethod(
JsonWebKeyVerificationMethod(
id = "publicKey1",
publicKeyJwk = publicKey,
relationships = listOf(PublicKeyPurpose.AUTHENTICATION, PublicKeyPurpose.AUTHENTICATION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class DidKeyTest {
// Note: cannot run the controller assertion because underlying lib enforces JSON-LD @context
// despite it not being a required field
// assertEquals(did, verificationMethod.controller.toString())
assertEquals("JsonWebKey2020", verificationMethod.type)
assertEquals("JsonWebKey", verificationMethod.type)
assertNotNull(verificationMethod.publicKeyJwk)

val publicKeyJwk = JWK.parse(verificationMethod.publicKeyJwk) // validates
Expand Down
2 changes: 1 addition & 1 deletion dids/src/test/resources/basic_did_resolution.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"kty": "OKP",
"x": "CV-aGlld3nVdgnhoZK0D36Wk-9aIMlZjZOK2XhPMnkQ"
},
"type": "JsonWebKey2020"
"type": "JsonWebKey"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"x": "nIqlRCx0eyBSXcQnqDpReSv4zuWhwCRWssoc9L_nj6A",
"y": "iG29VK6l2U5sKBZUSJePvyFusXgSlK2dDFlWaCM8F7k"
},
"type": "JsonWebKey2020"
"type": "JsonWebKey"
}
],
"authentication": [
Expand Down
2 changes: 1 addition & 1 deletion dids/src/test/resources/did_jwk_p256_document.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"verificationMethod": [
{
"id": "did:jwk:eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6ImFjYklRaXVNczNpOF91c3pFakoydHBUdFJNNEVVM3l6OTFQSDZDZEgyVjAiLCJ5IjoiX0tjeUxqOXZXTXB0bm1LdG00NkdxRHo4d2Y3NEk1TEtncmwyR3pIM25TRSJ9#0",
"type": "JsonWebKey2020",
"type": "JsonWebKey",
"controller": "did:jwk:eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6ImFjYklRaXVNczNpOF91c3pFakoydHBUdFJNNEVVM3l6OTFQSDZDZEgyVjAiLCJ5IjoiX0tjeUxqOXZXTXB0bm1LdG00NkdxRHo4d2Y3NEk1TEtncmwyR3pIM25TRSJ9",
"publicKeyJwk": {
"crv": "P-256",
Expand Down
2 changes: 1 addition & 1 deletion dids/src/test/resources/did_jwk_x25519_document.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"verificationMethod": [
{
"id": "did:jwk:eyJrdHkiOiJPS1AiLCJjcnYiOiJYMjU1MTkiLCJ1c2UiOiJlbmMiLCJ4IjoiM3A3YmZYdDl3YlRUVzJIQzdPUTFOei1EUThoYmVHZE5yZngtRkctSUswOCJ9#0",
"type": "JsonWebKey2020",
"type": "JsonWebKey",
"controller": "did:jwk:eyJrdHkiOiJPS1AiLCJjcnYiOiJYMjU1MTkiLCJ1c2UiOiJlbmMiLCJ4IjoiM3A3YmZYdDl3YlRUVzJIQzdPUTFOei1EUThoYmVHZE5yZngtRkctSUswOCJ9",
"publicKeyJwk": {
"kty": "OKP",
Expand Down
2 changes: 1 addition & 1 deletion web5-spec
Loading