ERC20
use tfhe::FheUint64;
use tfhe::prelude::FheOrd;
use tfhe::prelude::FheTrivialEncrypt;
use tfhe::prelude::IfThenElse;
#[allow(dead_code)]
fn erc20_transfer_whitepaper(
from_amount: &FheUint64,
to_amount: &FheUint64,
amount: &FheUint64,
) -> (FheUint64, FheUint64) {
let has_enough_funds = (from_amount).ge(amount);
let zero_amount = FheUint64::encrypt_trivial(0u64);
let amount_to_transfer = has_enough_funds.select(amount, &zero_amount);
let new_to_amount = to_amount + &amount_to_transfer;
let new_from_amount = from_amount - &amount_to_transfer;
(new_from_amount, new_to_amount)
}Last updated
Was this helpful?