Package com.bitsofproof.supernode.common

Examples of com.bitsofproof.supernode.common.Key


  private void ensureLookAhead (int from)
  {
    while ( keyIDForAddress.size () < (from + lookAhead - firstIndex) )
    {
      Key key = null;
      try
      {
        key = master.getKey (keyIDForAddress.size () + firstIndex);
      }
      catch ( ValidationException e )
      {
      }
      keyIDForAddress.put (key.getAddress (), keyIDForAddress.size () + firstIndex);
    }
  }
View Full Code Here


      TransactionInput i = transaction.getInputs ().get (j);
      ScriptFormat.Writer sw = new ScriptFormat.Writer ();
      if ( ScriptFormat.isPayToAddress (s.getScript ()) )
      {
        Address address = s.getOutputAddress ();
        Key key = getKeyForAddress (address);
        if ( key == null )
        {
          throw new ValidationException ("Have no key to spend this output");
        }
        byte[] sig = key.sign (hashTransaction (transaction, j, ScriptFormat.SIGHASH_ALL, s.getScript ()));
        byte[] sigPlusType = new byte[sig.length + 1];
        System.arraycopy (sig, 0, sigPlusType, 0, sig.length);
        sigPlusType[sigPlusType.length - 1] = (byte) (ScriptFormat.SIGHASH_ALL & 0xff);
        sw.writeData (sigPlusType);
        sw.writeData (key.getPublic ());
      }
      else
      {
        spendNonAddressOutput (j, s, sw, transaction);
      }
View Full Code Here

    {
      addresses.add (o.getOutputAddress ());
    }
    for ( Address a : addresses )
    {
      Key k = getKeyForAddress (a);
      if ( k != null )
      {
        print.println (ECKeyPair.serializeWIF (k) + " (" + a + ")");
      }
    }
View Full Code Here

    ExtendedKey ekprivate = ExtendedKey.createNew ();
    ExtendedKey ekpublic = new ExtendedKey (new ECPublicKey (ekprivate.getMaster ().getPublic (), true), ekprivate.getChainCode (), 0, 0, 0);

    for ( int i = 0; i < 20; ++i )
    {
      Key fullControl = ekprivate.getKey (i);
      Key readOnly = ekpublic.getKey (i);

      assertTrue (Arrays.equals (fullControl.getPublic (), readOnly.getPublic ()));
      assertTrue (fullControl.getAddress ().equals (readOnly.getAddress ()));

      byte[] toSign = new byte[100];
      random.nextBytes (toSign);
      byte[] signature = fullControl.sign (toSign);

      assertTrue (readOnly.verify (toSign, signature));
    }
  }
View Full Code Here

TOP

Related Classes of com.bitsofproof.supernode.common.Key

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.