Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting java.lang.StackOverflowError for exponent function #51

Open
someone235 opened this issue Mar 4, 2019 · 2 comments
Open

Getting java.lang.StackOverflowError for exponent function #51

someone235 opened this issue Mar 4, 2019 · 2 comments

Comments

@someone235
Copy link

When trying to create keys for the below code, I get this error: java.lang.StackOverflowError. Is there a way to fix it? Or is it not possible to make a loop with unknown number of iterations?

#include <stdint.h>

struct In {
        uint8_t number;
        uint8_t exponent;
};

struct Out {
        uint64_t result;
};

void compute(struct In *input, struct Out *output) {
        output->result = input->number;
        uint8_t i = input->exponent;
        for(; i > 0; i--){
                output->result = output->result * input->number;
        }
}
@MorelSerge
Copy link

It should be, check out the rle_decode_flat example.

@maxhowald
Copy link
Contributor

All loops must be statically bound at compile time, so that they can be compiled to an arithmetic circuit.

You can use the buffetfsm loop transformer to statically bound your loops without re-writing your code. To do this, just make sure you've built the loop transformer using the install_buffet.sh script, and include the annotation in your computation before your loop: [[buffet::fsm(LOOP_BOUND)]]

(see here for an example use.)

For more information on the static loop bound restriction and the loop transformer, you can check out this paper: https://eprint.iacr.org/2014/674.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants