org.bitcoin.x6763.crypto.ecdsa
Class PrivateKey

java.lang.Object
  extended by org.bitcoin.x6763.crypto.ecdsa.PrivateKey
All Implemented Interfaces:
java.io.Serializable, java.security.Key, java.security.PrivateKey, ECKey, ECPrivateKey, Secp256k1

public class PrivateKey
extends java.lang.Object
implements Secp256k1, ECPrivateKey

An elliptic curve private key, generated for the secp256k1 elliptic curve.

Author:
x6763
See Also:
Serialized Form

Field Summary
static long serialVersionUID
           
 
Fields inherited from interface org.bitcoin.x6763.crypto.ecdsa.Secp256k1
a, algorithm, b, bigX, bigY, curve, G, h, n, p, parameters, x, y
 
Constructor Summary
PrivateKey(java.math.BigInteger S)
          Creates a private key object from it's BigInteger form
PrivateKey(byte[] sBytes)
          Creates a private key object from a 256-bit byte array
 
Method Summary
 java.lang.String getAlgorithm()
          Returns the algorithm name, "ECDSA".
 byte[] getEncoded()
          Returns the serialized private key.
 java.lang.String getFormat()
           
 ECDomainParameters getParams()
          Returns the elliptic curve domain parameters for the secp256k1 curve.
 PublicKey getPublic()
          Derive a public key from this private key
 java.math.BigInteger getS()
          Returns the 256-bit private key number
 byte[] serialize()
          Serializes the private key into an array of 32 bytes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

PrivateKey

public PrivateKey(java.math.BigInteger S)
Creates a private key object from it's BigInteger form

Parameters:
S - the private key in BigInteger form

PrivateKey

public PrivateKey(byte[] sBytes)
Creates a private key object from a 256-bit byte array

Parameters:
sBytes - the array of bytes representing the private key
Method Detail

getPublic

public PublicKey getPublic()
Derive a public key from this private key

Returns:
a public key derived from this private key

getParams

public ECDomainParameters getParams()
Returns the elliptic curve domain parameters for the secp256k1 curve.

Specified by:
getParams in interface ECKey
Returns:
the secp256k1 elliptic curve domain parameters

getAlgorithm

public java.lang.String getAlgorithm()
Returns the algorithm name, "ECDSA".

Specified by:
getAlgorithm in interface java.security.Key
Returns:
the algorithm name, "EDCSA"

getEncoded

public byte[] getEncoded()
Returns the serialized private key. Same as serialize().

Specified by:
getEncoded in interface java.security.Key
Returns:
an array of 32 bytes
See Also:
serialize()

getFormat

public java.lang.String getFormat()
Specified by:
getFormat in interface java.security.Key
Returns:
null

getS

public java.math.BigInteger getS()
Returns the 256-bit private key number

Specified by:
getS in interface ECPrivateKey
Returns:
the BigInteger value of the private key

serialize

public byte[] serialize()
Serializes the private key into an array of 32 bytes. This format is not compatible with the DER-encoded private keys in wallets generated by the official Bitcoin software as of Bitcoin version 0.3.19.

Returns:
an array of 32 bytes