Package com.norswap.nanoeth.signature
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
-
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, themessage
will always be a hash.
-
Field Details
-
publicKey
-
-
Constructor Details
-
EthKeyPair
public EthKeyPair()Generate a new key pair. -
EthKeyPair
Create a key pair from an existing public and private key. -
EthKeyPair
Create a key pair from an existing private key (regenerating the public key). -
EthKeyPair
Create a key pair from the hex string representation (e.g. 0x123) of the private key.
-
-
Method Details
-
sign
Sign the Keccak hash of the given message (an arbitrary byte sequence) with ECDSA using the private key. -
signWithoutHashing
In Ethereum, themessage
will always be a hash. -
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.
-