Package com.algorand.algosdk.crypto
Class Address
- java.lang.Object
-
- com.algorand.algosdk.crypto.Address
-
- All Implemented Interfaces:
Serializable
public class Address extends Object implements Serializable
Address represents a serializable 32-byte length Algorand address.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static byte[]
APP_ID_PREFIX
static int
LEN_BYTES
The length of an address.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
compareTo(String address)
String
encodeAsString()
encodeAsString converts the address to a human-readable representation, with a 4-byte checksum appended at the end, using SHA256.boolean
equals(Object obj)
static Address
forApplication(long appID)
Get the escrow address of an application.byte[]
getBytes()
Get the underlying bytes wrapped by this Address.String
toString()
PublicKey
toVerifyKey()
toVerifyKey returns address' public key in a form suitable for java.security.Signature.initVerifyboolean
verifyBytes(byte[] message, Signature signature)
verifyBytes verifies that the signature for the message is valid for the public key.
-
-
-
Field Detail
-
LEN_BYTES
public static final int LEN_BYTES
The length of an address. Equal to the size of a SHA256 checksum.- See Also:
- Constant Field Values
-
APP_ID_PREFIX
public static final byte[] APP_ID_PREFIX
-
-
Constructor Detail
-
Address
public Address(byte[] bytes)
Create a new address from a byte array.- Parameters:
bytes
- array of 32 bytes
-
Address
public Address()
-
Address
public Address(String encodedAddr) throws NoSuchAlgorithmException
Create a new address from an encoded string, (encoded by encodeAsString)- Parameters:
encodedAddr
-- Throws:
NoSuchAlgorithmException
-
-
Method Detail
-
getBytes
public byte[] getBytes()
Get the underlying bytes wrapped by this Address.- Returns:
- 32 byte array
-
encodeAsString
public String encodeAsString() throws NoSuchAlgorithmException
encodeAsString converts the address to a human-readable representation, with a 4-byte checksum appended at the end, using SHA256. Note that string representations of addresses generated by different SDKs may not be compatible.- Returns:
- Throws:
NoSuchAlgorithmException
-
verifyBytes
public boolean verifyBytes(byte[] message, Signature signature) throws NoSuchAlgorithmException, InvalidKeySpecException, InvalidKeyException, SignatureException
verifyBytes verifies that the signature for the message is valid for the public key. The message should have been prepended with "MX" when signing.- Parameters:
message
- the message that was signedsignature
-- Returns:
- boolean; true if the signature is valid
- Throws:
NoSuchAlgorithmException
InvalidKeySpecException
InvalidKeyException
SignatureException
-
toVerifyKey
public PublicKey toVerifyKey() throws InvalidKeySpecException, NoSuchAlgorithmException
toVerifyKey returns address' public key in a form suitable for java.security.Signature.initVerify- Returns:
- PublicKey
- Throws:
InvalidKeySpecException
NoSuchAlgorithmException
-
compareTo
public boolean compareTo(String address)
-
forApplication
public static Address forApplication(long appID) throws NoSuchAlgorithmException, IOException
Get the escrow address of an application.- Parameters:
appID
- The ID of the application.- Returns:
- The address corresponding to that application's escrow account.
- Throws:
NoSuchAlgorithmException
IOException
-
-