Package com.bitsofproof.supernode.wallet

Examples of com.bitsofproof.supernode.wallet.KeyFormatter


  }

  @Test
  public void wifTest () throws IOException, JSONException, ValidationException
  {
    KeyFormatter formatter = new KeyFormatter (null, Network.PRODUCTION);
    JSONArray testData = readObjectArray (WIF);
    for ( int i = 0; i < testData.length (); ++i )
    {
      JSONArray test = testData.getJSONArray (i);
      ECKeyPair kp = formatter.parseSerializedKey (test.getString (1));
      String address = Address.toSatoshiStyle (Hash.keyHash (kp.getPublic ()), 0x0);
      assertTrue (test.getString (0).equals (address));
      String serialized = formatter.serializeKey (kp);
      assertTrue (test.getString (1).equals (serialized));
    }
  }
View Full Code Here


    JSONArray testData = readObjectArray (BIP38NoEC);
    for ( int i = 0; i < testData.length (); ++i )
    {
      final JSONArray test = testData.getJSONArray (i);

      KeyFormatter formatter = new KeyFormatter (test.getString (2), Network.PRODUCTION);

      ECKeyPair kp = formatter.parseSerializedKey (test.getString (0));
      String decrypted = ECKeyPair.serializeWIF (kp);
      assertTrue (test.getString (1).equals (decrypted));
      ECKeyPair kp2 = formatter.parseSerializedKey (decrypted);
      assertTrue (formatter.serializeKey (kp2).equals (test.getString (0)));
    }
  }
View Full Code Here

    JSONArray testData = readObjectArray (BIP38EC);
    for ( int i = 0; i < testData.length (); ++i )
    {
      final JSONArray test = testData.getJSONArray (i);

      KeyFormatter formatter = new KeyFormatter (test.getString (2), Network.PRODUCTION);
      ECKeyPair kp = formatter.parseSerializedKey (test.getString (0));
      String decrypted = ECKeyPair.serializeWIF (kp);
      assertTrue (test.getString (1).equals (decrypted));
    }
  }
View Full Code Here

      {
        p.append ((char) (r.nextInt () % 0x1FFFFF));
      }
      String passphrase = p.toString ();

      KeyFormatter formatter = new KeyFormatter (passphrase, Network.PRODUCTION);
      ECKeyPair kp = ECKeyPair.createNew (i % 2 == 0);
      String serialized = formatter.serializeKey (kp);
      ECKeyPair kp2 = formatter.parseSerializedKey (serialized);
      assertTrue (Arrays.equals (kp.getPublic (), kp2.getPublic ()));
      assertTrue (Arrays.equals (kp.getPrivate (), kp2.getPrivate ()));
    }
  }
View Full Code Here

TOP

Related Classes of com.bitsofproof.supernode.wallet.KeyFormatter

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.