Github user tellison commented on a diff in the pull request:

    https://github.com/apache/incubator-pirk/pull/102#discussion_r80862797
  
    --- Diff: src/main/java/org/apache/pirk/encryption/Paillier.java ---
    @@ -95,140 +95,185 @@
         }
       }
     
    -  private BigInteger p = null; // large prime
    -  private BigInteger q = null; // large prime
    -  private BigInteger N = null; // N=pq, RSA modulus
    +  private BigInteger p; // large prime
    +  private BigInteger q; // large prime
    +  private BigInteger N; // N=pq, RSA modulus
     
    -  private BigInteger NSquared = null; // NSquared = N^2
    -  private BigInteger lambdaN = null; // lambda(N) = lcm(p-1,q-1), 
Carmichael function of N
    -  private BigInteger w = null; // lambda(N)^-1 mod N
    +  private BigInteger NSquared; // NSquared = N^2
    +  private BigInteger lambdaN; // lambda(N) = lcm(p-1,q-1), Carmichael 
function of N
    +  private BigInteger w; // lambda(N)^-1 mod N
     
    -  private int bitLength = 0; // bit length of the modulus N
    +  private final int bitLength; // bit length of the modulus N
     
       /**
    -   * Constructor with all parameters p,q, and bitLengthInput specified
    -   * <p>
    -   * Only used, at this point, for testing purposes
    -   *
    +   * Creates a Paillier algorithm with all parameters specified.
    +   * 
    +   * @param p
    +   *          First large prime.
    +   * @param q
    +   *          Second large prime.
    +   * @param bitLength
    +   *          Bit length of the modulus {@code N}.
    +   * @throws IllegalArgumentException
    +   *           If {@code p} or {@code q} do not satisfy primality 
constraints.
        */
    -  public Paillier(BigInteger pInput, BigInteger qInput, int 
bitLengthInput) throws PIRException
    +  public Paillier(BigInteger p, BigInteger q, int bitLength)
       {
    -    bitLength = bitLengthInput;
    +    this.bitLength = bitLength;
     
         // Verify the prime conditions are satisfied
         int primeCertainty = 
SystemConfiguration.getIntProperty("pir.primeCertainty", 128);
         BigInteger three = BigInteger.valueOf(3);
    -    if ((pInput.compareTo(three) < 0) || (qInput.compareTo(three) < 0) || 
pInput.equals(qInput) || !pInput.isProbablePrime(primeCertainty)
    -        || !qInput.isProbablePrime(primeCertainty))
    +    if ((p.compareTo(three) < 0) || (q.compareTo(three) < 0) || 
p.equals(q) || !p.isProbablePrime(primeCertainty) || 
!q.isProbablePrime(primeCertainty))
         {
    -      throw new PIRException("pInput = " + pInput + " qInput = " + qInput 
+ " do not satisfy primality constraints");
    +      throw new IllegalArgumentException("p = " + p + " q = " + q + " do 
not satisfy primality constraints");
         }
     
    -    p = pInput;
    -    q = qInput;
    +    this.p = p;
    +    this.q = q;
     
    -    N = p.multiply(q);
    +    this.N = p.multiply(q);
     
         setDerivativeElements();
     
         logger.info("Parameters = " + parametersToString());
       }
     
       /**
    -   * Constructor to generate keys given the desired bitLength and prime 
certainty value
    +   * Constructs a Paillier algorithm with generated keys.
        * <p>
    -   * The probability that the new BigInteger values represents primes will 
exceed (1 - (1/2)^certainty). The execution time of this constructor is 
proportional
    -   * to the value of this parameter.
    -   *
    +   * The generated keys {@code p} and {@code q} will have the given 
modulus bit length and prime certainty.
    --- End diff --
    
    Fixed - thanks.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to