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

Installing app on Nano S with newest Firmware #4

Open
fasmat opened this issue May 22, 2023 · 3 comments
Open

Installing app on Nano S with newest Firmware #4

fasmat opened this issue May 22, 2023 · 3 comments

Comments

@fasmat
Copy link
Member

fasmat commented May 22, 2023

On macOS to install the app on Nano S with Firmware 2.1.0 the command in the README.md needs to be changed to:

python3 -m ledgerblue.loadApp --curve ed25519 --appFlags 0x800 --path "44'/540'" --tlv --targetId 0x31100004 --targetVersion="2.1.0" --delete --fileName bin/app.hex --appName "Spacemesh" --appVersion "0.1.0" --dataSize $((0x`cat debug/app.map |grep _envram_data | tr -s ' ' | cut -f2 -d' '|cut -f2 -d'x'` - 0x`cat debug/app.map |grep _nvram_data | tr -s ' ' | cut -f2 -d' '|cut -f2 -d'x'`)) `ICONHEX=\`python3 $BOLOS_SDK/icon3.py --hexbitmaponly icons/nanos_app_spacemesh.gif  2>/dev/null\` ; [ ! -z "$ICONHEX" ] && echo "--icon $ICONHEX"`

The --targetId needs to be 0x31100004 (according to official documentation for Firmware 1.5.x of Nano S), the --appFlags are 0x800 instead of 0xa00, --apiLevel isn't needed and the path to the .gif needs to be nanos_* instead of nanox_*.

@yantao1995
Copy link

@fasmat hello,now can i use this code to sign my transaction on spacemesh?
when i signing , the source code need the message header ,but the spacemesh example code not contains that.

the source code path: app-spacemesh->src->signMessage.c

if (parse_message_header(&parser, header) != 0) {
        // This is not a valid Solana message
        THROW(ApduReplySolanaInvalidMessage);
    }
int parse_message_header(Parser* parser, MessageHeader* header) {
    BAIL_IF(parse_version(parser, header));
    BAIL_IF(parse_pubkeys(parser, &header->pubkeys_header, &header->pubkeys));
    BAIL_IF(parse_blockhash(parser, &header->blockhash));
    BAIL_IF(parse_length(parser, &header->instructions_length));
    return 0;
}

the spacemesh code path: go-spacemesh->genvm->sdk->wallet->tx.go

// Spend creates spend transaction.
func Spend(pk signing.PrivateKey, to types.Address, amount uint64, nonce types.Nonce, opts ...sdk.Opt) []byte {
	options := sdk.Defaults()
	for _, opt := range opts {
		opt(options)
	}

	spawnargs := wallet.SpawnArguments{}
	copy(spawnargs.PublicKey[:], signing.Public(pk))
	principal := core.ComputePrincipal(wallet.TemplateAddress, &spawnargs)

	payload := core.Payload{}
	payload.GasPrice = options.GasPrice
	payload.Nonce = nonce

	args := wallet.SpendArguments{}
	args.Destination = to
	args.Amount = amount

	tx := encode(&sdk.TxVersion, &principal, &sdk.MethodSpend, &payload, &args)
	sig := ed25519.Sign(ed25519.PrivateKey(pk), core.SigningBody(options.GenesisID[:], tx))
	return append(tx, sig...)
}

@fasmat
Copy link
Member Author

fasmat commented Jan 4, 2024

@yantao1995 your comment seems unrelated to this issue, could you please open a new one?

cc @lrettig

@yantao1995
Copy link

ok.thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants