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

make JamtisDestinationV1 serializable #11

Merged
merged 5 commits into from
Jun 8, 2023

Conversation

DangerousFreedom1984
Copy link

Could you please add these changes? I need to work with a serialized JamtisDestinationV1.

src/seraphis_impl/serialization_demo_types.h Outdated Show resolved Hide resolved
src/seraphis_impl/serialization_demo_utils.cpp Outdated Show resolved Hide resolved
src/seraphis_impl/serialization_demo_utils.cpp Outdated Show resolved Hide resolved
src/seraphis_mocks/jamtis_mock_keys.cpp Outdated Show resolved Hide resolved
src/seraphis_mocks/jamtis_mock_keys.h Outdated Show resolved Hide resolved
src/seraphis_mocks/jamtis_mock_keys.h Outdated Show resolved Hide resolved
@@ -71,6 +77,21 @@ struct jamtis_mock_keys
rct::key K_1_base; //jamtis spend base = k_vb X + k_m U
crypto::x25519_pubkey xK_ua; //unlock-amounts pubkey = xk_ua xG
crypto::x25519_pubkey xK_fr; //find-received pubkey = xk_fr xk_ua xG

crypto::chacha_iv m_encryption_iv;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer that you implement a password-protected wrapper class instead of embedding encryption details inside the struct.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could write a template for password-protected keys.
A) static assert that the template type is POD
B) encrypt/decrypt the entire data struct as raw data (cast to void* and encrypt/decrypt in-place)
C) use RAII somehow to ensure the struct is re-encrypted as needed
D) be sure to safely handle multithreaded access to the protected container

src/seraphis_mocks/jamtis_mock_keys.h Outdated Show resolved Hide resolved
src/seraphis_impl/serialization_demo_utils.h Outdated Show resolved Hide resolved
@DangerousFreedom1984
Copy link
Author

Thanks for the detailed comments.

I will let ghostway make the changes (if he did not do it yet) related to the key_container (jamtis_mock_keys.*) as he is working on it. So I removed this part from the PR.

src/seraphis_impl/serialization_demo_types.h Outdated Show resolved Hide resolved
src/seraphis_impl/serialization_demo_types.h Outdated Show resolved Hide resolved
src/seraphis_impl/serialization_demo_types.h Show resolved Hide resolved
src/seraphis_impl/serialization_demo_utils.cpp Outdated Show resolved Hide resolved
src/seraphis_impl/serialization_demo_utils.cpp Outdated Show resolved Hide resolved
src/seraphis_impl/serialization_demo_utils.cpp Outdated Show resolved Hide resolved
Comment on lines 395 to 397
serializable_dest_out.addr_K1 = dest.addr_K1;
serializable_dest_out.addr_K2 = dest.addr_K2;
serializable_dest_out.addr_K3 = dest.addr_K3;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
serializable_dest_out.addr_K1 = dest.addr_K1;
serializable_dest_out.addr_K2 = dest.addr_K2;
serializable_dest_out.addr_K3 = dest.addr_K3;
serializable_dest_out.addr_K1 = dest.addr_K1;
serializable_dest_out.addr_K2 = dest.addr_K2;
serializable_dest_out.addr_K3 = dest.addr_K3;

Comment on lines 696 to 698
dest_out.addr_K1 = serializable_destination.addr_K1;
dest_out.addr_K2 = serializable_destination.addr_K2;
dest_out.addr_K3 = serializable_destination.addr_K3;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dest_out.addr_K1 = serializable_destination.addr_K1;
dest_out.addr_K2 = serializable_destination.addr_K2;
dest_out.addr_K3 = serializable_destination.addr_K3;
dest_out.addr_K1 = serializable_destination.addr_K1;
dest_out.addr_K2 = serializable_destination.addr_K2;
dest_out.addr_K3 = serializable_destination.addr_K3;

@UkoeHB UkoeHB merged commit fb30680 into UkoeHB:seraphis_lib Jun 8, 2023
DangerousFreedom1984 added a commit to DangerousFreedom1984/seraphis_lib that referenced this pull request Jul 10, 2023
make JamtisDestinationV1 serializable 

---------

Co-authored-by: DangerousFreedom <[email protected]>
DangerousFreedom1984 added a commit to DangerousFreedom1984/seraphis_lib that referenced this pull request Jan 19, 2024
make JamtisDestinationV1 serializable 

---------

Co-authored-by: DangerousFreedom <[email protected]>
UkoeHB pushed a commit that referenced this pull request Feb 8, 2024
make JamtisDestinationV1 serializable 

---------

Co-authored-by: DangerousFreedom <[email protected]>
UkoeHB pushed a commit that referenced this pull request Mar 6, 2024
make JamtisDestinationV1 serializable 

---------

Co-authored-by: DangerousFreedom <[email protected]>
UkoeHB pushed a commit that referenced this pull request Aug 2, 2024
make JamtisDestinationV1 serializable 

---------

Co-authored-by: DangerousFreedom <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants