Giter Site home page Giter Site logo

Comments (4)

ivokub avatar ivokub commented on June 25, 2024

Indeed, making it parametric is an option, but I think it would still be a bit confusing. We have actually stumbled a few times when hashing from bytes to fr.Element inside MiMC, for example in cases when input byte slice overflows fr.Element.

My proposal has been to instead implement a new hash interface which takes as an input fr.Element (see #448), but the problem with the approach is that we would have to have separate interfaces for every supported field or use type parameters (which has been shown to be slow and may not be most intuitive). Then, it would be up to the user to perform the hashing from bytes to fr.Element (for example by using hash-to-field) in a most convenient way.

But until that as a workaround having either optional endianness or different MiMC constructor seems reasonable. cc @ThomasPiellard and @gbotrel, what do you think?

from gnark-crypto.

hussein-aitlahcen avatar hussein-aitlahcen commented on June 25, 2024

Indeed, making it parametric is an option, but I think it would still be a bit confusing. We have actually stumbled a few times when hashing from bytes to fr.Element inside MiMC, for example in cases when input byte slice overflows fr.Element.

My proposal has been to instead implement a new hash interface which takes as an input fr.Element (see #448), but the problem with the approach is that we would have to have separate interfaces for every supported field or use type parameters (which has been shown to be slow and may not be most intuitive). Then, it would be up to the user to perform the hashing from bytes to fr.Element (for example by using hash-to-field) in a most convenient way.

But until that as a workaround having either optional endianness or different MiMC constructor seems reasonable. cc @ThomasPiellard and @gbotrel, what do you think?

Also random question regarding this: would it be cryptographically insecure to consider MiMC as a 253bit (avoid the modulus) block-cipher hash function? If not we could have a sha2-like interface ingesting arbitrary bytes?

from gnark-crypto.

gbotrel avatar gbotrel commented on June 25, 2024

Technically we can do both -- for the "hash interface that takes bytes", add in the constructor an option (retro compatible change) with an enum big / little endian.
And if one days it comes to it that doesn't prevent us from doing #448 .

from gnark-crypto.

ivokub avatar ivokub commented on June 25, 2024

Also random question regarding this: would it be cryptographically insecure to consider MiMC as a 253bit (avoid the modulus) block-cipher hash function? If not we could have a sha2-like interface ingesting arbitrary bytes?

It should indeed be a secure cryptographic hash function. The issue it is not usually used outside of circuits is that it is quite slow. But in circuit due to the algebraic nature it is better than SHA2.

The problem with current interface (that MiMC implements hash.Hash i.e. ingests bytes) is that we have to split the input into log(q) bit partitions, construct individual fr.Element from the partitions and then run MiMC. But the individual partitions could overflows the field. So, we would rather have to represent the input byte slice as base q big integer, but this is very memory-expensive when the inputs are a few MBs.

from gnark-crypto.

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.