Skip to content

Commit

Permalink
feat(did-key): Add EBSI Natural Person Format
Browse files Browse the repository at this point in the history
Fixed link to EBSI docs
  • Loading branch information
Ian Hamilton committed Apr 2, 2024
1 parent a47fa92 commit 7c8aaeb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions did-key/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const DID_KEY_BLS12381_G2_PREFIX: [u8; 2] = [0xeb, 0x01];
const DID_KEY_P256_PREFIX: [u8; 2] = [0x80, 0x24];
const DID_KEY_P384_PREFIX: [u8; 2] = [0x81, 0x24];
const DID_KEY_RSA_PREFIX: [u8; 2] = [0x85, 0x24];
const DID_KEY_JWK_JCS_PUB_PREFIX: [u8; 3] = [0xd1, 0xd6, 0x03]; // see: https://hub.ebsi.eu/vc-framework/did/did-methods/natural-person
const DID_KEY_JWK_JCS_PUB_PREFIX: [u8; 3] = [0xd1, 0xd6, 0x03]; // see: https://hub.ebsi.eu/vc-framework/did/natural-person

#[derive(Error, Debug)]
pub enum DIDKeyError {
Expand Down Expand Up @@ -220,7 +220,7 @@ impl DIDResolver for DIDKey {
&& data[2] == DID_KEY_JWK_JCS_PUB_PREFIX[2]
{
// For EBSI compliance - multicodec jwk_jcs-pub
// see: https://hub.ebsi.eu/vc-framework/did/did-methods/natural-person
// see: https://hub.ebsi.eu/vc-framework/did/natural-person
vm_type = "JsonWebKey2020".to_string();
vm_type_iri = "https://w3id.org/security#JsonWebKey2020".to_string();
if let Ok(jwk) = serde_json::from_slice(&data[3..]) {
Expand Down Expand Up @@ -471,7 +471,7 @@ mod tests {

#[async_std::test]
async fn from_did_key_jwk_jcs_pub() {
// https://hub.ebsi.eu/vc-framework/did/did-methods/natural-person
// https://hub.ebsi.eu/vc-framework/did/natural-person

let did = "did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9Kbs995rh8qKeDHQgTwf22MTWWYFWQKZPYDz7LLTA4orkBZBHxzasmpiz7wa9BkwwMcjtxm4RUqQNJptsy6NDuXWFNSyc86uaCmiyP1k1uL2xHChFhpU1MQpUmYhSrwrQr8u2";
let (res_meta, _doc, _doc_meta) = DIDKey
Expand Down
2 changes: 1 addition & 1 deletion ssi-jwk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ fn p384_parse_private(data: &[u8]) -> Result<JWK, Error> {
Ok(jwk)
}

/// handle the JWK JCS multicodec used by EBSI. See https://hub.ebsi.eu/vc-framework/did/did-methods/natural-person.
/// handle the JWK JCS multicodec used by EBSI. See https://hub.ebsi.eu/vc-framework/did/natural-person.
fn jwk_jcs_parse(data: &[u8]) -> Result<JWK, Error> {
let json_result: Result<JWK, serde_json::Error> = serde_json::from_slice(data);
match json_result {
Expand Down
2 changes: 1 addition & 1 deletion ssi-jwk/src/multicodec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub enum Codec {
P384Pub = 0x1201,
P521Pub = 0x1202,
RSAPub = 0x1205,
JWKJCSPub = 0xeb51, // see: https://hub.ebsi.eu/vc-framework/did/did-methods/natural-person
JWKJCSPub = 0xeb51, // see: https://hub.ebsi.eu/vc-framework/did/natural-person
Ed25519Priv = 0x1300,
Secp256k1Priv = 0x1301,
RSAPriv = 0x1305,
Expand Down

0 comments on commit 7c8aaeb

Please sign in to comment.