Coder Social home page Coder Social logo

Comments (1)

samtay avatar samtay commented on June 15, 2024 1

This seems like an oversight on our part, thank you for pointing it out. We have arithmetic implementations for field elements F behind ProgramNodes so that you can do arithmetic within a #[zkp_program] function, and I guess we mostly considered the BulletproofsField type on its own to be used for providing static-ish arguments. But I can definitely see how it would be convenient to do some arithmetic on them outside of the ZKP program.

In the meantime, you could just do your arithmetic on a different integral type, and then cast to the BulletproofsField. Your example above would change to something like:

// Create the list out of u32s
let mut counters_list = [0u32; 100];
for (i, f) in counters_list.into_iter().enumerate() {
    if i == alices_index {
        counters_list[i] = f + 1;
    }
}
// Then cast them all to BulletproofsField
let counters_list = counters_list.map(BulletproofsField::from);

For this particular example, there's also a nice stdlib function you could use:

let counters_list: [BulletproofsField; 100] = core::array::from_fn(|i| {
    if i == alices_index {
        1.into()
    } else {
        0.into()
    }
});

from sunscreen.

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.