litentry / tee-worker

Based on the integritee-network/worker framework
Apache License 2.0
3 stars 3 forks source link

Use hash of raw message in identity verification #118

Closed Kailai-Wang closed 1 year ago

Kailai-Wang commented 1 year ago

Problem:

the web2 verification message needs to be encrypted with TEE's shielding key before being posted on the platform. Currently TEE uses 3072 bit RSA key pair which means the resulting ciphertext would be 384 bytes long => 768 chars in hex.

It will exceed the length limit of a tweet: 280 chars.

Suggested solution:

use blake2_256 hash of the composed message as the raw payload.

It means now the raw "cleartext" would be a fixed length (32) byte array => this will be what the user posts on twitter/discord It also means for some web3 verification scenarios (substrate-ecdsa and evm signature) we will have to hash twice: we are performing another blake2_256 and keccak_256 hashing to the hashed message, respectively => but we don't see a problem there

What about the hash collision

It's considered safe because:

Please feel free to leave a comment if you have concerns or better ideas

jingleizhang commented 1 year ago

It looks good.

  1. It's good for UX. Reducing message length can make the user send it just in one tweet. Meanwhile, the user can't know and even doesn't care about the original contents of the verification message.

  2. The total storage size for those hashed messages is under our control, because there is an expiration time for each message. Expired messages can be deleted at some step in the codes.

jonalvarezz commented 1 year ago

I actually like this hashing approach better than using the shielding key. It ensures the message can safely remain public as the risk of guessing the message is quite low.