Skip to content
This repository has been archived by the owner on Feb 8, 2019. It is now read-only.

Improve in-memory exponent table creation #114

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tellison
Copy link
Member

Accumulate values in expTable rather than repeatedly compute powers.

Please take a look. This benches faster for me.

@tellison
Copy link
Member Author

Sigh, I don't know why this Maven plugin is failing. I will close and re-open this PR to cause a retest and see if that fixes it.

@tellison tellison closed this Oct 28, 2016
@tellison tellison reopened this Oct 28, 2016
{
BigInteger value = ModPowAbstraction.modPow(element, BigInteger.valueOf(i), NSquared);
value = value.multiply(element).mod(NSquared);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was ModPowAbstraction removed here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... to avoid the need to compute the power of each big integer. The point of the PR is to just use multiplication.

For example, the code may be creating an expTable with 256 powers of a number of big integers.

In the current implementation using ModPowAbstration that is achieved by computing all 256 powers individually, i.e. element^0, element^1, ... element^255. Clearly as we build the table we know the value for (element-1)^n so we can simply remember the previous value and multiply it by element to find the next value.

This runs faster in my benchmarking.

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

Successfully merging this pull request may close these issues.

2 participants