Class EthKeyPair

java.lang.Object
com.norswap.nanoeth.signature.EthKeyPair

public final class EthKeyPair
extends Object
A SECP-256k1 key pair that can be used to sign transactions.
  • Field Summary

    Fields
    Modifier and Type Field Description
    ECPoint publicKey  
  • Constructor Summary

    Constructors
    Constructor Description
    EthKeyPair()
    Generate a new key pair.
    EthKeyPair​(String privateKey)
    Create a key pair from the hex string representation (e.g.
    EthKeyPair​(BigInteger privateKey)
    Create a key pair from an existing private key (regenerating the public key).
    EthKeyPair​(ECPoint publicKey, BigInteger privateKey)
    Create a key pair from an existing public and private key.
  • Method Summary

    Modifier and Type Method Description
    Address address()
    Returns the address of the Ethereum account associated with the key pair, which is formed by the 20 rightmost byte of the public key's encoding.
    Signature sign​(byte[] message)
    Sign the Keccak hash of the given message (an arbitrary byte sequence) with ECDSA using the private key.
    Signature signWithoutHashing​(byte[] message)
    In Ethereum, the message will always be a hash.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • publicKey

      public final ECPoint publicKey
  • Constructor Details

    • EthKeyPair

      public EthKeyPair()
      Generate a new key pair.
    • EthKeyPair

      public EthKeyPair​(ECPoint publicKey, BigInteger privateKey)
      Create a key pair from an existing public and private key.
    • EthKeyPair

      public EthKeyPair​(BigInteger privateKey)
      Create a key pair from an existing private key (regenerating the public key).
    • EthKeyPair

      public EthKeyPair​(String privateKey)
      Create a key pair from the hex string representation (e.g. 0x123) of the private key.
  • Method Details

    • sign

      public Signature sign​(byte[] message)
      Sign the Keccak hash of the given message (an arbitrary byte sequence) with ECDSA using the private key.
    • signWithoutHashing

      public Signature signWithoutHashing​(byte[] message)
      In Ethereum, the message will always be a hash.
    • address

      public Address address()
      Returns the address of the Ethereum account associated with the key pair, which is formed by the 20 rightmost byte of the public key's encoding.