2

I'm trying to deserialize the ED25519 program, but the struct I derived does not tally with the bytes in the instruction data (buffer) https://github.com/solana-labs/solana/blob/master/sdk/src/ed25519_instruction.rs Has anyone deserialized the ix data before? or is there any bytes I'm missing?

pub struct ED25519Data {
    padding: u8,
    signature_offset: u16,             // offset to ed25519 signature of 64 bytes
    signature_instruction_index: u16,  // instruction index to find signature
    public_key_offset: u16,            // offset to public key of 32 bytes
    public_key_instruction_index: u16, // instruction index to find public key
    message_data_offset: u16,          // offset to start of message data
    message_data_size: u16,            // size of message data
    message_instruction_index: u16,   // index of instruction data to get message data
    ix_data: ? 
}   

ix_data isn't a fixed parameter, it varies.. Thank you!

3
  • Maybe you are missing the first byte, In solana native programs the 1st byte represents enum of the request try doing from the second byte Mar 7, 2023 at 6:04
  • @AbhishekFaliya i did ser! Still doesnt seem to tally
    – Sewy
    Mar 7, 2023 at 6:09
  • How exactly are you reading the data ? Are you reading from the account? or inspecting ix_data that you are sending ? Mar 7, 2023 at 11:44

1 Answer 1

0

There are a couple of missing bits. If you follow along the code, you'll see how the instruction data vector is built up, creating this struct:

pub struct ED25519Data {
    num_signatures: u8,                // number of signatures to verify
    padding: u8,                       // padding to make the struct 2-aligned
    signature_offset: u16,             // offset to ed25519 signature of 64 bytes
    signature_instruction_index: u16,  // instruction index to find signature
    public_key_offset: u16,            // offset to public key of 32 bytes
    public_key_instruction_index: u16, // instruction index to find public key
    message_data_offset: u16,          // offset to start of message data
    message_data_size: u16,            // size of message data
    message_instruction_index: u16,   // index of instruction data to get message data
    signing_pubkey: Pubkey,           // signing pubkey, 32 bytes
    signature: Signature,             // signature for the message produced by the signing pubkey, 64 bytes
    message: [u8],                    // the bytes that were signed by signing_pubkey, could be any length (less than max transaction size)
}   

Note that this isn't valid Rust because of the message field, which is just raw bytes that are signed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.