scheme.md 9.4 KB

Scheme

Let $\t{Params}\t{VC}, \t{Bulla}\t{VC}$ be defined as in Vesting Configuration Model.

Let $\t{Coin}$ be defined as in the section Coin.

Let $โ„™โ‚š, ๐”ฝโ‚š, \mathcal{X}, \mathcal{Y}, \t{๐”นโถโด2๐”ฝโ‚š}$ be defined as in the section Pallas and Vesta.

Let $tโ‚€ = \t{BlockWindow} โˆˆ ๐”ฝโ‚š$ be the current blockwindow as defined in Blockwindow.

Let $\t{PoseidonHash}$ be defined as in the section PoseidonHash Function.

Let $\t{ElGamal.Encrypt}, \t{ElGamalEncNote}โ‚–$ be defined as in the section Verifiable In-Band Secret Distribution.

Denote the Vesting contract ID by $\t{CID}\t{V} โˆˆ ๐”ฝโ‚š$ and its Exec function spend hook by $\t{SH}\t{V} โˆˆ ๐”ฝโ‚š$.

Vest

This function creates a vesting configuration bulla $โ„ฌ_\t{VC}$. We commit to the vesting configuration params and then add the bulla to the set, along with the vested coin $\t{Coin}$ minted by the child Money::transfer() call. Each vesting configuration keeps track of its minted coins, to ensure that only those can be burned in next actions, creating a sequence of coins, enabling the contract to keep track of remaining balances anonymously. Additionally, we verify the minted vesting coin is encrypted for the configuration shared secret key, ensuring both parties have access to it.

  • Wallet builder: TODO: add client path
  • WASM VM code: TODO: add entrypoint path
  • ZK proof: TODO: add proof path

Function Params

Define the vest function params $$ \begin{aligned} โ„ฌ\t{VC} &โˆˆ \t{im}(\t{Bulla}\t{VC}) \ \t{SPK} &โˆˆ โ„™โ‚š \end{aligned} $$

TODO: Add call params path

Contract Statement

Vesting configuration bulla uniqueness โ€ƒ whether $โ„ฌ_\t{VC}$ already exists. If yes then fail.

Let there be a prover auxiliary witness inputs: $$ \begin{aligned} VAx &โˆˆ ๐”ฝโ‚š \ VPK &โˆˆ ๐”ฝโ‚š \ Sx &โˆˆ ๐”ฝโ‚š \ ฯ„ &โˆˆ ๐”ฝโ‚š \ T &โˆˆ โ„•โ‚†โ‚„ \ C &โˆˆ โ„•โ‚†โ‚„ \ S &โˆˆ โ„•โ‚†โ‚„ \ E &โˆˆ โ„•โ‚†โ‚„ \ V &โˆˆ โ„•โ‚†โ‚„ \ b\t{VC} &โˆˆ ๐”ฝโ‚š \ b\t{Coin} &โˆˆ ๐”ฝโ‚š \end{aligned} $$

Attach a proof $ฯ€$ such that the following relations hold:

Proof that start blockwindow is greater than current blockwindow โ€ƒ $S > tโ‚€$.

Proof that end blockwindow is greater than start blockwindow โ€ƒ $E > S$.

Proof that total is greater than cliff โ€ƒ $T >= C$.

Proof that blockwindow value is valid โ€ƒ $T == (E - S) * V + C$.

Proof of vesting authority public key ownership โ€ƒ $\t{VAPK} = \t{DerivePubKey}(VAx)$.

Proof of shared secret public key ownership โ€ƒ $\t{SPK} = \t{DerivePubKey}(Sx)$.

Vesting configuration bulla integrity โ€ƒ $โ„ฌ = \t{Bulla}\t{VC}(\mathcal{X}(p.\t{VAPK}), \mathcal{Y}(p.\t{VAPK}), \mathcal{X}(p.\t{VPK}), \mathcal{Y}(p.\t{VPK}), \mathcal{X}(p.\t{SPK}), \mathcal{Y}(p.\t{SPK}), t, T, C, S, E, V, b\t{VC})$

Minted vested coin integrity โ€ƒ $Coin = \t{PoseidonHash}(\mathcal{X}(p.\t{SPK}), \mathcal{Y}(p.\t{SPK}), T, t, \t{CID}\t{V}, \t{SH}\t{V}, โ„ฌ, b_\t{Coin})$

Verifiable vested coin note encryption โ€ƒ let $๐ง = (c.v, c.ฯ„, c.\t{SH}, c.\t{UD}, c.n)$, and verify $a = \t{ElGamal}.\t{Encrypt}(๐ง, \t{esk}, d.\t{SPK})$.

Signatures

There should be a single signature attached, which uses $\t{SPK}$ as the signature public key.

Withdraw

This function enables the vestee to withdraw the corresponding unlocked value up to that blockwindow. The child Money::transfer() call must contain a single input, the vested coin we burn, and two outputs. The first one being the withdrawed one while the second one is the remaining vested balance coin. Both coins values are verified by the vesting configuration rules, and we store the second one as the current vested coin, to burn in next actions. Additionally, we verify the second/vested coin is encrypted for the configuration shared secret key, ensuring both parties have access to it.

  • Wallet builder: TODO: add client path
  • WASM VM code: TODO: add entrypoint path
  • ZK proof: TODO: add proof path

Function Params

Define the withdraw function params $$ \begin{aligned} โ„ฌ\t{VC} &โˆˆ \t{im}(\t{Bulla}\t{VC}) \ \t{SPK} &โˆˆ โ„™โ‚š \end{aligned} $$

TODO: Add call params path

Contract Statement

Vesting configuration bulla existance โ€ƒ whether $โ„ฌ_\t{VC}$ exists. If no then fail.

Burned vested coin existance โ€ƒ whether the burned coin $\t{BCoin}$ matches the vesting configuration record one. If no then fail.

Let there be a prover auxiliary witness inputs: $$ \begin{aligned} VAPK &โˆˆ ๐”ฝโ‚š \ Vx &โˆˆ ๐”ฝโ‚š \ Sx &โˆˆ ๐”ฝโ‚š \ ฯ„ &โˆˆ ๐”ฝโ‚š \ T &โˆˆ โ„•โ‚†โ‚„ \ C &โˆˆ โ„•โ‚†โ‚„ \ S &โˆˆ โ„•โ‚†โ‚„ \ E &โˆˆ โ„•โ‚†โ‚„ \ V &โˆˆ โ„•โ‚†โ‚„ \ b\t{VC} &โˆˆ ๐”ฝโ‚š \ Bv &โˆˆ โ„•โ‚†โ‚„ \ b\t{BCoin} &โˆˆ ๐”ฝโ‚š \ xc &โˆˆ ๐”ฝโ‚š \ Cv &โˆˆ โ„•โ‚†โ‚„ \ b\t{Coin} &โˆˆ ๐”ฝโ‚š \end{aligned} $$

Attach a proof $ฯ€$ such that the following relations hold:

Proof of vestee public key ownership โ€ƒ $\t{VPK} = \t{DerivePubKey}(Vx)$.

Proof of shared secret public key ownership โ€ƒ $\t{SPK} = \t{DerivePubKey}(Sx)$.

Vesting configuration bulla integrity โ€ƒ $โ„ฌ = \t{Bulla}\t{VC}(\mathcal{X}(p.\t{VAPK}), \mathcal{Y}(p.\t{VAPK}), \mathcal{X}(p.\t{VPK}), \mathcal{Y}(p.\t{VPK}), \mathcal{X}(p.\t{SPK}), \mathcal{Y}(p.\t{SPK}), t, T, C, Cb, S, E, V, b\t{VC})$

Proof that current blockwindow is greater than start blockwindow โ€ƒ $tโ‚€ >= S$.

TODO: cond_select statement to pick current or end blockwindow

Proof of withdraw amount correctness โ€ƒ $$ \begin{aligned} CurrentBlockwindow = CondSelect(BlockwindowCond, tโ‚€, E); \ BlockwindowsPassed = CurrentBlockwindow - S; \ Available = (BlockwindowsPassed * V) + C; \ Withdrawn = T - Bv; \ WithdrawlCoinValue = Available - Withdrawn; \ VestingChangeValue = T - (Withdrawn + WithdrawlCoinValue); \end{aligned} $$

Verify the child Money::transfer() call correctnes:

Burned vested coin integrity โ€ƒ $BCoin = \t{PoseidonHash}(\mathcal{X}(p.\t{SPK}), \mathcal{Y}(p.\t{SPK}), Bv, t, \t{CID}\t{V}, \t{SH}\t{V}, โ„ฌ, b_\t{Coin})$

Burned vested coin nullifier integrity โ€ƒ $\cN = \t{PoseidonHash}(x_c, BCoin)$

Minted vested coin integrity โ€ƒ $Coin = \t{PoseidonHash}(\mathcal{X}(p.\t{SPK}), \mathcal{Y}(p.\t{SPK}), VestingChangeValue, t, \t{CID}\t{V}, \t{SH}\t{V}, โ„ฌ, b_\t{Coin})$

Verifiable vested coin note encryption โ€ƒ let $๐ง = (c.v, c.ฯ„, c.\t{SH}, c.\t{UD}, c.n)$, and verify $a = \t{ElGamal}.\t{Encrypt}(๐ง, \t{esk}, d.\t{SPK})$.

Signatures

There should be a single signature attached, which uses $\t{SPK}$ as the signature public key.

Forfeit

This function enables the vesting authority to forfeit a vesting configuration, withdrawing the rest of vested value. The child Money::transfer() call must containg a single input, the vested coin we burn, and a single output, the newlly minted coin. Both coins values are verified by the vesting configuration rules, and we remove the vesting configuration bulla $โ„ฌ_\t{VC}$ entry from the set.

  • Wallet builder: TODO: add client path
  • WASM VM code: TODO: add entrypoint path
  • ZK proof: TODO: add proof path

Function Params

Define the vest function params $$ \begin{aligned} โ„ฌ\t{VC} &โˆˆ \t{im}(\t{Bulla}\t{VC}) \ \t{SPK} &โˆˆ โ„™โ‚š \end{aligned} $$

TODO: Add call params path

Contract Statement

Vesting configuration bulla existance โ€ƒ whether $โ„ฌ_\t{VC}$ exists. If no then fail.

Burned vested coin existance โ€ƒ whether the burned coin $\t{BCoin}$ matches the vesting configuration record one. If no then fail.

Let there be a prover auxiliary witness inputs: $$ \begin{aligned} VAx &โˆˆ ๐”ฝโ‚š \ VPK &โˆˆ ๐”ฝโ‚š \ Sx &โˆˆ ๐”ฝโ‚š \ ฯ„ &โˆˆ ๐”ฝโ‚š \ T &โˆˆ โ„•โ‚†โ‚„ \ C &โˆˆ โ„•โ‚†โ‚„ \ S &โˆˆ โ„•โ‚†โ‚„ \ E &โˆˆ โ„•โ‚†โ‚„ \ V &โˆˆ โ„•โ‚†โ‚„ \ b\t{VC} &โˆˆ ๐”ฝโ‚š Bv &โˆˆ โ„•โ‚†โ‚„ \ b\t{BCoin} &โˆˆ ๐”ฝโ‚š \ x_c &โˆˆ ๐”ฝโ‚š \end{aligned} $$

Attach a proof $ฯ€$ such that the following relations hold:

Proof of vesting authority public key ownership โ€ƒ $\t{VAPK} = \t{DerivePubKey}(VAx)$.

Proof of shared secret public key ownership โ€ƒ $\t{SPK} = \t{DerivePubKey}(Sx)$.

Vesting configuration bulla integrity โ€ƒ $โ„ฌ = \t{Bulla}\t{VC}(\mathcal{X}(p.\t{VAPK}), \mathcal{Y}(p.\t{VAPK}), \mathcal{X}(p.\t{VPK}), \mathcal{Y}(p.\t{VPK}), \mathcal{X}(p.\t{SPK}), \mathcal{Y}(p.\t{SPK}), t, T, C, S, E, V, b\t{VC})$

Proof of forfeit amount correctness โ€ƒ $ForfeitValue = T - Bv$

Verify the child Money::transfer() call correctnes:

Burned vested coin integrity โ€ƒ $BCoin = \t{PoseidonHash}(\mathcal{X}(p.\t{SPK}), \mathcal{Y}(p.\t{SPK}), ForfeitValue, t, \t{CID}\t{V}, \t{SH}\t{V}, โ„ฌ, b_\t{Coin})$

Burned vested coin nullifier integrity โ€ƒ $\cN = \t{PoseidonHash}(x_c, BCoin)$

Minted coin integrity โ€ƒ let $c.\t{CID}, c.\t{SH}, c.\t{UD}$ be the vesting authority chosen Contract ID, spend hook and user data for the minted coin, and verify $Coin = \t{PoseidonHash}(\mathcal{X}(p.\t{VAPK}), \mathcal{Y}(p.\t{VAPK}), ForfeitValue, t, \t{CID}, \t{SH}, \t{UD}, b_\t{Coin})$

Signatures

There should be a single signature attached, which uses $\t{SPK}$ as the signature public key.