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

Monero: use only the first input ring length for RCT deserialization. #504

Merged
merged 2 commits into from
Jan 5, 2024

Conversation

Boog900
Copy link
Contributor

@Boog900 Boog900 commented Jan 4, 2024

This changes RCT deserialization to use the first inputs ring size for all inputs, which is how Monero does it [1] [2]. By using the first inputs ring size for all inputs Monero restricts all RCT transactions to have the same number of ring members across all inputs, otherwise the signatures would be incorrect as they would have a different number of elements than required.

This isn't an issue for current txs as from hf 12 Monero requires all inputs to have the same number of decoys anyway, but for transactions before that we would accept RCT txs with inputs differing in ring size whereas Monero would reject them.

I could add a rule in Cuprate that all RCT txs must have a constant number of decoys but I think it would be better to fix this mismatch in deserialization.

This also adds a check I missed in #383, Monero checks that MLSAG signatures have at least 2 ring members.

This is what Monero does:
https://github.com/monero-project/monero/blob/ac02af92867590ca80b2779a7bbeafa99ff94dcb/src/ringct/rctTypes.h#L422

https://github.com/monero-project/monero/blob/master/src/cryptonote_basic/cryptonote_basic.h#L308-L309

This isn't an issue for current transactions as from hf 12 Monero requires
all inputs to have the same number of decoys but for transactions before
that Monero would reject RCT txs with differing ring lengths. Monero would
deserialize each inputs signature using the ring length of the first so the
signatures for inputs other than the first would have a different
(wrong) number of elements for that input meaning the signature is invalid.

But as we are using the ring length of each input, which arguably is the
*correct* way, we would approve of transactions with inputs differing in
ring lengths.
@Boog900 Boog900 changed the title Monero: use only the first input ring length for all RCT input signatures. Monero: use only the first input ring length for RCT deserialization. Jan 4, 2024
@kayabaNerve
Copy link
Member

ACK.

Thanks for tightening this up :)

@kayabaNerve kayabaNerve added bug Something isn't working monero An issue with the Monero library/integration labels Jan 5, 2024
@kayabaNerve kayabaNerve merged commit 93e85c5 into serai-dex:develop Jan 5, 2024
16 checks passed
@kayabaNerve kayabaNerve deleted the rct-deser branch January 5, 2024 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working monero An issue with the Monero library/integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants