hypersign-protocol / hid-node

A permissionless blockchain network to manage digital identity and access rights
https://hypersign.id
Apache License 2.0
226 stars 23 forks source link

PublicKeyMultibase should be 48 bytes #148

Closed Vishwas1 closed 2 years ago

Vishwas1 commented 2 years ago

As per spec:

https://w3c-ccg.github.io/lds-ed25519-2020/#ed25519verificationkey2020

The publicKeyMultibase property of the verification method MUST be a public key encoded according to [MULTICODEC] and formatted according to [MULTIBASE]. The multicodec encoding of a Ed25519 public key is the two-byte prefix 0xed01 followed by the 32-byte public key data.

If you look at Digital bazar, they seems to be right:

Prefixing the 45 byte key with two byte data https://github.com/digitalbazaar/ed25519-verification-key-2020/blob/f78c8fd6e0c9debc205795529fb569f5b9c864fe/lib/Ed25519VerificationKey2020.js#L13

const MULTICODEC_ED25519_PUB_HEADER = new Uint8Array([0xed, 0x01]);

const publicKeyMultibase =  _encodeMbKey(MULTICODEC_ED25519_PUB_HEADER, keyObject.publicKey);

Same Goes for priatekey https://w3c-ccg.github.io/lds-ed25519-2020/#example-4

 "publicKeyMultibase": "z6Mkf5rGMoatrSj1f4CyvuHBeXJELe9RPdzo2PKGNCKVtZxP",
 "privateKeyMultibase": "zrv3kJcnBP1RpYmvNZ9jcYpKBZg41iSobWxSg3ix2U7Cp59kjwQFCT4SZTgLSL3HP8iGMdJs3nedjqYgNn6ZJmsmjRm"
arnabghose997 commented 2 years ago

The W3C spec mentioned in the description is unofficial draft published on 26 July 2021.

The latest draft ( https://www.w3.org/TR/did-core/#dfn-publickeymultibase ) doesn't meantions about prefix 2 byte array to publicKeyMultibase