dk.alexandra.fresco.suite.spdz.gates.SpdzSubtractProtocolKnownRight Maven / Gradle / Ivy
package dk.alexandra.fresco.suite.spdz.gates;
import dk.alexandra.fresco.framework.DRes;
import dk.alexandra.fresco.framework.network.Network;
import dk.alexandra.fresco.framework.value.SInt;
import dk.alexandra.fresco.suite.spdz.SpdzResourcePool;
import dk.alexandra.fresco.suite.spdz.datatypes.SpdzElement;
import dk.alexandra.fresco.suite.spdz.datatypes.SpdzSInt;
import java.math.BigInteger;
public class SpdzSubtractProtocolKnownRight extends SpdzNativeProtocol {
private DRes left;
private BigInteger right;
private SpdzSInt out;
public SpdzSubtractProtocolKnownRight(DRes left, BigInteger right) {
this.left = left;
this.right = right;
}
@Override
public SpdzSInt out() {
return out;
}
@Override
public EvaluationStatus evaluate(int round, SpdzResourcePool spdzResourcePool,
Network network) {
SpdzSInt left = (SpdzSInt) this.left.out();
SpdzElement knownSpdzElement =
SpdzKnownSIntProtocol.createKnownSpdzElement(spdzResourcePool, right);
this.out = new SpdzSInt(left.value.subtract(knownSpdzElement));
return EvaluationStatus.IS_DONE;
}
}