Score:2

If SNARKs generally work in finite fields, how are non integer values handled - say fixed point decimal numbers?

et flag

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?

DannyNiu avatar
vu flag
I didn't realize blockchain transaction values are floating points. I always thought financial data would use fixed-point numbers for accuracy.
et flag
@DannyNiu - I have updated the question - I actually wanted to ask about any non-integer values
kodlu avatar
sa flag
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.
et flag
@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
Score:4
sa flag

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

et flag
Is it how it's actually done in real world blockchains which use SNARKs?
et flag
`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?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.