public static SecureWord Multiplex(SecureWord left, SecureWord right, SecureBoolean condition) { if (left.Builder != right.Builder || condition.Builder != right.Builder) { throw new ArgumentException("Secure words must use the same circuit builder for constructing gates."); } if (left.Length != right.Length) { throw new ArgumentException("Secure words must be of same length for multiplexing."); } Wire[] result = new Wire[right.Length]; for (int i = 0; i < right.Length; ++i) { result[i] = right.Builder.Xor( left.Wires[i], right.Builder.And( condition.Wire, right.Builder.Xor(left.Wires[i], right.Wires[i]) ) ); } return(new SecureWord(right.Builder, result)); }
public static SecureInteger FromWord(SecureWord word) { return(new SecureInteger(word.Builder, word.Wires)); }