Giter VIP home page Giter VIP logo

Comments (2)

clehner avatar clehner commented on July 30, 2024

That length check refers to the length of the decoded data - the bytes before encoding with multibase/base58btc.
did:key doesn't place limits on the size of the encoded string or the inner bytes. But some key types have specific-sized public keys. I've responded about the length of secp256k1 keys in #93 (comment).

The length of a byte string encoded into base58 would be: Math.ceil(byteString.length * 8 / Math.log2(58))

For example, a secp256k public key of 33 bytes, plus the 2-byte multicodec prefix is 35 bytes:
Math.ceil(35 * 8 / Math.log2(58)) = 48.
This corresponds to the length of "Q3shokFTS3brHcDQrn82RUDfCZESWL1ZdCEJwekUDPQiYBme" in the example did:key. Then adding the prefix "did:key:z" (z in multicodec indicating base58btc) gives the complete DID which is 57 characters in length.

from ssi.

wyc avatar wyc commented on July 30, 2024

I see we consider variable length base58 encoding here:

let method_specific_id = &did[8..];

Thanks!

from ssi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.