Add std::array support to BigInt::serialize function#5153
Add std::array support to BigInt::serialize function#5153KaganCanSit wants to merge 1 commit intorandombit:masterfrom
Conversation
There was a problem hiding this comment.
Nice, thanks!
Interesting way to detect an array! However, IIUC this would work for other tuple-types as well, no? Like std::pair<int, std::string>. That would produce very strange compiler errors for sure... But then again, the API does also allow passing a std::vector<uint32_t>, which is just as awful I guess. You could look into using the statically_spanable_range<> concept to detect the array instead.
Anyway: Could you please add a few tests that serialize a BigInt into an array? src/tests/test_bigint.cpp has a function test_bigint_serialization, please add another CHECK that uses std::array. Also check that the exception is thrown as expected if the array is too short or too long.
cd14944 to
84439ab
Compare
You're right that it will provide general support for tuple types. I've made the changes as you suggested. Additionally, for the situation you mentioned, However, since this is a general change to the API, I haven't added it to the branch. What do you think? Update: 20.01.2026 - Rebase master branch and remove |
f0e12e3 to
fc8b8cd
Compare
reneme
left a comment
There was a problem hiding this comment.
Sorry for changing my mind on this, but I think there's a better strategy to implement this TODO.
fc8b8cd to
6161f70
Compare
Thanks for the detailed feedback and this learning opportunity. I've pushed the changes but since I worked on this after hours, I'd like to revisit and review them more thoroughly when I'm fresher (I'm not yet comfortable using concepts actively). I want to make sure I fully understand the reasoning behind each change. I will write experimental code blocks for exploration and possibly add more tests later. But absolutily like this way, more readable and effective. |
5e6e674 to
74c7a7a
Compare
reneme
left a comment
There was a problem hiding this comment.
LGTM. @randombit I'm guessing you agree with adding a BigInt::serialize_to_array<32>() given that you left the TODO?
74c7a7a to
1329eff
Compare
1329eff to
73d954c
Compare
This PR resolves the TODO comment in
BigInt::serialize()by adding support forstd::array<uint8_t, N>alongside existingstd::vectorandsecure_vectorsupport.TODO Message: