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

[Bug] Problems with Window Table #9

Open
alexpArtos opened this issue Feb 19, 2019 · 0 comments
Open

[Bug] Problems with Window Table #9

alexpArtos opened this issue Feb 19, 2019 · 0 comments

Comments

@alexpArtos
Copy link

I think there is a bug in the Window Table calculation in the SerialSetup.java.
Around line 90, there is this block of code that initializes the window table.

        config.beginLog("Generating G1 MSM Window Table");
        final G1T generatorG1 = g1Factory.random(config.seed(), config.secureSeed());
        final int scalarCountG1 = nonZeroAt + nonZeroBt + numVariables;
        final int scalarSizeG1 = generatorG1.bitSize();
        final int windowSizeG1 = FixedBaseMSM.getWindowSize(scalarCountG1, generatorG1);
        final List<List<G1T>> windowTableG1 = FixedBaseMSM
                .getWindowTable(generatorG1, scalarSizeG1, windowSizeG1);
        config.endLog("Generating G1 MSM Window Table");

The scalarSizeG1 is set to the size of the generator, and this returns the minimum number of bits that can represent generatorG1. If I pick this to be g1Factory.one() (a valid generator), the scalarSizeG1 would be 2 and the window table would be too small. I did some basic tests for batchMSM with such a table (with scalars between 1 and 10) and it could not accurately compute the multiples of generatorG1, because it did not inspect all the bits of the scalars.

I think this should not really depend on the generator but be an attribute of the type used. Otherwise, even when uniformly sampling the generator, we should get a wrong number of bits with reasonable probability.

I did a quick fix for my particular use case (non-generic) like this. A better fix should be capable of taking the type into account:

scalarSizeG1 = (int) BN254aFields.BN254aFr.FrParameters.numBits();
@alexpArtos alexpArtos changed the title Problems with Window Table [Bug] Problems with Window Table Mar 5, 2019
doutv pushed a commit to doutv/dizk that referenced this issue Jul 5, 2023
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

1 participant