Open
Description
Feature Request
Implement Rust equivalent of the encrypt_for_round
garaga/hydra/garaga/drand/tlock.py
Lines 30 to 91 in d71cc28
garaga/src/src/utils/drand.cairo
Line 693 in d71cc28
- Users should be able to encrypt a msg for a specific round OR a specific time from Rust and javascript with the wasm binding. Add a time_to_round_number function and provide both alternatives.
- the output (as list of Felt/BigUint) should be serialized for the Corresponding Cairo struct ciphertext :
garaga/src/src/utils/drand.cairo
Lines 532 to 536 in d71cc28
- Carefully handle errors with Result<>, especially for input larger than 16 bytes.
- Use cryptographically secure random number generation (similar to the
secrets
lib in python which is more secure thanrandom
)
Test by :
- adding a method serialize_to_calldata to the Python Ciphertext struct https://github.com/keep-starknet-strange/garaga/blob/d71cc28b8aa8066d27f02e84fc4577b156533be5/hydra/garaga/drand/tlock.py#L12C1-L27C20 or other relevant methods
- adding a python binding for the rust encrypt_for_round function
- test ciphertexts as calldata are equal for similar inputs (use debug mode or a variant to use same secrets on both sides)
Final note :
For rust and typescript, we can drop the drand_public_key: G2Point
parameter and assume a default public key which will be the drand quicknet public key.