This question is a possible duplicate. However, I think this code may be helpful for your POC i.e. signing and verifying messages without the use of Web3js.
Using Java, the ECKey.java class in EthereumJ gives you all the required functionality. Here's an example of it in practice...
Signing:
public void testEthereumSign() throws IOException {
ECKey key = ECKey.fromPrivate(privateKey);
System.out.println("Secret\t: " + Hex.toHexString(key.getPrivKeyBytes()));
System.out.println("Pubkey\t: " + Hex.toHexString(key.getPubKey()));
System.out.println("Data\t: " + exampleMessage);
byte[] messageHash = HashUtil.sha3(exampleMessage.getBytes());
ECDSASignature signature = key.sign(messageHash);
String output = signature.toBase64();
System.out.println("Signtr\t: " + output + " (Base64, length: " + output.length() + ")");
assertEquals(sigBase64, output);
}
Verifying:
public void testVerifySignature1() {
ECKey key = ECKey.fromPublicOnly(pubKey);
BigInteger r = new BigInteger("28157690258821599598544026901946453245423343069728565040002908283498585537001");
BigInteger s = new BigInteger("30212485197630673222315826773656074299979444367665131281281249560925428307087");
ECDSASignature sig = ECDSASignature.fromComponents(r.toByteArray(), s.toByteArray(), (byte) 28);
key.verify(HashUtil.sha3(exampleMessage.getBytes()), sig);
}
Python with pyethereum:
sign(key, network_id=None)
- signs the transaction with the given key
sha3(data)
- computes the SHA3 (or more precisely, keccak256) hash
ecrecover_to_pub(hash, v, r, s)
- recovers the public key that made
the signature as a 64-byte binary blob of encode_int32(x) +
encode_int32(y). Hashing this and taking the last 20 bytes gives the
address that signed a message.
ecsign(hash, key)
- returns the v, r, s values of a signature
normalize_key(key)
- converts a key from many formats into 32-byte binary
privtoaddr(key)
- converts a key to an
address
w3.eth.account.sign()
does what you're looking for. Unfortunately, it's only accessible by installing from source, at the moment. It is scheduled to be released as beta in the next week or so.