Giter Club home page Giter Club logo

foundation-ur-py's People

Contributors

foundationken avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

foundation-ur-py's Issues

Publish on pypi.org?

Hi!

Thanks for implementing this in Python!

Have you considered publishing the package on pypi.org?

UR decode receive part fails because of crc32 checksum calculation

Occasionally UR decoding fails to decode a fragment when it shouldn't. It fails to decode the fragment because the checksum included in the body does not match the calculated checksum. I believe the issue is that the calculated checksum is the wrong byte size. Here is an example fragment that reproduces the issue. Other UR libs appear to decode this fragment successfully.

fragment = "UR:CRYPTO-PSBT/20-29/LPBBCSCACFCMCPCYBBRSPTSKHDSSDTSBTKDECHRHPKHKVWMDMNKSGDAOAEAEAEAEAECHPTBBEODKPLETLBLDAMJOPMBNPEPLWMFZLTZTHGOEQZTELTLGAYCHAEAEAEAEAECHPTBBFXSAWKIDLTENBSKPJLFEFLMNCLPKEMTPWPMHMHIOLTKECSAMAEAEAEAEAECHPTBBINTKMWZMYNKNKEZCBGKTHDFEZOPAYNPRMEFTHPKGLTAEAEAEAEADADDNEMMDAAAEAEAEAEAECPAECXHDGWFDVTSPHDOLBNKIGETEECLKOSOXLPJSSNFXSGCLAHESJSVTURDYJZCWSRKNDTADAHTKGHCLAOFSTDLNUYSAASIESFDNRKHSMNJZTONLPSLDWFTDMNINOXEHHNKOTODRWPCHRORHDACLAEETWDVL"

ur_decoder = URDecoder()
status = ur_decoder.receive_part(fragment)

Bytewords.decode throws the exception 'Invalid Bytewords.' because the calculated crc32 checksum does not match the checksum on the body of the fragment. I believe the issue is that the calculated checksum is not returning from crc32_bytes as a 32 bit integer.

For the above example the checksum included in the fragment is 0038eae3 in hex. But the checksum returned by crc32_bytes is 38eae3. So on line 110 of bytewords.py the check if checksum != body_checksum: is false.

When I hard code the byte length in the crc32n function to be 4 bytes this seems to fix the issue, but I don't know what the "correct" way would be to handle this.

I changed:
return n.to_bytes((bit_length(n) + 7) // 8, 'big')

to:
return n.to_bytes(4, 'big')

and this makes this issue go away as far as I can tell

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.