java.lang.Object
com.hedera.hashgraph.sdk.Key
com.hedera.hashgraph.sdk.PublicKey
- Direct Known Subclasses:
PublicKeyECDSA,PublicKeyED25519
A public key on the Hedera™ network.
-
Field Summary
Fields 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
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) abstract com.google.protobuf.ByteStringGet the signature from a signature pair protobuf.(package private) static PublicKeyfromAliasBytes(com.google.protobuf.ByteString aliasBytes) The public key from an immutable byte string.static PublicKeyfromBytes(byte[] publicKey) Create a public key from a byte array.static PublicKeyfromBytesDER(byte[] publicKey) Create a public key from a DER encoded byte array.static PublicKeyfromBytesECDSA(byte[] publicKey) Create a public key from a byte array.static PublicKeyfromBytesED25519(byte[] publicKey) Create a public key from a byte array.static PublicKeyfromString(String publicKey) Create a public key from a string.static PublicKeyfromStringDER(String publicKey) Create a public key from a string.static PublicKeyfromStringECDSA(String publicKey) Create a public key from a string.static PublicKeyfromStringED25519(String publicKey) Create a public key from a string.abstract booleanisECDSA()Is this an ECDSA key?abstract booleanIs this an ED25519 key?toAccountId(long shard, long realm) Create a new account id.abstract byte[]toBytes()Create the byte array.abstract byte[]Extract the DER represented as a byte array.abstract byte[]Extract the raw byte representation.abstract EvmAddressConverts the key to EVM address(package private) abstract SignaturePairtoSignaturePairProtobuf(byte[] signature) Serialize this key as a SignaturePair protobuf objecttoString()Extract the DER encoded string.Extract the raw string.static PublicKeyReturns an "unusable" public key.abstract booleanverify(byte[] message, byte[] signature) Verify a signature on a message with this public key.booleanverifyTransaction(Transaction<?> transaction) Is the given transaction valid?Methods inherited from class com.hedera.hashgraph.sdk.Key
fromProtobufKey, toProtobufKey
-
Constructor Details
-
PublicKey
public PublicKey()
-
-
Method Details
-
fromBytes
Create a public key from a byte array.- Parameters:
publicKey- the byte array- Returns:
- the new public key
-
fromBytesDER
Create a public key from a DER encoded byte array.- Parameters:
publicKey- the DER encoded byte array- Returns:
- the new key
-
fromBytesED25519
Create a public key from a byte array.- Parameters:
publicKey- the byte array- Returns:
- the new key
-
fromBytesECDSA
Create a public key from a byte array.- Parameters:
publicKey- the byte array- Returns:
- the new key
-
fromString
Create a public key from a string.- Parameters:
publicKey- the string- Returns:
- the new key
-
fromStringED25519
Create a public key from a string.- Parameters:
publicKey- the string- Returns:
- the new key
-
fromStringECDSA
Create a public key from a string.- Parameters:
publicKey- the string- Returns:
- the new key
-
fromStringDER
Create a public key from a string.- Parameters:
publicKey- the string- Returns:
- the new key
-
fromAliasBytes
The public key from an immutable byte string.- Parameters:
aliasBytes- the immutable byte string- Returns:
- the key
-
verify
public abstract boolean verify(byte[] message, byte[] signature) Verify a signature on a message with this public key.- Parameters:
message- The array of bytes representing the messagesignature- The array of bytes representing the signature- Returns:
- boolean
-
extractSignatureFromProtobuf
Get the signature from a signature pair protobuf.- Parameters:
pair- the protobuf- Returns:
- the signature
-
verifyTransaction
Is the given transaction valid?- Parameters:
transaction- the transaction- Returns:
- is it valid
-
toSignaturePairProtobuf
Serialize this key as a SignaturePair protobuf object -
toBytes
public abstract byte[] toBytes()Description copied from class:KeyCreate the byte array. -
toBytesDER
public abstract byte[] toBytesDER()Extract the DER represented as a byte array.- Returns:
- the DER represented as a byte array
-
toBytesRaw
public abstract byte[] toBytesRaw()Extract the raw byte representation.- Returns:
- the raw byte representation
-
toString
-
toStringDER
Extract the DER encoded string.- Returns:
- the DER encoded string
-
toStringRaw
Extract the raw string.- Returns:
- the raw string
-
toAccountId
Create a new account id.- Parameters:
shard- the shard partrealm- the realm part- Returns:
- the new account id
-
isED25519
public abstract boolean isED25519()Is this an ED25519 key?- Returns:
- is this an ED25519 key
-
isECDSA
public abstract boolean isECDSA()Is this an ECDSA key?- Returns:
- is this an ECDSA key
-
toEvmAddress
Converts the key to EVM address- Returns:
- the EVM address
-
unusableKey
Returns an "unusable" public key. “Unusable” refers to a key such as an Ed25519 0x00000... public key, since it is (presumably) impossible to find the 32-byte string whose SHA-512 hash begins with 32 bytes of zeros.- Returns:
- The "unusable" key
-