Skip to content

Commit

Permalink
Merge remote-tracking branch 'ledger/main' into update/dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
abenso committed Sep 19, 2024
2 parents 440b131 + 9d40962 commit 5832f06
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 52 deletions.
8 changes: 8 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Checklist
<!-- Put an `x` in each box when you have completed the items. -->
- [ ] App update process has been followed <!-- See comment below -->
- [ ] Target branch is `develop` <!-- unless you have a very good reason -->
- [ ] Application version has been bumped <!-- required if your changes are to be deployed -->

<!-- Make sure you followed the process described in https://developers.ledger.com/docs/embedded-app/maintenance/ before opening your Pull Request.
Don't hesitate to contact us directly on Discord if you have any questions ! https://developers.ledger.com/discord -->
1 change: 1 addition & 0 deletions .github/workflows/guidelines_enforcer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ name: Ensure compliance with Ledger guidelines
#
# More information on the guidelines can be found in the repository:
# LedgerHQ/ledger-app-workflows/

on:
workflow_dispatch:
push:
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Lint and format 💅

on:
workflow_dispatch:
# push:
# pull_request:
# branches:
# - main
# - develop

jobs:
lint:
runs-on: ubuntu-latest
container: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-legacy:latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Add missing deps
run: |
DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y bear sudo
- name: Generate compilation database
run: bear -- make -j BOLOS_SDK="$NANOSP_SDK"
- name: Lint and format 💅
uses: cpp-linter/cpp-linter-action@v2
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file-annotations: true
files-changed-only: false
ignore: "app/build|cmake|deps|fuzz|tests"
step-summary: true
style: file # uses .clang-format
thread-comments: true
tidy-checks: "" # use only .clang-tidy checks
- name: Fail if errors
if: steps.linter.outputs.checks-failed > 0
run: |
echo "Linter or formatter failed!"
exit 1
1 change: 1 addition & 0 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.side_loading

include $(BOLOS_SDK)/Makefile.rules


dep/%.d: %.c Makefile

listvariants:
Expand Down
2 changes: 1 addition & 1 deletion app/Makefile.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ include Makefile.version
# Enable debug output in speculos and other development features
APP_TESTING ?= 0

PRODUCTION_BUILD ?= 0
PRODUCTION_BUILD ?= 1
53 changes: 2 additions & 51 deletions go/avalanche.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,62 +137,13 @@ func (ledger *LedgerAvalanche) GetPubKey(path string, show bool, hrp string, cha

// [publicKeyLen | publicKey | hash | address | errorCode]
publicKeyLen := response[0]
publicKey := append([]byte{}, response[1:publicKeyLen+1]...)
hash := append([]byte{}, response[publicKeyLen+1:publicKeyLen+1+20]...)
publicKey := response[1 : publicKeyLen+1]
hash := response[publicKeyLen+1 : publicKeyLen+1+20]
address := string(response[publicKeyLen+1+20:])

return &ResponseAddr{publicKey, hash, address}, nil
}

// GetExtPubKey returns the extended pubkey
func (ledger *LedgerAvalanche) GetExtPubKey(path string, show bool, hrp string, chainid string) ([]byte, []byte, error) {
if len(hrp) > 83 {
return nil, nil, errors.New("hrp len should be < 83 chars")
}

serializedHRP, err := SerializeHrp(hrp)
if err != nil {
return nil, nil, err
}

serializedPath, err := SerializePath(path)
if err != nil {
return nil, nil, err
}

serializedChainID, err := SerializeChainID(chainid)
if err != nil {
return nil, nil, err
}

p1 := byte(P1_ONLY_RETRIEVE)
if show {
p1 = byte(P1_SHOW_ADDRESS_IN_DEVICE)
}

// Prepare message
header := []byte{CLA, INS_GET_EXTENDED_PUBLIC_KEY, p1, 0, 0}
message := append(header, serializedHRP...)
message = append(message, serializedChainID...)
message = append(message, serializedPath...)
message[4] = byte(len(message) - len(header)) // update length

response, err := ledger.api.Exchange(message)
if err != nil {
return nil, nil, err
}

if len(response) < 32 {
return nil, nil, errors.New("Invalid response")
}

publicKeyLen := response[0]
publicKey := append([]byte{}, response[1:publicKeyLen+1]...)
chainCode := append([]byte{}, response[publicKeyLen+1:]...)

return publicKey, chainCode, nil
}

func (ledger *LedgerAvalanche) Sign(pathPrefix string, signingPaths []string, message []byte, changePaths []string) (*ResponseSign, error) {
paths := signingPaths
if changePaths != nil {
Expand Down

0 comments on commit 5832f06

Please sign in to comment.