Package tools.ec.EllipticCurve

Examples of tools.ec.EllipticCurve.Element


  public static void main(String[] args) throws Exception {
    EllipticCurve curve = new EllipticCurve(new BigInteger(
        "231980187997634794246138521723892165531"), new BigInteger(
        "286458106491124997002528249079664631375"), new BigInteger(
        "300957219209219074658154646971415184777"));
    Element g = new Element(curve, new BigInteger(
        "147686244687917713362777524310538490730"), new BigInteger(
        "83517868646140609087900046649718421315"));
    Element target = new Element(curve, new BigInteger(
        "216591050567009152291214325597583347779"), new BigInteger(
        "107398660888944827631602166762428987345"));
    BigInteger k = new BigInteger("182755680224874988969105090392374859247");

    BufferedReader br = new BufferedReader(new InputStreamReader(
        new FileInputStream("src/ass4/decrypt/cipher")));
    PrintWriter pw = new PrintWriter(new FileOutputStream(
        "src/ass4/decrypt/plain"));
    String line = null;
    while ((line = br.readLine()) != null) {
      String[] parts = line.split(" ");
      try {
        Element cipher = new Element(curve, new BigInteger(parts[0]),
            new BigInteger(parts[1]));
        Element sand = new Element(curve, new BigInteger(parts[2]),
            new BigInteger(parts[3]));
        Element result = cipher.add(sand.mul(k).negate());
        pw.print((char) result.getX().intValue());
      } catch (IllegalArgumentException e) {
        System.out.println(line);
      }
    }
    pw.close();
View Full Code Here


    EllipticCurve curve = new EllipticCurve(new BigInteger(
        "231980187997634794246138521723892165531"), new BigInteger(
        "286458106491124997002528249079664631375"), new BigInteger(
        "300957219209219074658154646971415184777"));
    Element g = new Element(curve, new BigInteger(
        "147686244687917713362777524310538490730"), new BigInteger(
        "83517868646140609087900046649718421315"));

    BufferedReader br = new BufferedReader(new InputStreamReader(
        new FileInputStream("src/ass4/brute/history")));
    String line = null;
    while ((line = br.readLine()) != null) {
      Matcher matcher = ptn.matcher(line);
      if (matcher.matches()) {
        int x = Integer.valueOf(matcher.group(1));
        Long y = NumberFormat.getNumberInstance(java.util.Locale.US)
            .parse(matcher.group(2)).longValue();
        Element element = new Element(curve, new BigInteger(
            matcher.group(3)), new BigInteger(matcher.group(4)));
        if (!element.equals(g.mul((y - 1) * 6 + x + 1))) {
          System.out.println(line);
        }
      } else {
        throw new IllegalArgumentException("Not recognized:" + line);
      }
View Full Code Here

  public static void main(String[] args) {
    EllipticCurve curve = new EllipticCurve(new BigInteger(
        "231980187997634794246138521723892165531"), new BigInteger(
        "286458106491124997002528249079664631375"), new BigInteger(
        "300957219209219074658154646971415184777"));
    Element g = new Element(curve, new BigInteger(
        "147686244687917713362777524310538490730"), new BigInteger(
        "83517868646140609087900046649718421315"));

    Element a2 = g.mul((2120000000l - 1) * 6l + (3 + 1));
    System.out.println(a2);
  }
View Full Code Here

  @Test
  public void testElementEquals() {
    EllipticCurve ec = new EllipticCurve(new BigInteger("43"),
        new BigInteger("4"), new BigInteger("34"));
    Element element1 = new Element(ec, new BigInteger("12"),
        new BigInteger("41"));
    Element element2 = new Element(ec, new BigInteger("12"),
        new BigInteger("41"));
    Element element3 = EllipticCurve.ZERO;
    Element element4 = EllipticCurve.ZERO;

    assertEquals(element1, element2);
    assertTrue(!element2.equals(element3));
    assertEquals(element3, element4);
  }
View Full Code Here

  public static void main(String[] args) {
    EllipticCurve curve = new EllipticCurve(new BigInteger(
        "231980187997634794246138521723892165531"), new BigInteger(
        "286458106491124997002528249079664631375"), new BigInteger(
        "300957219209219074658154646971415184777"));
    Element g = new Element(curve, new BigInteger(
        "147686244687917713362777524310538490730"), new BigInteger(
        "83517868646140609087900046649718421315"));
    Element target = new Element(curve, new BigInteger(
        "216591050567009152291214325597583347779"), new BigInteger(
        "107398660888944827631602166762428987345"));
    int threadCount = 6;
    Element inc = g.mul(threadCount);
    // for (int i = 0; i < threadCount; i++) {
    // CalculateThread thread = new CalculateThread(i, g.mul(i + 1), inc,
    // target);
    // thread.start();
    // }

    CalculateThread thread1 = new CalculateThread(0, new Element(curve,
        new BigInteger("145697449770187874476326978055883996266"),
        new BigInteger("174948184565688853772477350589115314329")),
        inc, target);
    thread1.setCounter(1560000000l);
    thread1.start();

    CalculateThread thread2 = new CalculateThread(1, new Element(curve,
        new BigInteger("86744068349102061789824003879905891645"),
        new BigInteger("84594757080104559577239545794193972610")), inc,
        target);
    thread2.setCounter(1600000000l);
    thread2.start();

    CalculateThread thread3 = new CalculateThread(2, new Element(curve,
        new BigInteger("177642080504131601247250215333792532415"),
        new BigInteger("106485593792002619071653479487123105629")),
        inc, target);
    thread3.setCounter(1650000000l);
    thread3.start();

    CalculateThread thread4 = new CalculateThread(3, new Element(curve,
        new BigInteger("21128894726749957056603814076103466212"),
        new BigInteger("118869102166829012890598188272916671353")),
        inc, target);
    thread4.setCounter(1630000000l);
    thread4.start();

    CalculateThread thread5 = new CalculateThread(4, new Element(curve,
        new BigInteger("144044002239725645798650253295476906320"),
        new BigInteger("12216884291606090643494028344316964534")), inc,
        target);
    thread5.setCounter(1540000000);
    thread5.start();

    CalculateThread thread6 = new CalculateThread(5, new Element(curve,
        new BigInteger("201881605958699569154366474366082739873"),
        new BigInteger("110116407719661230559194278133623891093")),
        inc, target);
    thread6.setCounter(1560000000l);
    thread6.start();
View Full Code Here

  @Test
  public void testMul() {
    EllipticCurve ec = new EllipticCurve(new BigInteger("43"),
        new BigInteger("4"), new BigInteger("34"));
    Element element1 = new Element(ec, new BigInteger("12"),
        new BigInteger("41"));

    assertEquals(element1, element1.mul(1));
    assertEquals(
        element1.add(element1).add(element1).add(element1)
            .add(element1), element1.mul(5));
    assertEquals(element1.mul(4), new Element(ec, new BigInteger("31"),
        new BigInteger("8")));
  }
View Full Code Here

  public void testBigMul() {
    EllipticCurve curve = new EllipticCurve(new BigInteger(
        "231980187997634794246138521723892165531"), new BigInteger(
        "286458106491124997002528249079664631375"), new BigInteger(
        "300957219209219074658154646971415184777"));
    Element g = new Element(curve, new BigInteger(
        "147686244687917713362777524310538490730"), new BigInteger(
        "83517868646140609087900046649718421315"));
    for (int i = 1; i < 100000; i++) {
      Element m1 = g.mul(i);
      Element m2 = g.mul(new BigInteger(String.valueOf(i)));
      assertEquals(m1, m2);
    }
  }
View Full Code Here

  public void testMulResult() {
    EllipticCurve curve = new EllipticCurve(new BigInteger(
        "231980187997634794246138521723892165531"), new BigInteger(
        "286458106491124997002528249079664631375"), new BigInteger(
        "300957219209219074658154646971415184777"));
    Element g = new Element(curve, new BigInteger(
        "147686244687917713362777524310538490730"), new BigInteger(
        "83517868646140609087900046649718421315"));
    Element a = g.mul((710000000l - 1) * 6l + (5 + 1));
    System.out.println(a);
  }
View Full Code Here

  @Test
  public void testToString() {
    EllipticCurve ec = new EllipticCurve(new BigInteger("43"),
        new BigInteger("4"), new BigInteger("34"));
    assertEquals("(31,8)", new Element(ec, new BigInteger("31"),
        new BigInteger("8")).toString());
    EllipticCurve curve = new EllipticCurve(new BigInteger(
        "231980187997634794246138521723892165531"), new BigInteger(
        "286458106491124997002528249079664631375"), new BigInteger(
        "300957219209219074658154646971415184777"));
    Element g = new Element(curve, new BigInteger(
        "147686244687917713362777524310538490730"), new BigInteger(
        "83517868646140609087900046649718421315"));

    assertEquals(
        "(147686244687917713362777524310538490730,83517868646140609087900046649718421315)",
        g.toString());
  }
View Full Code Here

    public void setCounter(long counter) {
      this.counter = counter;
    }

    public void run() {
      Element current = start;
      try {
        PrintWriter pw = new PrintWriter(new FileOutputStream(
            "history_" + number));
        while (!current.equals(target)) {
          current = current.add(inc);
          counter += 1;
          if (counter % 10000000 == 0) {
            String message = MessageFormat.format(
                "Processed:{0}:{1}, value {2}", number,
                Long.toString(counter), current);
View Full Code Here

TOP

Related Classes of tools.ec.EllipticCurve.Element

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.