import { Keypair } from './keypair'; import { Curve, Backend } from './note'; export type UtxoGenInput = { curve: Curve; backend: Backend; amount: string; chainId: string; blinding?: Uint8Array; index?: string; keypair?: Keypair; originChainId?: string; }; export declare class Utxo { _keypair: Keypair; _curve: Curve; _backend: Backend; _amount: string; _chainId: string; _index?: number; _pubkey: string; _secret_key: string; _blinding: string; _originChainId?: string; serialize(): string; /** * @param utxoString - A string representation of the parts that make up a utxo. * - All values are represented as BigEndian, hex-encoded strings unless indicated otherwise. * - Optional values are represented as the empty string if not present, * meaning the split call will always be an array of length "parts". * * parts[0] - Curve value, e.g. Bn254, Bls381, Ed25519, etc. value represented as string. * parts[1] - Backend value, e.g. arkworks or circom. value represented as string. * parts[2] - Amount of atomic units, e.g. ETH in wei amounts or DOT in 10^12 decimals. value represented as uint. * parts[3] - TypedChainId, the hex value of the calculated typed chain id * parts[4] - Blinding, secret random value * parts[5] - PublicKey, the "publicKey = hash(privateKey)" value which indicates ownership for a utxo. * parts[6] Optional - EncryptionKey, the public key of "publicKey = encryptionScheme(privateKey)" value used for messaging. * parts[7] Optional - PrivateKey, the secret key component correlated to the above values. * parts[8] Optional - Index, the leaf index if the utxo has been inserted in a merkle tree * @returns The Utxo object implementation of a Utxo. */ static deserialize(utxoString: string): Utxo; static generateUtxo(input: UtxoGenInput): Utxo; /** * Encrypt UTXO data using the current keypair. * This is used in the externalDataHash calculations so the funds for this deposit * can only be spent by the owner of `this.keypair`. * * @returns `0x`-prefixed hex string with data */ encrypt(): string; /** * Decrypt a UTXO * * @param keypair - keypair used to decrypt * @param data - hex string with data * @returns a UTXO object */ static decrypt(keypair: Keypair, data: string): Utxo; get keypair(): Keypair; set keypair(keypair: Keypair); get amount(): string; set amount(amount: string); get blinding(): string; set blinding(blinding: string); get chainId(): string; set chainId(chainId: string); get originChainId(): string | undefined; set originChainId(originChainId: string | undefined); /** * Returns commitment for this UTXO * * @returns the poseidon hash of [chainId, amount, pubKey, blinding] */ get commitment(): Uint8Array; /** * @returns the index configured on this UTXO. Output UTXOs generated * before they have been inserted in a tree. * */ get index(): number; set index(index: number); /** * @returns the nullifier: hash of [commitment, index, signature] as decimal string * where signature = hash([secret key, commitment, index]) */ get nullifier(): string; get public_key(): string; /** * @returns the secret_key AKA private_key used in the nullifier. * this value is used to derive the public_key for the commitment. */ get secret_key(): string; set secret_key(secret: string); getKeypair(): Keypair; setKeypair(keypair: Keypair): void; setOriginChainId(originChainId: string | undefined): void; setIndex(val: number): void; }