Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Time locks #107

Merged
merged 33 commits into from
Feb 26, 2024
Merged

feat: Time locks #107

merged 33 commits into from
Feb 26, 2024

Conversation

aszepieniec
Copy link
Contributor

This PR introduces time locks, which are a type of type script that can lock a UTXO until a certain release date. UTXOs generated by the genesis block and mining rewards are time-locked.

Additionally, this PR:

  • renames native_coin to native_currency
  • copies the relevant interface from the tasm-lang compiler so as to run rust code in an environment emulating Triton VM
  • refactors consensus logic programs and relations
  • implements Arbitrary for several structs, including structs that are or hold witness data
  • adds tests for these arbitrary methods
  • wraps the list of input or output UTXOs into a struct containing a salt, so that claims pertaining to these sets can be reduced to claims pertaining to randomized commitments thereto.

aszepieniec and others added 30 commits February 23, 2024 16:28
Avoid confusion with `neptune_coins`, which is for an amount of the
native currency.
Both `native_currency` and `neptune_coin` belong in the new directory.
Additionally, this directory anticipates a the new typescript,
`time_lock`.
"Native coin" is now "native currency".
Also: add stub code for time lock type script.

Hat-tip-to: Thorkil Værge <[email protected]>
With this support, we can write programs in rust such that they can be
run natively or compiled first and then run in Triton VM.
Specifically:
 - Add dependencies for proptest
 - Move transaction primitive witness to a separate file
 - Rename the above to primitive witness
 - Implement arbitrary for a bunch of data structures, most
   importantly the primitive transaction witness
This commit:
 - defines a new data structure, `RootAndPaths` which holds a single
   Merkle root and a bunch of authentication paths
 - implements `proptest::Arbitrary` for `RootAndPaths`, enabling the
   user to supply the tree height and the leafs and leaf indices
 - defines a property test using `test_strategy` for `RootAndPaths`

Co-authored-by: Ferdinand Sauer <[email protected]>
Factoring out mutator set part of random witness generation.
The generation of the input UTXOs (with witnesses) and output UTXOs
(where we don't care about witnesses) for `arbitrary` from seeds and
amounts has been moved to separate functions, enabling code reuse.
Witness objects such as `transaction::PrimitiveWitness` can contain
lists of input and output UTXOs. This commit wraps these lists of
into a new dedicated struct `SaltedUtxos` which adds a `salt` field.
The purpose is such that consensus programs can reduce a claim about
the set of input and/or output UTXOs to a claim about a single hash
digest. The salt ensures that claims related to different transactions
or blocks but happen to pertain to the same list of UTXOs (e.g., the
empty list) reduce to claims about distinct digests.
Trait `SecretWitness` is the interface between a blob of data that
makes an atomic unit of consensus logic valid, and the VM computation
induced by that validity claim. As such it supports the generation of
the program, the nondeterminism, and the input. The last one in that
list is the new function declarations.

Also in this commit: new trait `TypeScriptWitness` specializes
`SecretWitness` because for all type scripts the input and output are
the same. Specifically, the output is empty, and the input is the
triple (transaction kernel mast hash, salted input utxos hash, salted
output utxos hash).
@aszepieniec aszepieniec merged commit 80552a8 into master Feb 26, 2024
3 checks passed
@aszepieniec aszepieniec deleted the aszepieniec/time-locks branch February 26, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant