protected X9ECParameters createParameters() {
          ECCurve curve =
              new ECCurve.Fp(
                  // new
                  // BigInteger("15F75CAF668077F7E85B42EB01F0A81FF56ECD6191D55CB82B7D861458A18FEFC3E5AB7496F3C7B1") //Z
                  new BigInteger(
                      "D35E472036BC4FB7E13C785ED201E065F98FCFA6F6F40DEF4F92B9EC7893EC28FCD412B1F1B32E27",
                      16), // q
                  new BigInteger(
                      "D35E472036BC4FB7E13C785ED201E065F98FCFA6F6F40DEF4F92B9EC7893EC28FCD412B1F1B32E24",
                      16), // a'
                  new BigInteger(
                      "A7F561E038EB1ED560B3D147DB782013064C19F27ED27C6780AAF77FB8A547CEB5B4FEF422340353",
                      16)); // b'

          return new X9ECParameters(
              curve,
              curve.decodePoint(
                  Hex.decode(
                      "04925BE9FB01AFC6FB4D3E7D4990010F813408AB106C4F09CB7EE07868CC136FFF3357F624A21BED5263BA3A7A27483EBF6671DBEF7ABB30EBEE084E58A0B077AD42A5A0989D1EE71B1B9BC0455FB0D2C3")), // G'
              new BigInteger(
                  "D35E472036BC4FB7E13C785ED201E065F98FCFA5B68F12A32D482EC7EE8658E98691555B44C59311",
                  16), // n
              new BigInteger("01", 16)); // h
        }
        protected X9ECParameters createParameters() {
          ECCurve curve =
              new ECCurve.Fp(
                  // new
                  // BigInteger("12EE58E6764838B69782136F0F2D3BA06E27695716054092E60A80BEDB212B64E585D90BCE13761F85C3F1D2A64E3BE8FEA2220F01EBA5EEB0F35DBD29D922AB") //Z
                  new BigInteger(
                      "AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3",
                      16), // q
                  new BigInteger(
                      "AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F0",
                      16), // a'
                  new BigInteger(
                      "7CBBBCF9441CFAB76E1890E46884EAE321F70C0BCB4981527897504BEC3E36A62BCDFA2304976540F6450085F2DAE145C22553B465763689180EA2571867423E",
                      16)); // b'

          return new X9ECParameters(
              curve,
              curve.decodePoint(
                  Hex.decode(
                      "04640ECE5C12788717B9C1BA06CBC2A6FEBA85842458C56DDE9DB1758D39C0313D82BA51735CDB3EA499AA77A7D6943A64F7A3F25FE26F06B51BAA2696FA9035DA5B534BD595F5AF0FA2C892376C84ACE1BB4E3019B71634C01131159CAE03CEE9D9932184BEEF216BD71DF2DADF86A627306ECFF96DBB8BACE198B61E00F8B332")), // G'
              new BigInteger(
                  "AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA92619418661197FAC10471DB1D381085DDADDB58796829CA90069",
                  16), // n
              new BigInteger("01", 16)); // h
        }
        protected X9ECParameters createParameters() {
          ECCurve curve =
              new ECCurve.Fp(
                  // new
                  // BigInteger("41DFE8DD399331F7166A66076734A89CD0D2BCDB7D068E44E1F378F41ECBAE97D2D63DBC87BCCDDCCC5DA39E8589291C") //Z
                  new BigInteger(
                      "8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A71874700133107EC53",
                      16), // q
                  new BigInteger(
                      "8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A71874700133107EC50",
                      16), // a'
                  new BigInteger(
                      "7F519EADA7BDA81BD826DBA647910F8C4B9346ED8CCDC64E4B1ABD11756DCE1D2074AA263B88805CED70355A33B471EE",
                      16)); // b'

          return new X9ECParameters(
              curve,
              curve.decodePoint(
                  Hex.decode(
                      "0418DE98B02DB9A306F2AFCD7235F72A819B80AB12EBD653172476FECD462AABFFC4FF191B946A5F54D8D0AA2F418808CC25AB056962D30651A114AFD2755AD336747F93475B7A1FCA3B88F2B6A208CCFE469408584DC2B2912675BF5B9E582928")), // G'
              new BigInteger(
                  "8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC3103B883202E9046565",
                  16), // n
              new BigInteger("01", 16)); // h
        }
  public ECPoint twicePlus(ECPoint b) {
    if (this.isInfinity()) {
      return b;
    }
    if (b.isInfinity()) {
      return twice();
    }

    ECCurve curve = this.getCurve();

    ECFieldElement X1 = this.x;
    if (X1.isZero()) {
      // A point with X == 0 is it's own additive inverse
      return b;
    }

    // NOTE: twicePlus() only optimized for lambda-affine argument
    ECFieldElement X2 = b.getRawXCoord(), Z2 = b.getZCoord(0);
    if (X2.isZero() || !Z2.isOne()) {
      return twice().add(b);
    }

    ECFieldElement L1 = this.y, Z1 = this.zs[0];
    ECFieldElement L2 = b.getRawYCoord();

    ECFieldElement X1Sq = X1.square();
    ECFieldElement L1Sq = L1.square();
    ECFieldElement Z1Sq = Z1.square();
    ECFieldElement L1Z1 = L1.multiply(Z1);

    //        ECFieldElement T = curve.getA().multiply(Z1Sq).add(L1Sq).add(L1Z1);
    ECFieldElement T = L1Sq.add(L1Z1);
    ECFieldElement L2plus1 = L2.addOne();
    //        ECFieldElement A =
    // curve.getA().add(L2plus1).multiply(Z1Sq).add(L1Sq).multiplyPlusProduct(T, X1Sq, Z1Sq);
    ECFieldElement A = L2plus1.multiply(Z1Sq).add(L1Sq).multiplyPlusProduct(T, X1Sq, Z1Sq);
    ECFieldElement X2Z1Sq = X2.multiply(Z1Sq);
    ECFieldElement B = X2Z1Sq.add(T).square();

    if (B.isZero()) {
      if (A.isZero()) {
        return b.twice();
      }

      return curve.getInfinity();
    }

    if (A.isZero()) {
      //            return new SecT283K1Point(curve, A, curve.getB().sqrt(), withCompression);
      return new SecT283K1Point(curve, A, curve.getB(), withCompression);
    }

    ECFieldElement X3 = A.square().multiply(X2Z1Sq);
    ECFieldElement Z3 = A.multiply(B).multiply(Z1Sq);
    ECFieldElement L3 = A.add(B).square().multiplyPlusProduct(T, L2plus1, Z3);

    return new SecT283K1Point(curve, X3, L3, new ECFieldElement[] {Z3}, this.withCompression);
  }
        protected X9ECParameters createParameters() {
          ECCurve curve =
              new ECCurve.Fp(
                  new BigInteger("C302F41D932A36CDA7A3463093D18DB78FCE476DE1A86297", 16), // q
                  new BigInteger("6A91174076B1E0E19C39C031FE8685C1CAE040E5C69A28EF", 16), // a
                  new BigInteger("469A28EF7C28CCA3DC721D044F4496BCCA7EF4146FBF25C9", 16)); // b

          return new X9ECParameters(
              curve,
              curve.decodePoint(
                  Hex.decode(
                      "04C0A0647EAAB6A48753B033C56CB0F0900A2F5C4853375FD614B690866ABD5BB88B5F4828C1490002E6773FA2FA299B8F")), // G
              new BigInteger("C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1", 16), // n
              new BigInteger("01", 16)); // h
        }
        protected X9ECParameters createParameters() {
          ECCurve curve =
              new ECCurve.Fp(
                  new BigInteger("E95E4A5F737059DC60DFC7AD95B3D8139515620F", 16), // q
                  new BigInteger("340E7BE2A280EB74E2BE61BADA745D97E8F7C300", 16), // a
                  new BigInteger("1E589A8595423412134FAA2DBDEC95C8D8675E58", 16)); // b

          return new X9ECParameters(
              curve,
              curve.decodePoint(
                  Hex.decode(
                      "04BED5AF16EA3F6A4F62938C4631EB5AF7BDBCDBC31667CB477A1A8EC338F94741669C976316DA6321")), // G
              new BigInteger("E95E4A5F737059DC60DF5991D45029409E60FC09", 16), // n
              new BigInteger("01", 16)); // h
        }
        protected X9ECParameters createParameters() {
          ECCurve curve =
              new ECCurve.Fp(
                  //   new BigInteger("24DBFF5DEC9B986BBFE5295A29BFBAE45E0F5D0B", 16), // Z
                  new BigInteger("E95E4A5F737059DC60DFC7AD95B3D8139515620F", 16), // q
                  new BigInteger("E95E4A5F737059DC60DFC7AD95B3D8139515620C", 16), // a'
                  new BigInteger("7A556B6DAE535B7B51ED2C4D7DAA7A0B5C55F380", 16)); // b'

          return new X9ECParameters(
              curve,
              curve.decodePoint(
                  Hex.decode(
                      "04B199B13B9B34EFC1397E64BAEB05ACC265FF2378ADD6718B7C7C1961F0991B842443772152C9E0AD")), // G
              new BigInteger("E95E4A5F737059DC60DF5991D45029409E60FC09", 16), // n
              new BigInteger("01", 16)); // h
        }
        protected X9ECParameters createParameters() {
          ECCurve curve =
              new ECCurve.Fp(
                  // new BigInteger("1B6F5CC8DB4DC7AF19458A9CB80DC2295E5EB9C3732104CB") //Z
                  new BigInteger("C302F41D932A36CDA7A3463093D18DB78FCE476DE1A86297", 16), // q
                  new BigInteger("C302F41D932A36CDA7A3463093D18DB78FCE476DE1A86294", 16), // a'
                  new BigInteger("13D56FFAEC78681E68F9DEB43B35BEC2FB68542E27897B79", 16)); // b'

          return new X9ECParameters(
              curve,
              curve.decodePoint(
                  Hex.decode(
                      "043AE9E58C82F63C30282E1FE7BBF43FA72C446AF6F4618129097E2C5667C2223A902AB5CA449D0084B7E5B3DE7CCC01C9")), // G'
              new BigInteger("C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1", 16), // n
              new BigInteger("01", 16)); // h
        }
        protected X9ECParameters createParameters() {
          ECCurve curve =
              new ECCurve.Fp(
                  new BigInteger(
                      "D7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FF", 16), // q
                  new BigInteger(
                      "68A5E62CA9CE6C1C299803A6C1530B514E182AD8B0042A59CAD29F43", 16), // a
                  new BigInteger(
                      "2580F63CCFE44138870713B1A92369E33E2135D266DBB372386C400B", 16)); // b

          return new X9ECParameters(
              curve,
              curve.decodePoint(
                  Hex.decode(
                      "040D9029AD2C7E5CF4340823B2A87DC68C9E4CE3174C1E6EFDEE12C07D58AA56F772C0726F24C6B89E4ECDAC24354B9E99CAA3F6D3761402CD")), // G
              new BigInteger("D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F", 16), // n
              new BigInteger("01", 16)); // n
        }
        protected X9ECParameters createParameters() {
          ECCurve curve =
              new ECCurve.Fp(
                  new BigInteger(
                      "A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E5377", 16), // q
                  new BigInteger(
                      "7D5A0975FC2C3057EEF67530417AFFE7FB8055C126DC5C6CE94A4B44F330B5D9", 16), // a
                  new BigInteger(
                      "26DC5C6CE94A4B44F330B5D9BBD77CBF958416295CF7E1CE6BCCDC18FF8C07B6", 16)); // b

          return new X9ECParameters(
              curve,
              curve.decodePoint(
                  Hex.decode(
                      "048BD2AEB9CB7E57CB2C4B482FFC81B7AFB9DE27E1E3BD23C23A4453BD9ACE3262547EF835C3DAC4FD97F8461A14611DC9C27745132DED8E545C1D54C72F046997")), // G
              new BigInteger(
                  "A9FB57DBA1EEA9BC3E660A909D838D718C397AA3B561A6F7901E0E82974856A7", 16), // n
              new BigInteger("01", 16)); // h
        }
        protected X9ECParameters createParameters() {
          ECCurve curve =
              new ECCurve.Fp(
                  // new BigInteger("2DF271E14427A346910CF7A2E6CFA7B3F484E5C2CCE1C8B730E28B3F") //Z
                  new BigInteger(
                      "D7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FF", 16), // q
                  new BigInteger(
                      "D7C134AA264366862A18302575D1D787B09F075797DA89F57EC8C0FC", 16), // a'
                  new BigInteger(
                      "4B337D934104CD7BEF271BF60CED1ED20DA14C08B3BB64F18A60888D", 16)); // b'

          return new X9ECParameters(
              curve,
              curve.decodePoint(
                  Hex.decode(
                      "046AB1E344CE25FF3896424E7FFE14762ECB49F8928AC0C76029B4D5800374E9F5143E568CD23F3F4D7C0D4B1E41C8CC0D1C6ABD5F1A46DB4C")), // G'
              new BigInteger("D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F", 16), // n
              new BigInteger("01", 16)); // h
        }
  public ECPoint twice() {
    if (this.isInfinity()) {
      return this;
    }

    ECCurve curve = this.getCurve();

    ECFieldElement X1 = this.x;
    if (X1.isZero()) {
      // A point with X == 0 is it's own additive inverse
      return curve.getInfinity();
    }

    ECFieldElement L1 = this.y, Z1 = this.zs[0];

    boolean Z1IsOne = Z1.isOne();
    ECFieldElement Z1Sq = Z1IsOne ? Z1 : Z1.square();
    ECFieldElement T;
    if (Z1IsOne) {
      T = L1.square().add(L1);
    } else {
      T = L1.add(Z1).multiply(L1);
    }

    if (T.isZero()) {
      //            return new SecT283K1Point(curve, T, curve.getB().sqrt(), withCompression);
      return new SecT283K1Point(curve, T, curve.getB(), withCompression);
    }

    ECFieldElement X3 = T.square();
    ECFieldElement Z3 = Z1IsOne ? T : T.multiply(Z1Sq);

    ECFieldElement t1 = L1.add(X1).square();
    ECFieldElement t2 = Z1IsOne ? Z1 : Z1Sq.square();
    ECFieldElement L3 = t1.add(T).add(Z1Sq).multiply(t1).add(t2).add(X3).add(Z3);

    return new SecT283K1Point(curve, X3, L3, new ECFieldElement[] {Z3}, this.withCompression);
  }
        protected X9ECParameters createParameters() {
          ECCurve curve =
              new ECCurve.Fp(
                  new BigInteger(
                      "AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3",
                      16), // q
                  new BigInteger(
                      "7830A3318B603B89E2327145AC234CC594CBDD8D3DF91610A83441CAEA9863BC2DED5D5AA8253AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CA",
                      16), // a
                  new BigInteger(
                      "3DF91610A83441CAEA9863BC2DED5D5AA8253AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CADC083E67984050B75EBAE5DD2809BD638016F723",
                      16)); // b

          return new X9ECParameters(
              curve,
              curve.decodePoint(
                  Hex.decode(
                      "0481AEE4BDD82ED9645A21322E9C4C6A9385ED9F70B5D916C1B43B62EEF4D0098EFF3B1F78E2D0D48D50D1687B93B97D5F7C6D5047406A5E688B352209BCB9F8227DDE385D566332ECC0EABFA9CF7822FDF209F70024A57B1AA000C55B881F8111B2DCDE494A5F485E5BCA4BD88A2763AED1CA2B2FA8F0540678CD1E0F3AD80892")), // G
              new BigInteger(
                  "AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA92619418661197FAC10471DB1D381085DDADDB58796829CA90069",
                  16), // n
              new BigInteger("01", 16)); // h
        }
        protected X9ECParameters createParameters() {
          ECCurve curve =
              new ECCurve.Fp(
                  new BigInteger(
                      "D35E472036BC4FB7E13C785ED201E065F98FCFA6F6F40DEF4F92B9EC7893EC28FCD412B1F1B32E27",
                      16), // q
                  new BigInteger(
                      "3EE30B568FBAB0F883CCEBD46D3F3BB8A2A73513F5EB79DA66190EB085FFA9F492F375A97D860EB4",
                      16), // a
                  new BigInteger(
                      "520883949DFDBC42D3AD198640688A6FE13F41349554B49ACC31DCCD884539816F5EB4AC8FB1F1A6",
                      16)); // b

          return new X9ECParameters(
              curve,
              curve.decodePoint(
                  Hex.decode(
                      "0443BD7E9AFB53D8B85289BCC48EE5BFE6F20137D10A087EB6E7871E2A10A599C710AF8D0D39E2061114FDD05545EC1CC8AB4093247F77275E0743FFED117182EAA9C77877AAAC6AC7D35245D1692E8EE1")), // G
              new BigInteger(
                  "D35E472036BC4FB7E13C785ED201E065F98FCFA5B68F12A32D482EC7EE8658E98691555B44C59311",
                  16), // n
              new BigInteger("01", 16)); // h
        }
        protected X9ECParameters createParameters() {
          ECCurve curve =
              new ECCurve.Fp(
                  // new
                  // BigInteger("3E2D4BD9597B58639AE7AA669CAB9837CF5CF20A2C852D10F655668DFC150EF0")
                  // //Z
                  new BigInteger(
                      "A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E5377", 16), // q
                  new BigInteger(
                      "A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E5374", 16), // a'
                  new BigInteger(
                      "662C61C430D84EA4FE66A7733D0B76B7BF93EBC4AF2F49256AE58101FEE92B04",
                      16)); // b'

          return new X9ECParameters(
              curve,
              curve.decodePoint(
                  Hex.decode(
                      "04A3E8EB3CC1CFE7B7732213B23A656149AFA142C47AAFBC2B79A191562E1305F42D996C823439C56D7F7B22E14644417E69BCB6DE39D027001DABE8F35B25C9BE")), // G'
              new BigInteger(
                  "A9FB57DBA1EEA9BC3E660A909D838D718C397AA3B561A6F7901E0E82974856A7", 16), // n
              new BigInteger("01", 16)); // h
        }
        protected X9ECParameters createParameters() {
          ECCurve curve =
              new ECCurve.Fp(
                  new BigInteger(
                      "8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A71874700133107EC53",
                      16), // q
                  new BigInteger(
                      "7BC382C63D8C150C3C72080ACE05AFA0C2BEA28E4FB22787139165EFBA91F90F8AA5814A503AD4EB04A8C7DD22CE2826",
                      16), // a
                  new BigInteger(
                      "4A8C7DD22CE28268B39B55416F0447C2FB77DE107DCD2A62E880EA53EEB62D57CB4390295DBC9943AB78696FA504C11",
                      16)); // b

          return new X9ECParameters(
              curve,
              curve.decodePoint(
                  Hex.decode(
                      "041D1C64F068CF45FFA2A63A81B7C13F6B8847A3E77EF14FE3DB7FCAFE0CBD10E8E826E03436D646AAEF87B2E247D4AF1E8ABE1D7520F9C2A45CB1EB8E95CFD55262B70B29FEEC5864E19C054FF99129280E4646217791811142820341263C5315")), // G
              new BigInteger(
                  "8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC3103B883202E9046565",
                  16), // n
              new BigInteger("01", 16)); // h
        }
  public ECPoint twice() {
    if (this.isInfinity()) {
      return this;
    }

    ECCurve curve = this.getCurve();

    SecP384R1FieldElement Y1 = (SecP384R1FieldElement) this.y;
    if (Y1.isZero()) {
      return curve.getInfinity();
    }

    SecP384R1FieldElement X1 = (SecP384R1FieldElement) this.x,
        Z1 = (SecP384R1FieldElement) this.zs[0];

    int c;
    int[] t1 = Nat.create(12);
    int[] t2 = Nat.create(12);

    int[] Y1Squared = Nat.create(12);
    SecP384R1Field.square(Y1.x, Y1Squared);

    int[] T = Nat.create(12);
    SecP384R1Field.square(Y1Squared, T);

    boolean Z1IsOne = Z1.isOne();

    int[] Z1Squared = Z1.x;
    if (!Z1IsOne) {
      Z1Squared = t2;
      SecP384R1Field.square(Z1.x, Z1Squared);
    }

    SecP384R1Field.subtract(X1.x, Z1Squared, t1);

    int[] M = t2;
    SecP384R1Field.add(X1.x, Z1Squared, M);
    SecP384R1Field.multiply(M, t1, M);
    c = Nat.addBothTo(12, M, M, M);
    SecP384R1Field.reduce32(c, M);

    int[] S = Y1Squared;
    SecP384R1Field.multiply(Y1Squared, X1.x, S);
    c = Nat.shiftUpBits(12, S, 2, 0);
    SecP384R1Field.reduce32(c, S);

    c = Nat.shiftUpBits(12, T, 3, 0, t1);
    SecP384R1Field.reduce32(c, t1);

    SecP384R1FieldElement X3 = new SecP384R1FieldElement(T);
    SecP384R1Field.square(M, X3.x);
    SecP384R1Field.subtract(X3.x, S, X3.x);
    SecP384R1Field.subtract(X3.x, S, X3.x);

    SecP384R1FieldElement Y3 = new SecP384R1FieldElement(S);
    SecP384R1Field.subtract(S, X3.x, Y3.x);
    SecP384R1Field.multiply(Y3.x, M, Y3.x);
    SecP384R1Field.subtract(Y3.x, t1, Y3.x);

    SecP384R1FieldElement Z3 = new SecP384R1FieldElement(M);
    SecP384R1Field.twice(Y1.x, Z3.x);
    if (!Z1IsOne) {
      SecP384R1Field.multiply(Z3.x, Z1.x, Z3.x);
    }

    return new SecP384R1Point(curve, X3, Y3, new ECFieldElement[] {Z3}, this.withCompression);
  }
  public ECPoint add(ECPoint b) {
    if (this.isInfinity()) {
      return b;
    }
    if (b.isInfinity()) {
      return this;
    }
    if (this == b) {
      return twice();
    }

    ECCurve curve = this.getCurve();

    SecP384R1FieldElement X1 = (SecP384R1FieldElement) this.x, Y1 = (SecP384R1FieldElement) this.y;
    SecP384R1FieldElement X2 = (SecP384R1FieldElement) b.getXCoord(),
        Y2 = (SecP384R1FieldElement) b.getYCoord();

    SecP384R1FieldElement Z1 = (SecP384R1FieldElement) this.zs[0];
    SecP384R1FieldElement Z2 = (SecP384R1FieldElement) b.getZCoord(0);

    int c;
    int[] tt1 = Nat.create(24);
    int[] tt2 = Nat.create(24);
    int[] t3 = Nat.create(12);
    int[] t4 = Nat.create(12);

    boolean Z1IsOne = Z1.isOne();
    int[] U2, S2;
    if (Z1IsOne) {
      U2 = X2.x;
      S2 = Y2.x;
    } else {
      S2 = t3;
      SecP384R1Field.square(Z1.x, S2);

      U2 = tt2;
      SecP384R1Field.multiply(S2, X2.x, U2);

      SecP384R1Field.multiply(S2, Z1.x, S2);
      SecP384R1Field.multiply(S2, Y2.x, S2);
    }

    boolean Z2IsOne = Z2.isOne();
    int[] U1, S1;
    if (Z2IsOne) {
      U1 = X1.x;
      S1 = Y1.x;
    } else {
      S1 = t4;
      SecP384R1Field.square(Z2.x, S1);

      U1 = tt1;
      SecP384R1Field.multiply(S1, X1.x, U1);

      SecP384R1Field.multiply(S1, Z2.x, S1);
      SecP384R1Field.multiply(S1, Y1.x, S1);
    }

    int[] H = Nat.create(12);
    SecP384R1Field.subtract(U1, U2, H);

    int[] R = Nat.create(12);
    SecP384R1Field.subtract(S1, S2, R);

    // Check if b == this or b == -this
    if (Nat.isZero(12, H)) {
      if (Nat.isZero(12, R)) {
        // this == b, i.e. this must be doubled
        return this.twice();
      }

      // this == -b, i.e. the result is the point at infinity
      return curve.getInfinity();
    }

    int[] HSquared = t3;
    SecP384R1Field.square(H, HSquared);

    int[] G = Nat.create(12);
    SecP384R1Field.multiply(HSquared, H, G);

    int[] V = t3;
    SecP384R1Field.multiply(HSquared, U1, V);

    SecP384R1Field.negate(G, G);
    Nat384.mul(S1, G, tt1);

    c = Nat.addBothTo(12, V, V, G);
    SecP384R1Field.reduce32(c, G);

    SecP384R1FieldElement X3 = new SecP384R1FieldElement(t4);
    SecP384R1Field.square(R, X3.x);
    SecP384R1Field.subtract(X3.x, G, X3.x);

    SecP384R1FieldElement Y3 = new SecP384R1FieldElement(G);
    SecP384R1Field.subtract(V, X3.x, Y3.x);
    Nat384.mul(Y3.x, R, tt2);
    SecP384R1Field.addExt(tt1, tt2, tt1);
    SecP384R1Field.reduce(tt1, Y3.x);

    SecP384R1FieldElement Z3 = new SecP384R1FieldElement(H);
    if (!Z1IsOne) {
      SecP384R1Field.multiply(Z3.x, Z1.x, Z3.x);
    }
    if (!Z2IsOne) {
      SecP384R1Field.multiply(Z3.x, Z2.x, Z3.x);
    }

    ECFieldElement[] zs = new ECFieldElement[] {Z3};

    return new SecP384R1Point(curve, X3, Y3, zs, this.withCompression);
  }
  public ECPoint add(ECPoint b) {
    if (this.isInfinity()) {
      return b;
    }
    if (b.isInfinity()) {
      return this;
    }

    ECCurve curve = this.getCurve();

    ECFieldElement X1 = this.x;
    ECFieldElement X2 = b.getRawXCoord();

    if (X1.isZero()) {
      if (X2.isZero()) {
        return curve.getInfinity();
      }

      return b.add(this);
    }

    ECFieldElement L1 = this.y, Z1 = this.zs[0];
    ECFieldElement L2 = b.getRawYCoord(), Z2 = b.getZCoord(0);

    boolean Z1IsOne = Z1.isOne();
    ECFieldElement U2 = X2, S2 = L2;
    if (!Z1IsOne) {
      U2 = U2.multiply(Z1);
      S2 = S2.multiply(Z1);
    }

    boolean Z2IsOne = Z2.isOne();
    ECFieldElement U1 = X1, S1 = L1;
    if (!Z2IsOne) {
      U1 = U1.multiply(Z2);
      S1 = S1.multiply(Z2);
    }

    ECFieldElement A = S1.add(S2);
    ECFieldElement B = U1.add(U2);

    if (B.isZero()) {
      if (A.isZero()) {
        return twice();
      }

      return curve.getInfinity();
    }

    ECFieldElement X3, L3, Z3;
    if (X2.isZero()) {
      // TODO This can probably be optimized quite a bit
      ECPoint p = this.normalize();
      X1 = p.getXCoord();
      ECFieldElement Y1 = p.getYCoord();

      ECFieldElement Y2 = L2;
      ECFieldElement L = Y1.add(Y2).divide(X1);

      //            X3 = L.square().add(L).add(X1).add(curve.getA());
      X3 = L.square().add(L).add(X1);
      if (X3.isZero()) {
        //                return new SecT283K1Point(curve, X3, curve.getB().sqrt(),
        // this.withCompression);
        return new SecT283K1Point(curve, X3, curve.getB(), this.withCompression);
      }

      ECFieldElement Y3 = L.multiply(X1.add(X3)).add(X3).add(Y1);
      L3 = Y3.divide(X3).add(X3);
      Z3 = curve.fromBigInteger(ECConstants.ONE);
    } else {
      B = B.square();

      ECFieldElement AU1 = A.multiply(U1);
      ECFieldElement AU2 = A.multiply(U2);

      X3 = AU1.multiply(AU2);
      if (X3.isZero()) {
        //                return new SecT283K1Point(curve, X3, curve.getB().sqrt(),
        // this.withCompression);
        return new SecT283K1Point(curve, X3, curve.getB(), this.withCompression);
      }

      ECFieldElement ABZ2 = A.multiply(B);
      if (!Z2IsOne) {
        ABZ2 = ABZ2.multiply(Z2);
      }

      L3 = AU2.add(B).squarePlusProduct(ABZ2, L1.add(Z1));

      Z3 = ABZ2;
      if (!Z1IsOne) {
        Z3 = Z3.multiply(Z1);
      }
    }

    return new SecT283K1Point(curve, X3, L3, new ECFieldElement[] {Z3}, this.withCompression);
  }