2
$\begingroup$

In Vitalik Buterin's write-up on SNARKs Quadratic Arithmetic Programs: from Zero to Hero, he writes

Note that the above is a simplification; “in the real world”, the addition, multiplication, subtraction, and division will happen not with regular numbers, but rather with finite field elements

I assume SNARKs are used in blockchains to hide & also verify the transactions. However, blockchain transactions may involve non-integer amounts (the sender is sending a fractional amount), so how are the private (witness) & public inputs which involve non-integer numbers represented in finite fields?

UPDATE from one of the answers:

Since a Satoshi is 0.00000001 BTC every send/receive transaction can probably be an integer value.

Is there any other stuff on a blockchain which are shielded by zkSNARKs and can have non integer values or everything for which zkSNARKs are used on a blockchain is integer values?

$\endgroup$
4
  • $\begingroup$ I didn't realize blockchain transaction values are floating points. I always thought financial data would use fixed-point numbers for accuracy. $\endgroup$
    – DannyNiu
    Feb 8, 2023 at 12:00
  • $\begingroup$ @DannyNiu - I have updated the question - I actually wanted to ask about any non-integer values $\endgroup$
    – user93353
    Feb 8, 2023 at 12:10
  • $\begingroup$ Your question has been answered. In practice under finite precision all values are rational, and can be boosted up to integers by multiplying with the denominator. $\endgroup$
    – kodlu
    Feb 9, 2023 at 23:34
  • $\begingroup$ @kodlu - I also want to know if there are any kinds of SNARK shielded transactions/computations on a blockchain which need this type of boosting $\endgroup$
    – user93353
    Feb 10, 2023 at 1:10

1 Answer 1

4
$\begingroup$

If necessary, this can be done by sending all $n$ digits of the fraction (it has to be finite length to be represented digitally) and an encoding (in $\log_2(n+1)$ bits) of the position of the decimal point. However it may not be needed, one can simply express the transaction as an integer multiple of a minimum allowed amount in fractional satoshis.

Edit:

zk-snarks are used to shield cryptocurrency transactions and according to the bitcoin setup we have:

"A UTXO (unspent transaction output) can have an arbitrary value denominated as a multiple of satoshis." Reference is Mastering Bitcoin, Chapter 5

$\endgroup$
2
  • $\begingroup$ Is it how it's actually done in real world blockchains which use SNARKs? $\endgroup$
    – user93353
    Feb 8, 2023 at 12:11
  • $\begingroup$ A UTXO (unspent transaction output) can have an arbitrary value denominated as a multiple of satoshis - Since a satoshi is 0.00000001 BTC every transaction is an integer value, right? So there is no chance a SNARK will involve non-integers on a blockchain? $\endgroup$
    – user93353
    Feb 8, 2023 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.