Skip to content

Commit

Permalink
Started implementing C++ compose.
Browse files Browse the repository at this point in the history
  • Loading branch information
geekbeast committed Mar 17, 2015
1 parent 196c2f4 commit d92e182
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Binary file not shown.
17 changes: 15 additions & 2 deletions krypto-lib/src/main/cpp/MultivariatePolynomialFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class MultivariatePolynomialFunction {

return f;
}

const BitVector<NUM_OUTPUTS> operator()(
const BitVector<NUM_OUTPUTS> operator()(
const BitVector<NUM_INPUTS> & input) {
BitVector<NUM_OUTPUTS> result;
for (int i = 0; i < maxMonomialCount; ++i) {
Expand All @@ -64,6 +64,19 @@ class MultivariatePolynomialFunction {
}
return result;
}

template<unsigned INNER_INPUT_LENGTH>
const MultivariatePolynomialFunction<INNER_INPUT_LENGTH,NUM_OUTPUTS> operator()(
const MultivariatePolynomialFunction<INNER_INPUT_LENGTH,NUM_INPUTS> & input) {
BitVector<NUM_OUTPUTS> result;
for (int i = 0; i < maxMonomialCount; ++i) {
BitVector<NUM_INPUTS> inputMask = _monomials[i] & input;
if (inputMask == input) {
result ^= _contributions[i];
}
}
return result;
}

private:
vector<BitVector<NUM_INPUTS>> _monomials;
Expand Down

0 comments on commit d92e182

Please sign in to comment.