Skip to content

How to Convert QuadExtField<Fp12ParamsWrapper<Fq12Parameters>> Back to Original Hex? #901

@vinay10949

Description

@vinay10949

I’m working on a codebase and am encountering an issue when trying to convert a decrypted message of type QuadExtField<Fp12ParamsWrapper<Fq12Parameters>> back to its original hexadecimal string format.

Here's a snippet of the code:

let my_str = "00000000000000008a7f5d0f15ef296b1d80813c63241ff1952a1d3d4fbd0cb8008242f1000e3bb7";

// Serialize the input hexadecimal string
let mut bytes: Vec<u8> = hex::decode(my_str).unwrap();
let m = Fq12::from_random_bytes(&data).unwrap();

// Encrypt the message
let ct = enc(&pk, 0, m);

// Decrypt the ciphertext
let decrypted_m = dec(&mut sk, &ct); // Type: QuadExtField<Fp12ParamsWrapper<Fq12Parameters>>

When I try to convert decrypted_m back to bytes and then to a hex string, the output is incorrect. Instead of getting the original my_str, I end up with a padded and incorrect result, such as:

"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f5d0f..."

Also details

ark-ff = "0.3"
ark-ec = "0.3"
ark-bls12-381 = "0.3"
ark-std = "0.3"
rand = "0.8.5"
bls12_381 = "0.8.0"
hex-literal = "=0.4.1"
sha2 = "0.10.8"
hex = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
ark-serialize = "0.3"

Question:

  • How can I correctly convert QuadExtField<Fp12ParamsWrapper<Fq12Parameters>> back to the original hexadecimal string (my_str)?
  • Is there a specific deserialization method or field extraction process I need to follow for this type?

Additional Context:

  • I’m using Fq12 for cryptographic operations.
  • The encryption and decryption steps work as expected, but the deserialization back to the original hex string is not producing the correct output.
  • Any guidance or references to examples would be greatly appreciated!

Thank You:

Thanks in advance for your help! 😊

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions