import { Range } from "../provers/range.js"; import { CipherBalance, GeneralPrefixData, ProjectivePoint } from "../types.js"; export declare const WITHDRAW_CAIRO_STRING = 8604536554778681719n; /** * Public inputs of the verifier for the withdraw operation. * @interface InputsWithdraw * @property {ProjectivePoint} y - The Tongo account to withdraw from * @property {bigint} nonce - The nonce of the Tongo account * @property {bigint} to - The starknet contract address to send the funds to * @property {bigint} amount - The amount of tongo to withdraw * @property {CipherBalance} currentBalance - The current CipherBalance stored for the account * @property {number} bit_size - The bit size for range proofs * @property {GeneralPrefixData} prefix_data - General prefix data for the operation */ export interface InputsWithdraw { y: ProjectivePoint; nonce: bigint; to: bigint; amount: bigint; currentBalance: CipherBalance; auxiliarCipher: CipherBalance; bit_size: number; prefix_data: GeneralPrefixData; } /** * Proof of withdraw operation. * @interface ProofOfWithdraw * @property {ProjectivePoint} A_x - The proof point A_x * @property {ProjectivePoint} A_r - The proof point A_r * @property {ProjectivePoint} A - The proof point A * @property {ProjectivePoint} A_v - The proof point A_v * @property {bigint} sx - The proof scalar sx * @property {bigint} sb - The proof scalar sb * @property {bigint} sr - The proof scalar sr * @property {Range} range - The range proof * @todo Remove the _ from property names? */ export interface ProofOfWithdraw { A_x: ProjectivePoint; A_r: ProjectivePoint; A: ProjectivePoint; A_v: ProjectivePoint; sx: bigint; sb: bigint; sr: bigint; range: Range; } export declare function proveWithdraw(private_key: bigint, initial_balance: bigint, amount: bigint, to: bigint, initial_cipherbalance: CipherBalance, nonce: bigint, bit_size: number, prefix_data: GeneralPrefixData): { inputs: InputsWithdraw; proof: ProofOfWithdraw; newBalance: CipherBalance; }; /** * Verifies the withdraw operation. First, users have to show knowledge of the private key. Then, users have to provide * a cleartext of the amount b to withdraw. The contract will construct a cipher balance (L2, R2) = (g**b y**r2, g**r2) * with randomness r2='withdraw'. The contract will subtract (L2,R2) to the stored balance of the user. The user have * to provide a zk proof that the final cipher balance is encrypting a positive (a value in (0, u**32)) amount b_left. To do * this when the RangeProof is verified, it returns a V = g**b_left h**r, with b_left positive. V is used as an L part of * a cipher balance, users have to prove that the cipher balance (V, R_aux = g**r) is encrypting the same amount * that the final cipher balance. * * Complexity: * - EC_MUL: 12 + n*5 = 172 for u32 * - EC_ADD: 8 + n*4 = 136 for u32 * * @param {InputsWithdraw} inputs - The withdraw operation inputs * @param {ProofOfWithdraw} proof - The proof to verify * @returns {boolean} True if the proof is valid, false otherwise */ export declare function verifyWithdraw(inputs: InputsWithdraw, proof: ProofOfWithdraw): void;