Class PersonalSign
java.lang.Object
com.codename1.crypto.evm.PersonalSign
EIP-191 personal_sign messages, the "Sign in with Ethereum" and wallet-ownership proof,
and the 65-byte r || s || v signatures EVM wallets exchange.
v is written as 27 or 28, the form personal_sign and eth_sign return; the
recovering methods also accept 0 and 1.
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]hash(byte[] message) keccak256("\x19Ethereum Signed Message:\n" + len(message) + message).static byte[]hash(byte[])of a text message, UTF-8 encoded.static EvmAddressrecover(byte[] message, byte[] signature65) The address that signed a message.static EvmAddressrecoverHash(byte[] hash32, byte[] signature65) The address whose key producedsignature65over a 32-byte digest.static byte[]sign(byte[] message, byte[] privateKey) Signs a message aspersonal_signdoes.static byte[]Signs a text message aspersonal_signdoes.static byte[]signHash(byte[] hash32, byte[] privateKey) Signs a 32-byte digest, answeringr || s || vwithv27 or 28.static booleanverify(String message, byte[] signature65, EvmAddress address) Tells whetheraddresssigned the textmessage.
-
Method Details
-
hash
public static byte[] hash(byte[] message) keccak256("\x19Ethereum Signed Message:\n" + len(message) + message). -
hash
hash(byte[])of a text message, UTF-8 encoded. -
sign
public static byte[] sign(byte[] message, byte[] privateKey) Signs a message aspersonal_signdoes. -
sign
Signs a text message aspersonal_signdoes. -
recover
The address that signed a message.
Throws
-
IllegalArgumentException: for a malformed signature -
com.codename1.security.CryptoException: when the signature recovers no key
-
-
verify
Tells whetheraddresssigned the textmessage. -
signHash
public static byte[] signHash(byte[] hash32, byte[] privateKey) Signs a 32-byte digest, answeringr || s || vwithv27 or 28. -
recoverHash
The address whose key producedsignature65over a 32-byte digest.
-