Class VectorUtils

Object
VectorUtils

public class VectorUtils
extends Object
  • Constructor Details

  • Method Details

    • innerProductWithBitvectorPublic

      public static DRes<SFixed> innerProductWithBitvectorPublic​(List<DRes<SInt>> a, List<Double> b, ProtocolBuilderNumeric builder)
      Compute the inner product of a public vector with a secret bit vector.
      Parameters:
      a - A secret bit vector
      b - A public vector
      builder - The builder to use.
      Returns:
      The inner product of a and b.
    • innerProductWithBitvector

      public static DRes<SFixed> innerProductWithBitvector​(List<DRes<SInt>> a, List<DRes<SFixed>> b, ProtocolBuilderNumeric builder)
      Compute the inner product of a secret vector with a secret bit vector.
      Parameters:
      a - A secret bit vector
      b - A secret vector
      builder - The builder to use.
      Returns:
      The inner product of a and b.
    • listBuilder

      public static <T> ArrayList<T> listBuilder​(int size, IntFunction<T> generator)
      Build a list of the given size using a generator. Note that this is not lazy -- the generator is called for all indices when this is called.
      Type Parameters:
      T -
      Parameters:
      size - The size of the list.
      generator - The generator used to create the entries.
      Returns:
      A list containg the created elements.
    • scale

      public static ArrayList<DRes<SFixed>> scale​(List<DRes<SFixed>> vector, DRes<SFixed> scalar, ProtocolBuilderNumeric builder)
      Scale all values in the given vector by the scalar.
      Parameters:
      vector - A secret vector.
      scalar - A secret scalar.
      builder - The builder to use.
      Returns:
      A scaled vector.
    • scale

      public static ArrayList<DRes<SFixed>> scale​(List<DRes<SFixed>> vector, double scalar, ProtocolBuilderNumeric builder)
      Scale all values in the given vector by the scalar.
      Parameters:
      vector - A secret vector.
      scalar - A public scalar.
      builder - The builder to use.
      Returns:
      A scaled vector.
    • scaleInt

      public static ArrayList<DRes<SInt>> scaleInt​(List<DRes<SInt>> vector, DRes<SInt> scalar, ProtocolBuilderNumeric builder)
      Scale all values in the given vector by the scalar.
      Parameters:
      vector - A secret vector.
      scalar - A public scalar.
      builder - The builder to use.
      Returns:
      A scaled vector.
    • div

      public static ArrayList<DRes<SFixed>> div​(List<DRes<SFixed>> vector, DRes<SFixed> scalar, ProtocolBuilderNumeric builder)
      Divide all values in the given vector by the scalar.
      Parameters:
      vector - A secret vector.
      scalar - A secret scalar.
      builder - The builder to use.
      Returns:
    • add

      public static List<DRes<SFixed>> add​(List<DRes<SFixed>> a, List<DRes<SFixed>> b, ProtocolBuilderNumeric builder)
      Add two secret vectors.
      Parameters:
      a - A secret vector.
      b - A secret scalar.
      builder - The builder to use.
      Returns:
      a+b
    • sum

      public static List<DRes<SFixed>> sum​(List<List<DRes<SFixed>>> a, ProtocolBuilderNumeric builder)
      Add a list of secret vectors.
      Parameters:
      a - A list of secret vectors.
      builder - The builder to use.
      Returns:
      sum(a)
    • sub

      public static ArrayList<DRes<SFixed>> sub​(List<DRes<SFixed>> a, List<DRes<SFixed>> b, ProtocolBuilderNumeric builder)
      Subtract two secret vectors.
      Parameters:
      a - A secret vector.
      b - A secret scalar.
      builder - The builder to use.
      Returns:
      a-b
    • negate

      public static ArrayList<DRes<SInt>> negate​(List<DRes<SInt>> a, ProtocolBuilderNumeric builder)
      Compute the entry-wise binary negation of a secret vector
      Parameters:
      a - A secret 0-1-vector.
      builder - The builder to use.
      Returns:
      not a
    • open

      public static ArrayList<DRes<BigInteger>> open​(List<DRes<SInt>> a, ProtocolBuilderNumeric builder)
    • mult

      public static List<DRes<SInt>> mult​(List<DRes<SInt>> a, List<DRes<SInt>> b, ProtocolBuilderNumeric protocolBuilderNumeric)
      Subtract two secret vectors.
      Parameters:
      a - A secret vector.
      b - A secret scalar.
      protocolBuilderNumeric - The builder to use.
      Returns:
      a.*b
    • entrywiseBinaryOp

      public static <A,​ B,​ C> ArrayList<C> entrywiseBinaryOp​(List<A> a, List<B> b, VectorUtils.EntrywiseBinaryOp<A,​B,​C> op, ProtocolBuilderNumeric builder)
    • entrywiseUnaryOp

      public static <A,​ C> ArrayList<C> entrywiseUnaryOp​(List<A> a, VectorUtils.EntrywiseUnaryOp<A,​C> op, ProtocolBuilderNumeric builder)
    • input

      public static ArrayList<DRes<SInt>> input​(List<BigInteger> list, int party, ProtocolBuilderNumeric builder)