/// <summary> /// Masks an option (i.e., a sender input message). /// </summary> /// <remarks> /// The option is XOR-masked with the output of a random oracle queried with the /// concatenation of the binary representations of the given groupElement, invocationIndex and optionIndex. /// </remarks> /// <param name="option">The sender input/option to be masked.</param> /// <param name="groupElement">The group element that acts as "key" in the query to the random oracle.</param> /// <param name="invocationIndex">The index of the OT invocation this option belongs to.</param> /// <param name="optionIndex">The index of the option.</param> /// <returns>The masked option.</returns> private byte[] MaskOption(byte[] option, BigInteger groupElement, int invocationIndex, int optionIndex) { using (RandomOracle randomOracle = _randomOracleProvider.Create()) { byte[] query = BufferBuilder.From(groupElement.ToByteArray()).With(invocationIndex).With(optionIndex).Create(); return(randomOracle.Mask(option, query)); } }
public NaorPinkasObliviousTransfer(SecurityParameters parameters, CryptoContext cryptoContext) { _parameters = parameters; _randomOracle = new HashRandomOracle(cryptoContext.HashAlgorithm); _randomNumberGenerator = new ThreadsafeRandomNumberGenerator(cryptoContext.RandomNumberGenerator); #if DEBUG Console.WriteLine("Security parameters:"); Console.WriteLine("p = {0}", _parameters.P); Console.WriteLine("q = {0}", _parameters.Q); Console.WriteLine("g = {0}", _parameters.G); Console.WriteLine("group element size = {0} bytes", _parameters.GroupElementSize); Console.WriteLine("exponent size = {0} bytes", _parameters.ExponentSize); #endif }