UkoeHB / monero

Monero: the secure, private, untraceable cryptocurrency
https://getmonero.org
Other
7 stars 4 forks source link

free function serialization DSL #32

Closed jeffro256 closed 8 months ago

jeffro256 commented 8 months ago

Useful for PR #25

jeffro256 commented 8 months ago

Example usage (replacing serialization_demo_utils):

BLOB_SERIALIZER(sp::jamtis::address_index_t);
BLOB_SERIALIZER(sp::jamtis::address_tag_t);
BLOB_SERIALIZER(sp::jamtis::encrypted_address_tag_t);
BLOB_SERIALIZER(sp::jamtis::encoded_amount_t);

BEGIN_SERIALIZE_OBJECT_FN(sp::SpCoinbaseEnoteCore)
    FIELD_F(onetime_address)
    VARINT_FIELD_F(amount)
END_SERIALIZE()

BEGIN_SERIALIZE_OBJECT_FN(sp::SpEnoteCore)
    FIELD_F(onetime_address)
    FIELD_F(amount_commitment)
END_SERIALIZE()

BEGIN_SERIALIZE_OBJECT_FN(sp::SpEnoteImageCore)
    FIELD_F(masked_address)
    FIELD_F(masked_commitment)
    FIELD_F(key_image)
END_SERIALIZE()

BEGIN_SERIALIZE_OBJECT_FN(sp::SpEnoteImageCore)
    FIELD_F(masked_address)
    FIELD_F(masked_commitment)
    FIELD_F(key_image)
END_SERIALIZE()

BEGIN_SERIALIZE_OBJECT_FN(sp::BulletproofPlus2)
    FIELD_F(A)
    FIELD_F(A1)
    FIELD_F(B)
    FIELD_F(r1)
    FIELD_F(s1)
    FIELD_F(d1)
    FIELD_F(L)
    FIELD_F(R)
END_SERIALIZE()

... continue pattern here 

We can serialize directly from seraphis types non-intrusively and don't need all the extra types and boilerplate eventually

DangerousFreedom1984 commented 8 months ago

That should make things much easier. Thanks.

UkoeHB commented 8 months ago

You should parallel-PR this to the monero repo.

jeffro256 commented 8 months ago

Fixed comments, thanks @UkoeHB