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: Amounts #114

Merged
merged 12 commits into from
Mar 8, 2024
Merged

feat: Amounts #114

merged 12 commits into from
Mar 8, 2024

Conversation

aszepieniec
Copy link
Contributor

Amounts and amount logic are quite important in the design of a currency. This PR:

  • Implements (in compiler-friendly rust) a type script NativeCurrency that verifies that transactions are balanced, i.e., do not generate new coins or have negative outputs.
  • Upgrades the dependency on tasm-lib.
  • Simplifies the internal representation of NeptuneCoins amounts: it now uses a u128 rather than a U32s<NUM_LIMBS>.

aszepieniec and others added 12 commits February 27, 2024 15:54
Code compiles but tests fail (fixed in a later commit).

Co-authored-by: Thorkil Værge <[email protected]>
Co-authored-by: Ferdinand Sauer <[email protected]>
In `get_swbf_indices`, the input was padded explicitly (!) before
calling `pad_and_absorb_all`, resulting in a double pad. The output
of this function disagreed with the tasm-lib snippet.
The motivation for this struct is to have something to implement
`SecretWitness` for, which supplies the interface towards running
the VM on (and, at a later stage, proving) the right program.
Internally `NeptuneCoins` represented amounts as `U32s<4>`. This
commit changes that internal representation to `u128`. Also, it
adds a function `safe_add` which returns `None` if the result sets
the most significant bit.
Using `safe_add` as opposed to `+` catches overflows, which could lead
to inflation bugs.
Also: fix bug in amounts balancer.
@aszepieniec
Copy link
Contributor Author

  • Implement (in compiler-friendly rust) a type script NativeCurrency
    that verifies that transactions are balanced, i.e., do not generate
    new coins or have negative outputs.
  • Upgrades the dependency on tasm-lib.
  • Simplifies the internal representation of NeptuneCoins amounts:
    it now uses a u128 rather than a U32s<NUM_LIMBS>.

@aszepieniec aszepieniec merged commit e6a1270 into master Mar 8, 2024
3 checks passed
@Sword-Smith Sword-Smith deleted the aszepieniec/amounts branch August 27, 2024 10:55
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