@@ -20,25 +20,12 @@ public class DataIntegrityProofDataIntegritySuite extends DataIntegritySuite {
2020 "eddsa-jcs-2022" , JCSCanonicalizer .getInstance ()
2121 );
2222
23- private static final Map <String , Map <KeyTypeName , String >> JWS_ALGORITHM_BY_CRYPTOSUITE_AND_KEY_TYPE_NAME = Map .of (
24- "ecdsa-rdfc-2019" , Map .of (
25- KeyTypeName .secp256k1 , JWSAlgorithm .ES256K ,
26- KeyTypeName .P_256 , JWSAlgorithm .ES256 ,
27- KeyTypeName .P_384 , JWSAlgorithm .ES384 ,
28- KeyTypeName .P_521 , JWSAlgorithm .ES512
29- ),
30- "ecdsa-jcs-2019" , Map .of (
31- KeyTypeName .Ed25519 , JWSAlgorithm .EdDSA
32- ),
33- "eddsa-rdfc-2022" , Map .of (
34- KeyTypeName .secp256k1 , JWSAlgorithm .ES256K ,
35- KeyTypeName .P_256 , JWSAlgorithm .ES256 ,
36- KeyTypeName .P_384 , JWSAlgorithm .ES384 ,
37- KeyTypeName .P_521 , JWSAlgorithm .ES512
38- ),
39- "eddsa-jcs-2022" , Map .of (
40- KeyTypeName .Ed25519 , JWSAlgorithm .EdDSA
41- )
23+ private static final Map <String , List <String >> CRYPTOSUITES_BY_JWS_ALGORITHM = Map .of (
24+ JWSAlgorithm .EdDSA , List .of ("eddsa-rdfc-2022" , "eddsa-jcs-2022" ),
25+ JWSAlgorithm .ES256K , List .of ("ecdsa-rdfc-2019" , "ecdsa-jcs-2019" ),
26+ JWSAlgorithm .ES256 , List .of ("ecdsa-rdfc-2019" , "ecdsa-jcs-2019" ),
27+ JWSAlgorithm .ES384 , List .of ("ecdsa-rdfc-2019" , "ecdsa-jcs-2019" ),
28+ JWSAlgorithm .ES512 , List .of ("ecdsa-rdfc-2019" , "ecdsa-jcs-2019" )
4229 );
4330
4431 DataIntegrityProofDataIntegritySuite () {
@@ -52,4 +39,17 @@ public class DataIntegrityProofDataIntegritySuite extends DataIntegritySuite {
5239 KeyTypeName .P_521 , List .of (JWSAlgorithm .ES512 )),
5340 List .of (LDSecurityContexts .JSONLD_CONTEXT_W3ID_DATAINTEGRITY_V2 ));
5441 }
42+
43+ public static Canonicalizer findCanonicalizerByCryptosuite (String cryptosuite ) {
44+ return CANONICALIZERS_BY_CRYPTOSUITE .get (cryptosuite );
45+ }
46+
47+ public static List <String > findCryptosuitesByJwsAlgorithm (String jwsAlgorithm ) {
48+ return CRYPTOSUITES_BY_JWS_ALGORITHM .get (jwsAlgorithm );
49+ }
50+
51+ public static String findDefaultCryptosuiteByJwsAlgorithm (String jwsAlgorithm ) {
52+ List <String > foundCryptosuiteByJwsAlgorithm = findCryptosuitesByJwsAlgorithm (jwsAlgorithm );
53+ return foundCryptosuiteByJwsAlgorithm == null ? null : foundCryptosuiteByJwsAlgorithm .get (0 );
54+ }
5555}
0 commit comments