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

Verify that ledger nano can still clear sign with new transaction data #3841

Closed
Thoralf-M opened this issue Oct 31, 2024 · 1 comment
Closed
Assignees
Labels
dev-tools Issues related to the Developer Tools Team

Comments

@Thoralf-M
Copy link
Member

After all things in #2092 are done we should create new transaction data for signing and verify that nothing broke the ledger nano implementation
This test can be used for it, just needs to place the tx data here

'0000000000020008e803000000000000002021c22f952c8742b3156dfca5fc8278bd3ba7b209c81e26c4f44a9944259b03b50202000101000001010200000101006fb21feead027da4873295affd6c4f3618fe176fa2fbf3e7b5ef1d9463b31e2101cad8ac9d85be1fcb1ec3f5870a50004549f4f892856b70499ed1654201c4399984470b000000000020ec2f226e6647a523608dc52ccb9976720c51d60ebfeadc524ee870cdfd1f6b8c6fb21feead027da4873295affd6c4f3618fe176fa2fbf3e7b5ef1d9463b31e21e803000000000000404b4c000000000000',

Alternatively, one could create the new tx with the TS library, that might be more future proof

@Thoralf-M Thoralf-M added the dev-tools Issues related to the Developer Tools Team label Oct 31, 2024
@Thoralf-M Thoralf-M self-assigned this Nov 6, 2024
@Thoralf-M
Copy link
Member Author

I used Rust to generate the new singing data in case something wasn't updated on the JS side yet

#[path = "../utils.rs"]
mod utils;

use fastcrypto::encoding::{Encoding, Hex};
use iota_sdk::types::{
    programmable_transaction_builder::ProgrammableTransactionBuilder,
    transaction::{Argument, Command, TransactionData},
};
use shared_crypto::intent::{Intent, IntentMessage};
use utils::setup_for_write;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    let (client, sender, recipient) = setup_for_write().await?;

    let coins = client
        .coin_read_api()
        .get_coins(sender, None, None, None)
        .await?;
    let coin = coins.data.into_iter().next().unwrap();

    let mut ptb = ProgrammableTransactionBuilder::new();

    let split_coin_amount = ptb.pure(1000u64)?; // note that we need to specify the u64 type
    ptb.command(Command::SplitCoins(Argument::GasCoin, vec![
        split_coin_amount,
    ]));

    let argument_address = ptb.pure(recipient)?;
    ptb.command(Command::TransferObjects(
        vec![Argument::Result(0)],
        argument_address,
    ));
    let transaction = ptb.finish();

    let gas_budget = 5_000_000;
    let gas_price = client.read_api().get_reference_gas_price().await?;

    let tx_data = TransactionData::new_programmable(
        sender,
        vec![coin.object_ref()],
        transaction,
        gas_budget,
        gas_price,
    );

    let intent_message = IntentMessage::new(Intent::iota_transaction(), &tx_data);
    println!(
        "Hex encoded tx intent message: {}",
        Hex::encode(bcs::to_bytes(&intent_message)?)
    );

    Ok(())
}

with the new data we also get a new signature, but it can be parsed fine by the ledger app, so all good

        ledgerClient
            .signTransaction(
                `m/44'/4218'/0'/0'/0'`,
                '0000000000020008e8030000000000000020f1c7bd1835b93393fc3548b3ba398c23c75d0aa1ea80e0677662278ea85ba394020200010100000101020000010100111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b21501773a8169da3463ded8bf3b0a487cdbcce189967bb5668a6764d2502afa12d595690000000000000020d85230ad84b003c2131a9d2afcf79291f5e4d13fe2ee975f9c138dbb4f18e422111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215e803000000000000404b4c000000000000',
            )
            .then(({ signature }) => {
                expect(Buffer.from(signature).toString('hex')).toBe(
                    '3c81beaf0f99a580f45a16cf23675594855cffdeac8d058f9915070d3e9410769a4c7f6b332d362486d0277962a2f8fda78de3142a48efb98ac209af74a83602',
                );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev-tools Issues related to the Developer Tools Team
Projects
None yet
Development

No branches or pull requests

1 participant