mimblewimble / rust-secp256k1-zkp

ZKP fork for rust-secp256k1, adds wrappers for range proofs, pedersen commitments, etc
Creative Commons Zero v1.0 Universal
57 stars 51 forks source link

Update ArrayVec crate to 0.7 #84

Closed yeastplume closed 4 months ago

yeastplume commented 5 months ago

Previous to this, on latest version of Rust (1.78), the serialize_vec function was failing due to additional debug assertions in Rust:

'unsafe precondition(s) violated: slice::get_unchecked_mut requires that the index is within the slice': library/core/src/panicking.rs:215 

Note that our existing code isn't incorrect; ArrayVec allocates fixed memory according to its capacity (in this case setting its capacity to constants::PUBLIC_KEY_SIZE or 72). (This is made clearer by the newer parameter format of ArrayVec 0.7x). secp256k1_ec_pubkey_serialize returns the actual length according to whether the result is compressed or uncompressed and we call ArrayVec::set_len() to set the actual length of the data, which is where the problematic assertion is being raised. This appears to be due to an issue in earlier versions of the ArrayVec crate, which seems to have been resolved in the latest.