Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public final class PersonalSign

  1. Object
  2. 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.

Methods

public static byte[] hash(byte[] message)keccak256("\x19Ethereum Signed Message:\n" + len(message) + message).
public static byte[] hash(String message)hash of a text message, UTF-8 encoded.
public static byte[] sign(byte[] message, byte[] privateKey)Signs a message as personal_sign does.
public static byte[] sign(String message, byte[] privateKey)Signs a text message as personal_sign does.
public static EvmAddress recover(byte[] message, byte[] signature65)The address that signed a message.
public static boolean verify(String message, byte[] signature65, EvmAddress address)Tells whether address signed the text message.
public static byte[] signHash(byte[] hash32, byte[] privateKey)Signs a 32-byte digest, answering r || s || v with v 27 or 28.
public static EvmAddress recoverHash(byte[] hash32, byte[] signature65)The address whose key produced signature65 over a 32-byte digest.

Inherited methods

Method details

hash

public static byte[] hash(byte[] message)
keccak256("\x19Ethereum Signed Message:\n" + len(message) + message).

hash

public static byte[] hash(String message)
hash of a text message, UTF-8 encoded.

sign

public static byte[] sign(byte[] message, byte[] privateKey)
Signs a message as personal_sign does.

sign

public static byte[] sign(String message, byte[] privateKey)
Signs a text message as personal_sign does.

recover

public static EvmAddress recover(byte[] message, byte[] signature65)
The address that signed a message.

Throws

IllegalArgumentException
for a malformed signature
com.codename1.security.CryptoException
when the signature recovers no key

verify

public static boolean verify(String message, byte[] signature65, EvmAddress address)
Tells whether address signed the text message.

signHash

public static byte[] signHash(byte[] hash32, byte[] privateKey)
Signs a 32-byte digest, answering r || s || v with v 27 or 28.

recoverHash

public static EvmAddress recoverHash(byte[] hash32, byte[] signature65)
The address whose key produced signature65 over a 32-byte digest.