java.lang.Object
com.hedera.hashgraph.sdk.Key
com.hedera.hashgraph.sdk.PrivateKey
com.hedera.hashgraph.sdk.PrivateKeyECDSA
Encapsulate the ECDSA private key.
-
Field Summary
Fields inherited from class com.hedera.hashgraph.sdk.PrivateKey
publicKeyFields inherited from class com.hedera.hashgraph.sdk.Key
ECDSA_SECP256K1_CURVE, ECDSA_SECP256K1_DOMAIN, ID_EC_PUBLIC_KEY, ID_ECDSA_SECP256K1, ID_ED25519 -
Constructor Summary
ConstructorsConstructorDescriptionPrivateKeyECDSA(BigInteger keyData, org.bouncycastle.crypto.params.KeyParameter chainCode) Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) static PrivateKeyECDSAderivableKeyECDSA(byte[] deriveData) Create a derived key.derive(int index) Given a wallet/account index, derive a child key compatible with the iOS and Android wallets.(package private) static PrivateKeyfromBytesInternal(byte[] privateKey) Create a private key from a byte array.(package private) static PrivateKeyfromECPrivateKeyInternal(org.bouncycastle.asn1.sec.ECPrivateKey privateKey) Create a new private key from a ECPrivateKey object.(package private) static PrivateKeyfromPrivateKeyInfoInternal(org.bouncycastle.asn1.pkcs.PrivateKeyInfo privateKeyInfo) Create a new private key from a private key ino object.static PrivateKeyfromSeed(byte[] seed) Create an ECDSA key from seed.(package private) static PrivateKeyECDSACreate a new private ECDSA key.org.bouncycastle.crypto.params.KeyParameterGet the chain code of the keyDerive a public key from this private key.intgetRecoveryId(byte[] r, byte[] s, byte[] message) booleanCheck if this private key supports derivation.booleanisECDSA()Are we an ECDSA key?booleanAre we an ED25519 key?legacyDerive(long index) Derive a child key based on the index.(package private) static byte[]legacyDeriveChildKey(byte[] entropy, long index) Throws an exception when trying to derive a child key.byte[]sign(byte[] message) Sign a message with this private key.byte[]toBytes()Create the byte array.byte[]Extract the byte array encoded as DER.byte[]Extract the raw byte array.Methods inherited from class com.hedera.hashgraph.sdk.PrivateKey
fromBytes, fromBytesDER, fromBytesECDSA, fromBytesED25519, fromMnemonic, fromMnemonic, fromPem, fromPem, fromSeedECDSAsecp256k1, fromSeedED25519, fromString, fromStringDER, fromStringECDSA, fromStringED25519, generate, generateECDSA, generateED25519, legacyDerive, readPem, readPem, signTransaction, toAccountId, toProtobufKey, toString, toStringDER, toStringRawMethods inherited from class com.hedera.hashgraph.sdk.Key
fromProtobufKey
-
Constructor Details
-
PrivateKeyECDSA
PrivateKeyECDSA(BigInteger keyData, @Nullable org.bouncycastle.crypto.params.KeyParameter chainCode) Constructor.- Parameters:
keyData- the key data
-
-
Method Details
-
generateInternal
Create a new private ECDSA key.- Returns:
- the new key
-
fromPrivateKeyInfoInternal
static PrivateKey fromPrivateKeyInfoInternal(org.bouncycastle.asn1.pkcs.PrivateKeyInfo privateKeyInfo) Create a new private key from a private key ino object.- Parameters:
privateKeyInfo- the private key info object- Returns:
- the new key
-
fromECPrivateKeyInternal
Create a new private key from a ECPrivateKey object.- Parameters:
privateKey- the ECPrivateKey object- Returns:
- the new key
-
fromBytesInternal
Create a private key from a byte array.- Parameters:
privateKey- the byte array- Returns:
- the new key
-
legacyDeriveChildKey
static byte[] legacyDeriveChildKey(byte[] entropy, long index) Throws an exception when trying to derive a child key.- Parameters:
entropy- entropy byte arrayindex- the child key index- Returns:
- the new key
-
legacyDerive
Description copied from class:PrivateKeyDerive a child key based on the index.- Specified by:
legacyDerivein classPrivateKey- Parameters:
index- the index- Returns:
- the derived child key
-
isDerivable
public boolean isDerivable()Description copied from class:PrivateKeyCheck if this private key supports derivation.This is currently only the case if this private key was created from a mnemonic.
- Specified by:
isDerivablein classPrivateKey- Returns:
- boolean
-
derive
Description copied from class:PrivateKeyGiven a wallet/account index, derive a child key compatible with the iOS and Android wallets.Use index 0 for the default account.
- Specified by:
derivein classPrivateKey- Parameters:
index- the wallet/account index of the account, 0 for the default account.- Returns:
- the derived key
- See Also:
-
fromSeed
Create an ECDSA key from seed. Implement the published algorithm as defined in BIP32 in order to derive the primary account key from the original (and never stored) master key. The original master key, which is a secure key generated according to the BIP39 specification, is input to this operation, and provides the base cryptographic seed material required to ensure the output is sufficiently random to maintain strong cryptographic assurances. The fromSeed() method must be provided with cryptographically secure material; otherwise, it will produce insecure output.- Parameters:
seed- the seed bytes- Returns:
- the new key
- See Also:
-
derivableKeyECDSA
Create a derived key. The industry standard protocol for deriving an active ECDSA keypair from a BIP39 master key is described in BIP32. By using this deterministic mechanism to derive cryptographically secure keypairs from a single original secret, the user maintains secure access to their wallet, even if they lose access to a particular system or wallet local data store. The active keypair can always be re-derived from the original master key. The use of the fixed "key" values in this code is defined by this deterministic protocol, and this data is mixed, in a deterministic but cryptographically secure manner, with the original master key and/or other derived keys "higher" in the tree to produce a cryptographically secure derived key. This "Key Derivation Function" makes use of secure hash algorithm and a secure hash based message authentication code to produce an initialization vector, and then produces the actual key from a portion of that vector.- Parameters:
deriveData- data to derive the key- Returns:
- the new key
- See Also:
-
getPublicKey
Description copied from class:PrivateKeyDerive a public key from this private key.The public key can be freely given and used by other parties to verify the signatures generated by this private key.
- Specified by:
getPublicKeyin classPrivateKey- Returns:
- the corresponding public key for this private key.
-
getChainCode
public org.bouncycastle.crypto.params.KeyParameter getChainCode()Description copied from class:PrivateKeyGet the chain code of the key- Specified by:
getChainCodein classPrivateKey- Returns:
- the chainCode
-
sign
public byte[] sign(byte[] message) Description copied from class:PrivateKeySign a message with this private key.- Specified by:
signin classPrivateKey- Parameters:
message- The array of bytes to sign with- Returns:
- the signature of the message.
-
getRecoveryId
public int getRecoveryId(byte[] r, byte[] s, byte[] message) -
toBytes
public byte[] toBytes()Description copied from class:KeyCreate the byte array.- Specified by:
toBytesin classPrivateKey- Returns:
- the byte array representation
-
toBytesRaw
public byte[] toBytesRaw()Description copied from class:PrivateKeyExtract the raw byte array.- Specified by:
toBytesRawin classPrivateKey- Returns:
- the raw byte array
-
toBytesDER
public byte[] toBytesDER()Description copied from class:PrivateKeyExtract the byte array encoded as DER.- Specified by:
toBytesDERin classPrivateKey- Returns:
- the byte array encoded as DER
-
isED25519
public boolean isED25519()Description copied from class:PrivateKeyAre we an ED25519 key?- Specified by:
isED25519in classPrivateKey- Returns:
- are we an ED25519 key
-
isECDSA
public boolean isECDSA()Description copied from class:PrivateKeyAre we an ECDSA key?- Specified by:
isECDSAin classPrivateKey- Returns:
- are we an ECDSA key
-