Skip to content

Commit

Permalink
REF
Browse files Browse the repository at this point in the history
  • Loading branch information
Overtorment committed Apr 10, 2023
1 parent 7288682 commit c147d5b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
16 changes: 10 additions & 6 deletions blue_modules/noble_ecc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import createHash from 'create-hash';
import { createHmac } from 'crypto';
import * as necc from '@noble/secp256k1';
import { TinySecp256k1Interface } from 'ecpair/src/ecpair';
import { TinySecp256k1Interface as TinySecp256k1Interface2 } from 'bip32/types/bip32';
import { TinySecp256k1Interface as TinySecp256k1InterfaceBIP32 } from 'bip32/types/bip32';

export interface TinySecp256k1InterfaceExtended {
pointMultiply(p: Uint8Array, tweak: Uint8Array, compressed?: boolean): Uint8Array | null;

pointAdd(pA: Uint8Array, pB: Uint8Array, compressed?: boolean): Uint8Array | null;
}

necc.utils.sha256Sync = (...messages: Uint8Array[]): Uint8Array => {
const sha256 = createHash('sha256');
Expand Down Expand Up @@ -54,7 +60,7 @@ function isPoint(p: Uint8Array, xOnly: boolean): boolean {
}
}

const ecc: TinySecp256k1Interface & TinySecp256k1Interface2 = {
const ecc: TinySecp256k1InterfaceExtended & TinySecp256k1Interface & TinySecp256k1InterfaceBIP32 = {
isPoint: (p: Uint8Array): boolean => isPoint(p, false),
isPrivate: (d: Uint8Array): boolean => {
/* if (
Expand Down Expand Up @@ -84,17 +90,15 @@ const ecc: TinySecp256k1Interface & TinySecp256k1Interface2 = {
return necc.Point.fromHex(p).toRawBytes(defaultTrue(compressed));
},

/*
pointMultiply: (a: Uint8Array, tweak: Uint8Array, compressed?: boolean): Uint8Array | null =>
throwToNull(() => necc.utils.pointMultiply(a, tweak, defaultTrue(compressed))),
*/

/* pointAdd: (a: Uint8Array, b: Uint8Array, compressed?: boolean): Uint8Array | null =>
pointAdd: (a: Uint8Array, b: Uint8Array, compressed?: boolean): Uint8Array | null =>
throwToNull(() => {
const A = necc.Point.fromHex(a);
const B = necc.Point.fromHex(b);
return A.add(B).toRawBytes(defaultTrue(compressed));
}), */
}),

pointAddScalar: (p: Uint8Array, tweak: Uint8Array, compressed?: boolean): Uint8Array | null =>
throwToNull(() => necc.utils.pointAddScalar(p, tweak, defaultTrue(compressed))),
Expand Down
2 changes: 1 addition & 1 deletion class/wallets/abstract-hd-electrum-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {

// final check if PC is even valid (could've been constructed by a buggy code, and our code would crash with that):
try {
BIP47Factory(ecc).fromPaymentCode(paymentCode);
bip47.fromPaymentCode(paymentCode);
} catch (_) {
continue;
}
Expand Down
4 changes: 3 additions & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"crypto-js": "4.1.1",
"dayjs": "1.11.7",
"detox": "20.6.0",
"ecpair": "2.0.1",
"ecpair": "^2.0.1",
"ecurve": "1.0.6",
"electrum-client": "https://github.com/BlueWallet/rn-electrum-client#76c0ea35e1a50c47f3a7f818d529ebd100161496",
"electrum-mnemonic": "2.0.0",
Expand Down

0 comments on commit c147d5b

Please sign in to comment.