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

Panic in Ring Proof deserialization #18

Closed
ggwpez opened this issue Jun 16, 2024 · 3 comments
Closed

Panic in Ring Proof deserialization #18

ggwpez opened this issue Jun 16, 2024 · 3 comments

Comments

@ggwpez
Copy link

ggwpez commented Jun 16, 2024

Upstream tracked in arkworks-rs/algebra#834

Regression test:

#[test]
#[cfg(feature = "ring")]
pub fn regression_arkworks_algebra_834() {
    let proof: [u8; 752] = hex::decode("7ECBE998F5FCE67A356BF82CEF3D00FCDA30A23162368496816030E9AF49644E47115CAC904B988C2B9DEF01151449F8FE86294C18956C06FED4CC7A03605B6FAD2211AF913769AB629BEA809D0497BE8E3F77D35A6851FEBA581F30B1901C212365483994531C46A46D2068F1415E682F9D8B643CAA9EB49C0772786314950E8A6FCD32736E337CCCB2BC4887A02D3E78010BE68A7D6BC50F3334F023BA3404B635EFFF94BCFA3E49A332E4008BCECF2C9DB72F271A6C36A46F34BE757C9B655E06B1C9B05278C772DFA6A21ABFEFFA84E17DBCB003E5C2CA9A1E88794F1225A0AEBECDF88AC5DBF9D999D77710E9361B414CE70EA289AC82A1A0704185154693E166A44D95401521C8907F949776E29863C6A198474A0C18C5DC2F47EE446147C4EF8F94F547933326985E2985D355B62BC68A075DC6BA58FE86098119A26B214BC1F1CB90C68801A9A8D3F973B33664A44B761CE54370FB0F9C69EF2DB4B46E17413AE76FCAD5DB324653C81BD12E92F9451B221402A3FCE8DC1151EDDB70C4FE2BB4D17326DA1165D1AFD33A2D670ADEDA935409A4CF3576DED6B0D70A57267E75381C0469347E7E8C07AE812A3BE302C1A53C5DEBA9C64BCFC168B3533081C421E8F6FAA0C1960291FF93E82EA727EFCBEF27CDD3CC42DE1DDECC42E76752360BBE061714C2CD2EFB9AD8591947EAE5A18BCD170B30EF097DDE6FDE7266F1050957461E4CBE86A0884FD2297273BADF3286464D072A73A8C6669C040573CDF01C196DED7FD2F7AADB874A2AA3091C18EBAADA50A001A97076D0E76BBD008E62433A6E2B238E062EE7AEFC659E976EBA3C2DEA856C98FBB005EDFEB042AD6D01ADB11D0AC7BD2F9F2312DB3ED8E863778BE29478ED9B2D1A3E2F55106A7090B1DE4486F422373B6AD8A986A11F018B0F2DF776A59509276F8B7536133B4B8A4F0F8D2C8C6C46ABB23D445F1DFE75799899FA52F362135FC8BABEB1FBBDBB87855BB910FC82D31227954B333C869363A940CE9EFDE71348BC20FE689668980D67BA260D5EEDB53BA9539E096542B7").unwrap().try_into().unwrap();

    use crate::suites::bandersnatch::edwards::BandersnatchSha512Ell2 as S;
    // PANICS:
    crate::ring::Proof::<S>::deserialize_compressed(&proof[..]);
}
Stacktrace

---- testing::regression_arkworks_algebra_834 stdout ----
thread 'testing::regression_arkworks_algebra_834' panicked at /Users/vados/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ark-serialize-0.4.2/src/impls.rs:461:75:
called `Result::unwrap()` on an `Err` value: InvalidData
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/result.rs:1654:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/result.rs:1077:23
   4: ark_serialize::impls::<impl ark_serialize::CanonicalDeserialize for [T; N]>::deserialize_with_mode::{{closure}}
             at /Users/vados/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ark-serialize-0.4.2/src/impls.rs:461:13
   5: core::ops::try_trait::NeverShortCircuit<T>::wrap_mut_1::{{closure}}
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/try_trait.rs:385:36
   6: core::array::try_from_fn_erased
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/array/mod.rs:818:20
   7: core::array::try_from_fn
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/array/mod.rs:104:11
   8: core::array::from_fn
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/array/mod.rs:63:5
   9: ark_serialize::impls::<impl ark_serialize::CanonicalDeserialize for [T; N]>::deserialize_with_mode
             at /Users/vados/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ark-serialize-0.4.2/src/impls.rs:460:22
  10: <ring::piop::RingCommitments<F,C> as ark_serialize::CanonicalDeserialize>::deserialize_with_mode
             at /Users/vados/.cargo/git/checkouts/ring-proof-e9e49c3c86c409a2/b273d33/ring/src/piop/mod.rs:25:37
  11: <common::Proof<F,CS,Commitments,Evaluations> as ark_serialize::CanonicalDeserialize>::deserialize_with_mode
             at /Users/vados/.cargo/git/checkouts/ring-proof-e9e49c3c86c409a2/b273d33/common/src/lib.rs:78:37
  12: <ark_ec_vrfs::ring::Proof<S> as ark_serialize::CanonicalDeserialize>::deserialize_with_mode
             at ./src/ring.rs:38:37
  13: ark_serialize::CanonicalDeserialize::deserialize_compressed
             at /Users/vados/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ark-serialize-0.4.2/src/lib.rs:135:9
  14: ark_ec_vrfs::testing::regression_arkworks_algebra_834
             at ./src/testing.rs:76:5
  15: ark_ec_vrfs::testing::regression_arkworks_algebra_834::{{closure}}
             at ./src/testing.rs:71:41
  16: core::ops::function::FnOnce::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:250:5
  17: core::ops::function::FnOnce::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

One work-around would be to use two individual fields here instead of the [C; 2] array, since the issue only occurs for fixed size arrays. But there may be multiple of these occurrences.

@davxy
Copy link
Owner

davxy commented Jun 17, 2024

Ty for reporting. Lets see how the issue is handled upstream first

@davxy
Copy link
Owner

davxy commented Jun 23, 2024

Fixed by arkworks-rs/algebra#837
Waiting for ark-serialize 0.4.3 to be published

@davxy
Copy link
Owner

davxy commented Jul 10, 2024

Closed by w3f/ring-proof#24

@davxy davxy closed this as completed Jul 10, 2024
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

No branches or pull requests

2 participants