Hey!
I’ve included a small code snippet in this libra proposal: https://github.com/libra/lip/blob/master/lips/lip-1.mdx#recipient-signature. You can test it with the Libra Python SDK (pip3 install pylibra-beta
).
An example here:
metadata: Metadata = Metadata__TravelRuleMetadata(
TravelRuleMetadata__TravelRuleMetadataVersion0(
TravelRuleMetadataV0(
off_chain_reference_id="reference_id",
)
)
)
dual_attest_msg_bytes: bytearray = bytearray()
dual_attest_msg_bytes.extend(lcs.serialize(metadata, Metadata)) # Travel Rule metadata
dual_attest_msg_bytes.extend(lcs.serialize(bytes.fromhex("793251de1a61e9b4d1a17d13aa015e45"), bytes)) # Sender Address
dual_attest_msg_bytes.extend(lcs.serialize(st.uint64(1000000), st.uint64)) # Amount
dual_attest_msg_bytes.extend(lcs.serialize(b"@@$$LIBRA_ATTEST$$@@", bytes)) # Libra Domain Separator
dual_attest_msg: TransactionArgument__U8Vector = TransactionArgument__U8Vector(bytes(dual_attest_msg_bytes))
dual_attest_msg_lcs = lcs.serialize(dual_attest_msg, TransactionArgument__U8Vector)
print("Result:", dual_attest_msg_lcs)
Result: b'>\x02\x00\x01\x0creference_id\x10y2Q\xde\x1aa\xe9\xb4\xd1\xa1}\x13\xaa\x01^E@B\x0f\x00\x00\x00\x00\x00\x14@@$$LIBRA_ATTEST$$@@'
or in hex: b'3e0200010c7265666572656e63655f696410793251de1a61e9b4d1a17d13aa015e4540420f000000000014404024244c494252415f41545445535424244040'
Note: The ed25519 compliance key signs directly the bytes, not a hash of this dual attestation signable.