I want to decrypt some encrypted RSA payload at the anchor program. So I've tried to cargo add
some RSA libraries such as rsa
, ring
, and openssl
. But when I tried to build the anchor, it all failed. I think it's not supported for solana program. Is there a way to build these libraries for solana/anchor? How could I use RSA at the program?
Add a comment
|
1 Answer
Unfortunately, the answer is simple: you can't. Even if you manage to compile the crates, your program won't be able to perform decryption on-chain without going over the compute limit.
Any cryptographic operation must use the Solana platform syscalls. Here are some examples:
- secp256k1_recover: https://github.com/anza-xyz/agave/blob/3b9e7a3ca53e73f066be058edae0ccaffda852f3/curves/secp256k1-recover/src/lib.rs#L397
- alt bn128 addition: https://github.com/anza-xyz/agave/blob/3b9e7a3ca53e73f066be058edae0ccaffda852f3/curves/bn254/src/lib.rs#L310
- alt bn128 multiplication: https://github.com/anza-xyz/agave/blob/3b9e7a3ca53e73f066be058edae0ccaffda852f3/curves/bn254/src/lib.rs#L330
- curve 25519 operations: https://github.com/anza-xyz/agave/blob/3b9e7a3ca53e73f066be058edae0ccaffda852f3/sdk/program/src/syscalls/definitions.rs#L37
-
How could I use Solana platform syscalls? Could you give me the examples? Commented Aug 16 at 6:11
-