GithubHelp home page GithubHelp logo

Comments (6)

dtebbs avatar dtebbs commented on August 26, 2024 1

Thanks for raising this @kaxxa123, and for the code snippet. I guess that gadget has not been used for a while and needs some attention (and a test). Feel free to submit a pull request with your fix.

from zeth.

AntoineRondelet avatar AntoineRondelet commented on August 26, 2024

Thanks @kaxxa123! Good catch, the function signature is not satisfied indeed justifying the compilation error.

Rather than quick fixing this and add ZERO back, we should probably bring the sha256 hasher interface in sync with the blake one (which doesn't use ZERO), see:

BLAKE2s_256(
libsnark::protoboard<FieldT> &pb,
const libsnark::block_variable<FieldT> &input,
const libsnark::digest_variable<FieldT> &output,
const std::string &annotation_prefix = "blake2s_gadget");

Removing ZERO from the arguments of the sha constructor begs for a refactoring of this "legacy" function that uses ONE and ZERO. So we need to get rid of the useless directives at the top of the file and use FieldT::one(), FieldT::zero() apropriately here:

// Takes a vector of boolean values, and convert this vector of boolean values
// into a vector of FieldT::zero() and FieldT:one()
template<typename FieldT>
libsnark::pb_variable_array<FieldT> variable_array_from_bit_vector(
const std::vector<bool> &bits, const libsnark::pb_variable<FieldT> &ZERO)
{
libsnark::pb_variable_array<FieldT> acc;
acc.reserve(bits.size());
for (bool bit : bits) {
acc.emplace_back(bit ? ONE : ZERO);
}
return acc;
};

In fact, we should probably use the bits class here and the associated method:

zeth/libzeth/core/bits.tcc

Lines 107 to 119 in 8247fc3

template<size_t numBits>
template<typename FieldT>
void bits<numBits>::fill_variable_array(
libsnark::protoboard<FieldT> &pb,
libsnark::pb_variable_array<FieldT> &var_array) const
{
if (var_array.size() != numBits) {
throw std::invalid_argument("invalid pb_variable_array size");
}
for (size_t i = 0; i < numBits; ++i) {
pb.val(var_array[i]) = ((*this)[i]) ? FieldT::one() : FieldT::zero();
}
}
to fill the pb_variable_array, effectively removing this legacy code that turns out to trigger compilation error.

Let us know if you want to contribute to the project and get a shot at fixing this ticket (if not, no worries at all, we'll close this ticket on our end :) )

from zeth.

kaxxa123 avatar kaxxa123 commented on August 26, 2024

In that case I will leave the fix to you, since for the moment I am still learning about your various gadgets as I work on my dissertation :)

from zeth.

dtebbs avatar dtebbs commented on August 26, 2024

Yes, at some point the code needs to be updated to avoid the ONE and ZERO variables. Happy to do this as a separate change if you did want to submit a PR @kaxxa123. Otherwise we'll keep this issue as a reminder to do it all at once. Either way, thanks again.

from zeth.

AntoineRondelet avatar AntoineRondelet commented on August 26, 2024

In that case I will leave the fix to you, since for the moment I am still learning about your various gadgets as I work on my dissertation :)

No problem! We'll fix this on our end :)

from zeth.

AntoineRondelet avatar AntoineRondelet commented on August 26, 2024

This issue was fixed in #391, closing the ticket as a consequence.

from zeth.

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.