@Override public DRes<SInt> randomElement() { this.randElmCount++; return this.delegate.randomElement(); }
DRes<SInt> r = b.numeric().randomElement(); DRes<SInt> inverse = b.advancedNumeric().invert(r); List<DRes<SInt>> values = new ArrayList<>(pipeLength + 2);
@Override public void test() { Application<List<BigInteger>, ProtocolBuilderNumeric> app = producer -> { Numeric numeric = producer.numeric(); Collections collections = producer.collections(); int numElements = 10; List<DRes<SInt>> elements = new ArrayList<>(numElements); for (int i = 0; i < numElements; i++) { elements.add(numeric.randomElement()); } DRes<List<DRes<BigInteger>>> opened = collections.openList(() -> elements); return () -> opened.out().stream().map(DRes::out) .collect(Collectors.toList()); }; List<BigInteger> elements = runApplication(app); assertAllDifferent(elements); Assert.assertEquals(10, elements.size()); } };
DRes<SInt> mimcKey = builder.numeric().randomElement(); return builder.par(par -> { Matrix<DRes<SInt>> inputRows = shuffled.out();
@Override public DRes<SInt> buildComputation(ProtocolBuilderNumeric builder) { Numeric numeric = builder.numeric(); DRes<SInt> random = numeric.randomElement(); DRes<SInt> product = numeric.mult(value, random); DRes<BigInteger> open = numeric.open(product); return builder.seq((seq) -> { BigInteger value = open.out(); BigInteger inverse = value.modInverse(seq.getBasicNumericContext().getModulus()); return seq.numeric().mult(inverse, random); }); } }