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

Zip32 update #5

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,26 @@
},
"devDependencies": {
"@types/ledgerhq__hw-transport": "^4.21.8",
"@typescript-eslint/eslint-plugin": "^8.4.0",
"@typescript-eslint/parser": "^8.4.0",
"@typescript-eslint/eslint-plugin": "^8.18.1",
"@typescript-eslint/parser": "^8.18.1",
"bip32": "^5.0.0-rc.0",
"bip39": "^3.1.0",
"core-js": "^3.38.1",
"core-js": "^3.39.0",
"crypto-js": "4.2.0",
"eslint": "^9.5.0",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^17.9.0",
"eslint-plugin-promise": "^6.2.0",
"eslint-plugin-tsdoc": "^0.3.0",
"eslint-plugin-n": "^17.15.1",
"eslint-plugin-promise": "^7.2.1",
"eslint-plugin-tsdoc": "^0.4.0",
"eslint-plugin-unused-imports": "^4.0.0",
"sort-package-json": "^2.10.0",
"jest": "^29.7.0",
"leb128": "^0.0.5",
"prettier": "^3.3.3",
"secp256k1": "^5.0.0",
"typescript": "^5.5.4"
"prettier": "^3.4.2",
"secp256k1": "^5.0.1",
"sort-package-json": "^2.12.0",
"typescript": "^5.7.2"
},
"moduleDirectories": [
"node_modules",
Expand Down
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export const INS = {
}
export const SALT_LEN = 8
export const HASH_LEN = 32
export const TAG_LEN = 4
export const PK_LEN_PLUS_TAG = 33
export const SIG_LEN_PLUS_TAG = 65
export const KEY_LENGTH = 32
export const XFVK_LENGTH = 1 + 2 * TAG_LEN + 5 * KEY_LENGTH
export const RANDOMNESS_LENGTH = 32
export const PAYMENT_ADDR_LENGTH = 43
21 changes: 4 additions & 17 deletions src/processResponses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
******************************************************************************* */

import { errorCodeToString } from './common'
import { KEY_LENGTH, PK_LEN_PLUS_TAG, RANDOMNESS_LENGTH, SALT_LEN, SIG_LEN_PLUS_TAG } from './config'
import { KEY_LENGTH, PAYMENT_ADDR_LENGTH, PK_LEN_PLUS_TAG, RANDOMNESS_LENGTH, SALT_LEN, SIG_LEN_PLUS_TAG, XFVK_LENGTH } from './config'
import {
ISignature,
KeyResponse,
Expand Down Expand Up @@ -103,7 +103,7 @@ export function processGetKeysResponse(response: Buffer, keyType: NamadaKeys): K

switch (keyType) {
case NamadaKeys.PublicAddress: {
const publicAddress = Buffer.from(response.subarray(0, KEY_LENGTH))
const publicAddress = Buffer.from(response.subarray(0, PAYMENT_ADDR_LENGTH))
requestedKey = {
...requestedKey,
publicAddress,
Expand All @@ -112,24 +112,11 @@ export function processGetKeysResponse(response: Buffer, keyType: NamadaKeys): K
}

case NamadaKeys.ViewKey: {
const viewKey = Buffer.from(response.subarray(0, 2 * KEY_LENGTH))
const xfvk = Buffer.from(response.subarray(0, XFVK_LENGTH))
response = response.subarray(2 * KEY_LENGTH)

const ovk = Buffer.from(response.subarray(0, KEY_LENGTH))
response = response.subarray(KEY_LENGTH)

const ivk = Buffer.from(response.subarray(0, KEY_LENGTH))
response = response.subarray(KEY_LENGTH)

const dk = Buffer.from(response.subarray(0, KEY_LENGTH))
response = response.subarray(KEY_LENGTH)

requestedKey = {
...requestedKey,
viewKey,
ovk,
ivk,
dk,
xfvk,
}
break
}
Expand Down
5 changes: 1 addition & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ export interface ResponseAddress extends ResponseBase {
}

export interface ResponseViewKey extends ResponseBase {
viewKey?: Buffer
ivk?: Buffer
ovk?: Buffer
dk?: Buffer
xfvk?: Buffer
}

export interface ResponseProofGenKey extends ResponseBase {
Expand Down
Loading
Loading