Code Monkey home page Code Monkey logo

Comments (19)

skorokithakis avatar skorokithakis commented on August 23, 2024 2

Yep, everything works, thank you!

from py-cid.

dhruvbaldawa avatar dhruvbaldawa commented on August 23, 2024 1

Update: It will take some time for me to completely resolve the issue, I have most of the things fixed but few tests are failing because of a bug in the implementation of multibase, so working on fixing that.

from py-cid.

dhruvbaldawa avatar dhruvbaldawa commented on August 23, 2024 1

I have made another release, you can just install it and verify.. the requirements have also been relaxed

from py-cid.

dhruvbaldawa avatar dhruvbaldawa commented on August 23, 2024

Hi @skorokithakis, I checked the implementation. In this case, we default to checking if this is a valid CIDv0 string or not.

And since CIDv0 is base58 encoded and the alphabets that are legal values are 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz, these strings are a valid base58-encoded CIDs, unless I am missing something here.

Does that makes sense? If you however do something like cid.is_cid("!") you should see a ValueError, this is a ValueError because it is not handled yet. I should be handling this, I will fix this and make a release.

from py-cid.

skorokithakis avatar skorokithakis commented on August 23, 2024

Ah, I see, so basically it's more generic than I thought. I wanted to check that the hashes were valid IPFS hashes, Do you know if there is there any less general check I could run to further ensure that they're IPFS-generated? I'm looking for a validation function that will be as strict as possible while still covering all IPFS-generated hashes.

from py-cid.

dhruvbaldawa avatar dhruvbaldawa commented on August 23, 2024

I am not very sure about how helpful this will be, but we have the function that makes a CID object from a string and it fails under certain scenarios, maybe a helper function on top of this should help, I am not sure.

This is the function, the documentation mentions the scenarios in which it raises a ValueError - https://py-cid.readthedocs.io/en/stable/api_reference.html#cid.make_cid

from py-cid.

skorokithakis avatar skorokithakis commented on August 23, 2024

That helps, thanks!

from py-cid.

dhruvbaldawa avatar dhruvbaldawa commented on August 23, 2024

Cool, you are welcome!

from py-cid.

skorokithakis avatar skorokithakis commented on August 23, 2024

This issue should probably be reopened, as it looks like it's actually buggy. For example, CIDs should b e more than 3 bytes long, and this tool shows that many hashes that py-cid considers valid are actually invalid. This looks like something that would be very handy for a test suite (ie valid vs invalid CIDs).

from py-cid.

skorokithakis avatar skorokithakis commented on August 23, 2024

CCing @lidel here.

from py-cid.

lidel avatar lidel commented on August 23, 2024

@dhruvbaldawa I am afraid this is still broken, as noted by @skorokithakis:

Sadly I don't have free bandwidth to implement fixes, but I've added tests in #20 with valid and invalid CID samples that should help with identifying what is missing. Hope it helps :)

from py-cid.

dhruvbaldawa avatar dhruvbaldawa commented on August 23, 2024

@lidel thanks this should help.. I am trying to understand the js implementation and see what we are missing here

from py-cid.

lidel avatar lidel commented on August 23, 2024

@dhruvbaldawa js-cid is a good prior art, but if something is unclear the source of truth is https://github.com/ipld/cid#decoding-algorithm

from py-cid.

dhruvbaldawa avatar dhruvbaldawa commented on August 23, 2024

Yes, I went through the code and realized that I am missing one key part here, which is this - https://github.com/ipld/js-cid/blob/master/src/cid-util.js#L32

Unfortunately, the current multihash library does not have validate, so I am integrating another library

from py-cid.

skorokithakis avatar skorokithakis commented on August 23, 2024

Ah okay, thank you for the heads up!

from py-cid.

dhruvbaldawa avatar dhruvbaldawa commented on August 23, 2024

@skorokithakis i have released a new version today, can you please check?

from py-cid.

skorokithakis avatar skorokithakis commented on August 23, 2024

I'm trying, unfortunately the py-multiformats packages are being way too strict and requiring six==1.10.0 which breaks my package manager, as another project is requiring 1.11.0, so nothing can be installed... I'll get back to you if I manage the installation, thank you.

from py-cid.

skorokithakis avatar skorokithakis commented on August 23, 2024

cid.is_cid("hash") crashes, unfortunately.

from py-cid.

dhruvbaldawa avatar dhruvbaldawa commented on August 23, 2024

I am sorry, I have incorporated your hypothesis tests and also added a bunch of other fixes in related multiformats repos, I can see hypothesis consistently passing tests, can you have a look?

from py-cid.

Related Issues (6)

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.