Skip to content

Commit

Permalink
Merge pull request #65 from Zondax/dev
Browse files Browse the repository at this point in the history
New Release
  • Loading branch information
emmanuelm41 authored Sep 28, 2024
2 parents a77c08b + 1060c0f commit 0bbcb99
Show file tree
Hide file tree
Showing 16 changed files with 109 additions and 125 deletions.
27 changes: 8 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,12 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y curl protobuf-compiler build-essential git wget unzip python3 python3-pip \
libssl-dev libffi-dev libreadline-dev zlib1g-dev libbz2-dev libsqlite3-dev libncurses5-dev \
libgdbm-dev libnss3-dev liblzma-dev libxml2-dev libxmlsec1-dev libffi-dev libyaml-dev \
clang gcc-arm-none-eabi gcc-multilib llvm-dev llvm jq
sudo apt-get install -y curl build-essential git wget unzip
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2023-11-10
components: rust-src
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Checkout
uses: actions/checkout@v4
with:
Expand All @@ -39,19 +33,14 @@ jobs:
with:
node-version: 18
- name: Install yarn
run: |
npm install -g yarn
- name: Install ledger deps
run: |
cargo install cargo-ledger
cargo ledger setup
pip install ledgerwallet
run: npm install -g yarn
- name: Run rust tests
run: make rust_tests
- name: Build app
run: |
export PATH=/home/runner/.local/bin:$PATH
sudo rm -rf app/target
make all
- name: Run rust tests
run: make rust_tests
- name: Install zemu deps
run: make zemu_install
- name: Run tests
Expand All @@ -67,7 +56,7 @@ jobs:
sudo apt-get install -y curl protobuf-compiler build-essential git wget unzip python3 python3-pip \
libssl-dev libffi-dev libreadline-dev zlib1g-dev libbz2-dev libsqlite3-dev libncurses5-dev \
libgdbm-dev libnss3-dev liblzma-dev libxml2-dev libxmlsec1-dev libffi-dev libyaml-dev \
clang gcc-arm-none-eabi gcc-multilib llvm-dev llvm jq
clang gcc-arm-none-eabi gcc-multilib llvm-dev llvm jq libc6-dev
- name: Install rust
uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -129,7 +118,7 @@ jobs:
sudo apt-get install -y curl protobuf-compiler build-essential git wget unzip python3 python3-pip \
libssl-dev libffi-dev libreadline-dev zlib1g-dev libbz2-dev libsqlite3-dev libncurses5-dev \
libgdbm-dev libnss3-dev liblzma-dev libxml2-dev libxmlsec1-dev libffi-dev libyaml-dev \
clang gcc-arm-none-eabi gcc-multilib llvm-dev llvm jq
clang gcc-arm-none-eabi gcc-multilib llvm-dev llvm jq libc6-dev
- name: Install rust
uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -191,7 +180,7 @@ jobs:
sudo apt-get install -y curl protobuf-compiler build-essential git wget unzip python3 python3-pip \
libssl-dev libffi-dev libreadline-dev zlib1g-dev libbz2-dev libsqlite3-dev libncurses5-dev \
libgdbm-dev libnss3-dev liblzma-dev libxml2-dev libxmlsec1-dev libffi-dev libyaml-dev \
clang gcc-arm-none-eabi gcc-multilib llvm-dev llvm jq
clang gcc-arm-none-eabi gcc-multilib llvm-dev llvm jq libc6-dev
- name: Install rust
uses: actions-rs/toolchain@v1
with:
Expand Down
5 changes: 1 addition & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
[submodule "js"]
path = js
url = https://github.com/Zondax/ledger-ironfish-js
[submodule "ironfish"]
path = ironfish
url = https://github.com/iron-fish/ironfish
[submodule "deps/ledger-zxlib"]
path = deps/ledger-zxlib
url = https://github.com/Zondax/ledger-zxlib
[submodule "deps/ledger-secure-sdk"]
path = deps/ledger-secure-sdk
url = https://github.com/LedgerHQ/ledger-secure-sdk.git
url = https://github.com/LedgerHQ/ledger-secure-sdk.git
15 changes: 0 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,6 @@ default:
COIN=$(COIN) $(MAKE) -C app $@
endif



zemu_install_ironfish_link:
cd ironfish && yarn unlink || true
cd $(TESTS_ZEMU_DIR) && yarn unlink @ironfish/rust-nodejs || true
# Now build and link
cd ironfish && yarn install && cd ironfish-rust-nodejs && yarn link || true
cd $(TESTS_ZEMU_DIR) && yarn link @ironfish/rust-nodejs || true

# Redefine zemu_install, as we still need to compile the ironfish package locally
.PHONY: zemu_install
zemu_install: zemu_install_ironfish_link zemu_install_js_link
# and now install everything
cd $(TESTS_ZEMU_DIR) && yarn install

# Copy files quickly from a source to a folder with a regular expresions
# In some cases, when something change in the screens for some command, it changes for each participant.
# This makes it hard and tedious to update each participant snapshots (one per test run).
Expand Down
12 changes: 6 additions & 6 deletions app/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test = false
path = "bin-app/app.rs"

[dependencies]
ledger_device_sdk = { git = "https://github.com/Zondax/ledger-device-rust-sdk", rev = "04d487441b806506bf0bb16a87e2aa378d956c2b", optional = true }
ledger_device_sdk = { git = "https://github.com/Zondax/ledger-device-rust-sdk", rev = "9408c1ffc278a363e1903b4cc0b765a31c4eeace", optional = true }
# ledger_device_sdk = { version="1.14.0" , optional = true}
# ledger_device_sdk = { path="../../ledger-device-rust-sdk/ledger_device_sdk" , optional = true}
include_gif = "1.2.0"
Expand Down
8 changes: 4 additions & 4 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,23 @@ include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.side_loading

.PHONY: buildX
buildX:
APPVERSION_STR=$(APPVERSION_STR) PRODUCTION_BUILD=$(PRODUCTION_BUILD) RUSTFLAGS="-C opt-level=s" cargo +nightly-2023-11-10 ledger build nanox
BOLOS_SDK= APPVERSION_STR=$(APPVERSION_STR) PRODUCTION_BUILD=$(PRODUCTION_BUILD) RUSTFLAGS="-C opt-level=s" cargo +nightly-2023-11-10 ledger build nanox
FOLDER=nanox make post-build

.PHONY: buildS2
buildS2:
APPVERSION_STR=$(APPVERSION_STR) PRODUCTION_BUILD=$(PRODUCTION_BUILD) RUSTFLAGS="-C opt-level=s" cargo +nightly-2023-11-10 ledger build nanosplus
BOLOS_SDK= APPVERSION_STR=$(APPVERSION_STR) PRODUCTION_BUILD=$(PRODUCTION_BUILD) RUSTFLAGS="-C opt-level=s" cargo +nightly-2023-11-10 ledger build nanosplus
FOLDER=nanosplus make post-build

.PHONY: buildST
buildST:
APPVERSION_STR=$(APPVERSION_STR) PRODUCTION_BUILD=$(PRODUCTION_BUILD) RUSTFLAGS="-C opt-level=z" cargo +nightly-2023-11-10 ledger build stax
BOLOS_SDK= APPVERSION_STR=$(APPVERSION_STR) PRODUCTION_BUILD=$(PRODUCTION_BUILD) RUSTFLAGS="-C opt-level=z" cargo +nightly-2023-11-10 ledger build stax
FOLDER=stax make post-build


.PHONY: buildFL
buildFL:
APPVERSION_STR=$(APPVERSION_STR) PRODUCTION_BUILD=$(PRODUCTION_BUILD) RUSTFLAGS="-C opt-level=z" cargo +nightly-2023-11-10 ledger build flex
BOLOS_SDK= APPVERSION_STR=$(APPVERSION_STR) PRODUCTION_BUILD=$(PRODUCTION_BUILD) RUSTFLAGS="-C opt-level=z" cargo +nightly-2023-11-10 ledger build flex
FOLDER=flex make post-build


Expand Down
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ APPVERSION_M=0
# This is the minor version
APPVERSION_N=5
# This is the patch version
APPVERSION_P=0
APPVERSION_P=1
39 changes: 4 additions & 35 deletions app/src/app_ui/run_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,13 @@ use ledger_device_sdk::ui::{
};

#[cfg(any(target_os = "stax", target_os = "flex"))]
use ledger_device_sdk::nbgl::{Field, NbglChoice, NbglGlyph, NbglReview, TransactionType};
use ledger_device_sdk::nbgl::{Field, NbglGlyph, NbglReview, TransactionType};

use crate::bolos::app_canary;
use crate::utils::int_to_str;
#[cfg(any(target_os = "stax", target_os = "flex"))]
use include_gif::include_gif;

#[inline(never)]
pub fn ui_run_action<'a>(review_message: &'a [&'a str]) -> Result<bool, AppSW> {
#[cfg(not(any(target_os = "stax", target_os = "flex")))]
{
let fields: [Field; 0] = [];

let my_review = MultiFieldReview::new(
&fields,
review_message,
Some(&EYE),
"Approve",
Some(&VALIDATE_14),
"Reject",
Some(&CROSSMARK),
);

Ok(my_review.show())
}

#[cfg(any(target_os = "stax", target_os = "flex"))]
{
#[cfg(target_os = "stax")]
const FERRIS: NbglGlyph = NbglGlyph::from_include(include_gif!("stax_icon.gif", NBGL));
#[cfg(target_os = "flex")]
const FERRIS: NbglGlyph = NbglGlyph::from_include(include_gif!("flex_icon.gif", NBGL));

Ok(NbglChoice::new()
.glyph(&FERRIS)
.show(review_message[0], "", "Approve", "Reject"))
}
}

#[inline(never)]
pub fn ui_review_transaction<'a>(
transaction: &'a Transaction<'a>,
Expand Down Expand Up @@ -124,7 +92,7 @@ pub fn ui_review_transaction<'a>(
.titles("Review", "Transaction", "Approve Transaction?")
.glyph(&FERRIS);

Ok(review.show(&fields, false))
Ok(review.show(&fields))
}
}

Expand Down Expand Up @@ -425,9 +393,10 @@ pub fn ui_review<'a>(

let mut review = NbglReview::new()
.tx_type(TransactionType::Operation)
.light()
.titles(title, _subtitle, _finish_title)
.glyph(&ICON);

Ok(review.show(&fields, true))
Ok(review.show(&fields))
}
}
2 changes: 1 addition & 1 deletion deps/ledger-zxlib
Submodule ledger-zxlib updated 1 files
+17 −16 dockerized_build.mk
1 change: 0 additions & 1 deletion ironfish
Submodule ironfish deleted from 5c87a0
2 changes: 1 addition & 1 deletion js
Submodule js updated 1 files
+3 −4 src/index.ts
4 changes: 2 additions & 2 deletions tests_zemu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"upgrade": "bunx npm-check-updates -i"
},
"dependencies": {
"@ironfish/rust-nodejs": "../ironfish/ironfish-rust-nodejs",
"@ironfish/sdk": "^2.5.0",
"@ironfish/rust-nodejs": "^2.7.0",
"@ironfish/sdk": "^2.7.0",
"@zondax/ledger-ironfish": "../js",
"@zondax/zemu": "^0.50.2"
},
Expand Down
2 changes: 1 addition & 1 deletion tests_zemu/tests/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('Basic', function () {
expect(resp.testMode).toBe(false)
expect(resp.major).toBe(0)
expect(resp.minor).toBe(5)
expect(resp.patch).toBe(0)
expect(resp.patch).toBe(1)
} finally {
await sim.close()
}
Expand Down
46 changes: 23 additions & 23 deletions tests_zemu/tests/dkg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { isValidPublicAddress, multisig, UnsignedTransaction, verifyTransactions
import { Transaction } from '@ironfish/sdk'
import { buildTx, minimizeRound3Inputs } from './utils'
import { TModel } from '@zondax/zemu/dist/types'
import aggregateRawSignatureShares = multisig.aggregateRawSignatureShares
import aggregateSignatureShares = multisig.aggregateSignatureShares

jest.setTimeout(4500000)

Expand Down Expand Up @@ -383,10 +383,14 @@ describe.each(models)('DKG', function (m) {
return result
})

commitments.push(result.commitments.toString('hex'))
commitments.push(
multisig.SigningCommitment.fromRaw(identities[i], result.commitments, unsignedTx.hash(), identities)
.serialize()
.toString('hex'),
)
}

const signingPackageHex = unsignedTx.signingPackageFromRaw(identities, commitments)
const signingPackageHex = unsignedTx.signingPackage(commitments)
const signingPackage = new multisig.SigningPackage(Buffer.from(signingPackageHex, 'hex'))

for (let i = 0; i < participants; i++) {
Expand All @@ -402,16 +406,12 @@ describe.each(models)('DKG', function (m) {
return result
})

signatures.push(result.signature.toString('hex'))
signatures.push(
multisig.SignatureShare.fromFrost(result.signature, Buffer.from(identities[i], 'hex')).serialize().toString('hex'),
)
}

let signedTxRaw = aggregateRawSignatureShares(
identities,
publicPackages[0],
unsignedTxRaw.toString('hex'),
signingPackage.frostSigningPackage().toString('hex'),
signatures,
)
let signedTxRaw = aggregateSignatureShares(publicPackages[0], signingPackageHex, signatures)
expect(verifyTransactions([signedTxRaw])).toBeTruthy()

const signedTx = new Transaction(signedTxRaw)
Expand Down Expand Up @@ -568,10 +568,10 @@ describe.each(models)('DKG', function (m) {
return result.publicAddress.toString('hex')
})

let publicPackages = await runMethod(m, globalSims, 0, async (sim: Zemu, app: IronfishApp) => {
let publicPackage = await runMethod(m, globalSims, 0, async (sim: Zemu, app: IronfishApp) => {
let result = await app.dkgGetPublicPackage()

return result.publicPackage
return result.publicPackage.toString('hex')
})

for (let i = 0; i < participants; i++) {
Expand Down Expand Up @@ -615,10 +615,14 @@ describe.each(models)('DKG', function (m) {
return result
})

commitments.push(result.commitments.toString('hex'))
commitments.push(
multisig.SigningCommitment.fromRaw(identities[i], result.commitments, unsignedTx.hash(), identities)
.serialize()
.toString('hex'),
)
}

const signingPackageHex = unsignedTx.signingPackageFromRaw(identities, commitments)
const signingPackageHex = unsignedTx.signingPackage(commitments)
const signingPackage = new multisig.SigningPackage(Buffer.from(signingPackageHex, 'hex'))

for (let i = 0; i < participants; i++) {
Expand All @@ -634,7 +638,9 @@ describe.each(models)('DKG', function (m) {
return result
})

signatures.push(result.signature.toString('hex'))
signatures.push(
multisig.SignatureShare.fromFrost(result.signature, Buffer.from(identities[i], 'hex')).serialize().toString('hex'),
)
}

// Attempt to sign again. It should fail as the tx hash is cleaned
Expand All @@ -650,13 +656,7 @@ describe.each(models)('DKG', function (m) {
).rejects.toThrow()
}

let signedTxRaw = aggregateRawSignatureShares(
identities,
publicPackages.toString('hex'),
unsignedTxRaw.toString('hex'),
signingPackage.frostSigningPackage().toString('hex'),
signatures,
)
let signedTxRaw = aggregateSignatureShares(publicPackage, signingPackageHex, signatures)
expect(verifyTransactions([signedTxRaw])).toBeTruthy()

const signedTx = new Transaction(signedTxRaw)
Expand Down
Loading

0 comments on commit 0bbcb99

Please sign in to comment.