Skip to content

Commit

Permalink
Merge pull request #65 from nash-io/ts/add-arbitrum
Browse files Browse the repository at this point in the history
Ts/add arbitrum
  • Loading branch information
localhuman authored May 22, 2023
2 parents 825d51b + 7277cd3 commit 0f827a8
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [4.10.3](https://github.com/nash-io/nash-protocol/compare/v4.10.1...v4.10.3) (2023-05-22)

### [4.10.1](https://github.com/nash-io/nash-protocol/compare/v4.9.9...v4.10.1) (2023-05-19)

### [4.9.9](https://github.com/nash-io/nash-protocol/compare/v4.9.7...v4.9.9) (2023-02-21)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neon-exchange/nash-protocol",
"version": "4.10.1",
"version": "4.10.3",
"description": "TypeScript implementation of Nash crypto routines",
"main": "build/main/index.js",
"typings": "build/main/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/signatureVectors.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@
"timestamp": 1565362799120,
"signature": "30440220083a73aaaa2b69476c74b64e0f1a1bdc1f6e5d311472729712eba8b5f3343a0a02204dcd5a5aac2693865b140c041cf85d6bd079c9a4803fe83caa218bb09d13d2c2",
"raw": {
"polygon": "03FA39FDDDE46CEA3060B91F80ABED8672F77C5BEA000100000000121278900052E62CFA39FDDDE46CEA3060B91F80ABED8672F77C5BEA"
"polygon": "03FA39FDDDE46CEA3060B91F80ABED8672F77C5BEA000300000000121278900052E62CFA39FDDDE46CEA3060B91F80ABED8672F77C5BEA"
},
"blockchainSignatures": {
"polygon": "aea25dfbd61a2e0013e06f728d49f9bda50a135db0e2df1bdaa8101e0bc5d698f276adafdfed4d743291a8d0b97003e531c642fbdab5a88995162752aae8c06301"
"polygon": "e0b4e31781887a3639f24a0dee44356118f9ccc65158e7e06ef90581c7833be620ac6c6ff8906d3d0f87563c442944140b0da5ffb60d2cbfc8017a58d969bfc401"
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/generateWallet/generateWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export function deriveIndex(extendedKey: bip32.BIP32Interface, index: number): b

export const coinTypeFromString = (s: string): CoinType => {
const m: Record<string, CoinType> = {
arbitrum: CoinType.ABRITRUM,
avaxc: CoinType.AVAXC,
bch: CoinType.BCH,
btc: CoinType.BTC,
Expand All @@ -107,8 +108,7 @@ export const coinTypeFromString = (s: string): CoinType => {
ltc: CoinType.LTC,
neo: CoinType.NEO,
neo3: CoinType.NEO3,
polygon: CoinType.POLYGON,
arbitrum: CoinType.ABRITRUM
polygon: CoinType.POLYGON
}

if (!(s in m)) {
Expand Down
20 changes: 20 additions & 0 deletions src/mpc/generateAPIKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,21 @@ export async function generateAPIKeys(params: GenerateApiKeysParams): Promise<AP
params.net,
Blockchain.NEO3
)
const arbitrumWallet = generateWallet(
masterSeed,
coinTypeFromString('arbitrum'),
params.walletIndices.arbitrum,
params.net,
Blockchain.ARBITRUM
)

const btcSecret = btcWallet.privateKey
const ethSecret = ethWallet.privateKey
const neoSecret = neoWallet.privateKey
const avaxcSecret = avaxcWallet.privateKey
const polygonSecret = polygonWallet.privateKey
const neo3Secret = neo3Wallet.privateKey
const arbitrumSecret = arbitrumWallet.privateKey

const btc = await createAPIKey({
...params,
Expand Down Expand Up @@ -91,6 +99,12 @@ export async function generateAPIKeys(params: GenerateApiKeysParams): Promise<AP
curve: 'Secp256r1',
secret: neo3Secret
})
const arbitrum = await createAPIKey({
...params,
curve: 'Secp256k1',
secret: arbitrumSecret
})

return {
child_keys: {
[BIP44.BTC]: {
Expand Down Expand Up @@ -128,6 +142,12 @@ export async function generateAPIKeys(params: GenerateApiKeysParams): Promise<AP
client_secret_share: neo3.client_secret_share,
public_key: neo3Wallet.publicKey,
server_secret_share_encrypted: neo3.server_secret_share_encrypted
},
[BIP44.ABRITRUM]: {
address: arbitrumWallet.address,
client_secret_share: arbitrum.client_secret_share,
public_key: arbitrumWallet.publicKey,
server_secret_share_encrypted: arbitrum.server_secret_share_encrypted
}
},
paillier_pk: btc.paillier_pk,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ test('sign derc20 withdraw movement', async () => {
expect(payloadRes.blockchainMovement).toEqual({
address: 'fa39fddde46cea3060b91f80abed8672f77c5bea',
amount: '303200400',
asset: '0001',
asset: '0003',
nonce: '0052e62c',
prefix: '03',
userPubKey: 'fa39fddde46cea3060b91f80abed8672f77c5bea',
Expand Down Expand Up @@ -117,6 +117,6 @@ test('sign MATIC/DERC20 market buy order', async () => {
orderData
)
expect(rawData).toBe(
'019BAE2051097DC5DDF68D3C01D5FA5CCC7833109D000100000000001700000005FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF00000000000000000000002A'
'019BAE2051097DC5DDF68D3C01D5FA5CCC7833109D000300000000001700000005FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF00000000000000000000002A'
)
})
4 changes: 3 additions & 1 deletion src/types/MPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ export enum BIP44 {
NEO = "m/44'/888'/0'/0/0",
NEO3 = "m/44'/888'/1'/0/0",
POLYGON = "m/44'/966'/0'/0/0",
AVAXC = "m/44'/9000'/0'/0/0"
AVAXC = "m/44'/9000'/0'/0/0",
ABRITRUM = "m/44'/9001'/0'/0/0"
}

export interface ChildKey {
Expand All @@ -115,6 +116,7 @@ export interface APIKey {
[BIP44.AVAXC]?: ChildKey
[BIP44.POLYGON]?: ChildKey
[BIP44.NEO3]?: ChildKey
[BIP44.ABRITRUM]?: ChildKey
}
payload_signing_key: string
payload_public_key: string
Expand Down

0 comments on commit 0f827a8

Please sign in to comment.