Skip to content

Commit 9ec9553

Browse files
Merge pull request #1479 from xchainjs/chore/migrate-foundry-primitives
remove dependency on foundry-primitives fork
2 parents cfd1018 + e7bc97f commit 9ec9553

File tree

4 files changed

+15
-52
lines changed

4 files changed

+15
-52
lines changed

.changeset/rich-moons-poke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@xchainjs/xchain-crypto': patch
3+
---
4+
5+
drop dependency on foundry-primitives fork

packages/xchain-crypto/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
"@types/uuid": "^9.0.1"
4646
},
4747
"dependencies": {
48+
"@noble/hashes": "^1.8.0",
4849
"@scure/base": "^1.2.6",
4950
"bip39": "^3.1.0",
5051
"crypto-js": "4.2.0",
51-
"foundry-primitives-xchainjs": "github:xchainjs/foundry-primitives-js#master",
5252
"uuid": "^9.0.0"
5353
},
5454
"publishConfig": {

packages/xchain-crypto/src/crypto.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as bip39 from 'bip39'
22
import crypto from 'crypto'
3-
import { blake256 } from 'foundry-primitives-xchainjs'
3+
import { blake256 } from '@noble/hashes/blake1.js'
44
import { v4 as uuidv4 } from 'uuid'
55

66
import { pbkdf2Async } from './utils'
@@ -123,7 +123,8 @@ export const encryptToKeyStore = async (phrase: string, password: string): Promi
123123
const derivedKey = await pbkdf2Async(Buffer.from(password), salt, kdfParams.c, kdfParams.dklen, hashFunction)
124124
const cipherIV = crypto.createCipheriv(cipher, derivedKey.slice(0, 16), iv)
125125
const cipherText = Buffer.concat([cipherIV.update(Buffer.from(phrase, 'utf8')), cipherIV.final()])
126-
const mac = blake256(Buffer.concat([derivedKey.slice(16, 32), Buffer.from(cipherText)]))
126+
const mac_bytes: Uint8Array = blake256(Buffer.concat([derivedKey.slice(16, 32), Buffer.from(cipherText)]))
127+
const mac: string = Buffer.from(mac_bytes).toString('hex')
127128

128129
const cryptoStruct = {
129130
cipher: cipher,
@@ -162,7 +163,8 @@ export const decryptFromKeystore = async (keystore: Keystore, password: string):
162163
)
163164

164165
const ciphertext = Buffer.from(keystore.crypto.ciphertext, 'hex')
165-
const mac = blake256(Buffer.concat([derivedKey.slice(16, 32), ciphertext]))
166+
const mac_bytes: Uint8Array = blake256(Buffer.concat([derivedKey.slice(16, 32), ciphertext]))
167+
const mac: string = Buffer.from(mac_bytes).toString('hex')
166168

167169
if (mac !== keystore.crypto.mac) throw new Error('Invalid password')
168170
const decipher = crypto.createDecipheriv(

yarn.lock

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4007,14 +4007,14 @@ __metadata:
40074007
version: 0.0.0-use.local
40084008
resolution: "@xchainjs/xchain-crypto@workspace:packages/xchain-crypto"
40094009
dependencies:
4010+
"@noble/hashes": "npm:^1.8.0"
40104011
"@scure/base": "npm:^1.2.6"
40114012
"@types/bip39": "npm:^3.0.0"
40124013
"@types/crypto-js": "npm:^4.1.1"
40134014
"@types/node": "npm:^22.7.5"
40144015
"@types/uuid": "npm:^9.0.1"
40154016
bip39: "npm:^3.1.0"
40164017
crypto-js: "npm:4.2.0"
4017-
foundry-primitives-xchainjs: "github:xchainjs/foundry-primitives-js#master"
40184018
uuid: "npm:^9.0.0"
40194019
languageName: unknown
40204020
linkType: soft
@@ -5080,13 +5080,6 @@ __metadata:
50805080
languageName: node
50815081
linkType: hard
50825082

5083-
"bignumber.js@npm:^7.2.1":
5084-
version: 7.2.1
5085-
resolution: "bignumber.js@npm:7.2.1"
5086-
checksum: 10c0/7e2cb10cdc1991696666b129f3b888c44a5e35bd3a5e990b2d2c934c7bc6863fb42b45fdea830484ca0d9e0b9a70d15e1d43fcd03a0e04326612b8e3ac76a0ae
5087-
languageName: node
5088-
linkType: hard
5089-
50905083
"bignumber.js@npm:^9.0.0, bignumber.js@npm:^9.1.2":
50915084
version: 9.1.2
50925085
resolution: "bignumber.js@npm:9.1.2"
@@ -5299,7 +5292,7 @@ __metadata:
52995292
languageName: node
53005293
linkType: hard
53015294

5302-
"blakejs@npm:1.2.1, blakejs@npm:^1.1.0":
5295+
"blakejs@npm:1.2.1":
53035296
version: 1.2.1
53045297
resolution: "blakejs@npm:1.2.1"
53055298
checksum: 10c0/c284557ce55b9c70203f59d381f1b85372ef08ee616a90162174d1291a45d3e5e809fdf9edab6e998740012538515152471dc4f1f9dbfa974ba2b9c1f7b9aad7
@@ -5522,7 +5515,7 @@ __metadata:
55225515
languageName: node
55235516
linkType: hard
55245517

5525-
"buffer@npm:^5.2.1, buffer@npm:^5.5.0":
5518+
"buffer@npm:^5.5.0":
55265519
version: 5.7.1
55275520
resolution: "buffer@npm:5.7.1"
55285521
dependencies:
@@ -7439,25 +7432,6 @@ __metadata:
74397432
languageName: node
74407433
linkType: hard
74417434

7442-
"foundry-primitives-xchainjs@github:xchainjs/foundry-primitives-js#master":
7443-
version: 0.2.1
7444-
resolution: "foundry-primitives-xchainjs@https://github.com/xchainjs/foundry-primitives-js.git#commit=7daeca67840d95bda9afb8f527e9d5a397d67ac9"
7445-
dependencies:
7446-
bignumber.js: "npm:^7.2.1"
7447-
blakejs: "npm:^1.1.0"
7448-
bn.js: "npm:^4.11.8"
7449-
buffer: "npm:^5.2.1"
7450-
crypto-js: "npm:4.2.0"
7451-
elliptic: "npm:^6.6.1"
7452-
hmac-drbg: "npm:^1.0.1"
7453-
lodash: "npm:^4.17.21"
7454-
node-forge: "npm:^1.3.1"
7455-
rlp: "npm:^2.1.0"
7456-
tweetnacl: "npm:^1.0.3"
7457-
checksum: 10c0/1c0adb408012a4c35a63d043503e515595ca7310ab1dccb3e143071e44a20fb655a596a8caa097f4ba5d3d7a46682a8bffd76203784a6d25e29b4a6dff949009
7458-
languageName: node
7459-
linkType: hard
7460-
74617435
"fs-constants@npm:^1.0.0":
74627436
version: 1.0.0
74637437
resolution: "fs-constants@npm:1.0.0"
@@ -10164,13 +10138,6 @@ __metadata:
1016410138
languageName: node
1016510139
linkType: hard
1016610140

10167-
"node-forge@npm:^1.3.1":
10168-
version: 1.3.1
10169-
resolution: "node-forge@npm:1.3.1"
10170-
checksum: 10c0/e882819b251a4321f9fc1d67c85d1501d3004b4ee889af822fd07f64de3d1a8e272ff00b689570af0465d65d6bf5074df9c76e900e0aff23e60b847f2a46fbe8
10171-
languageName: node
10172-
linkType: hard
10173-
1017410141
"node-gyp-build@npm:^4.2.0, node-gyp-build@npm:^4.3.0, node-gyp-build@npm:^4.5.0":
1017510142
version: 4.7.1
1017610143
resolution: "node-gyp-build@npm:4.7.1"
@@ -11313,17 +11280,6 @@ __metadata:
1131311280
languageName: node
1131411281
linkType: hard
1131511282

11316-
"rlp@npm:^2.1.0":
11317-
version: 2.2.7
11318-
resolution: "rlp@npm:2.2.7"
11319-
dependencies:
11320-
bn.js: "npm:^5.2.0"
11321-
bin:
11322-
rlp: bin/rlp
11323-
checksum: 10c0/166c449f4bc794d47f8e337bf0ffbcfdb26c33109030aac4b6e5a33a91fa85783f2290addeb7b3c89d6d9b90c8276e719494d193129bed0a60a2d4a6fd658277
11324-
languageName: node
11325-
linkType: hard
11326-
1132711283
"rollup-plugin-visualizer@npm:^5.14.0":
1132811284
version: 5.14.0
1132911285
resolution: "rollup-plugin-visualizer@npm:5.14.0"
@@ -12627,7 +12583,7 @@ __metadata:
1262712583
languageName: node
1262812584
linkType: hard
1262912585

12630-
"tweetnacl@npm:1.0.3, tweetnacl@npm:^1.0.3":
12586+
"tweetnacl@npm:1.0.3":
1263112587
version: 1.0.3
1263212588
resolution: "tweetnacl@npm:1.0.3"
1263312589
checksum: 10c0/069d9df51e8ad4a89fbe6f9806c68e06c65be3c7d42f0701cc43dba5f0d6064686b238bbff206c5addef8854e3ce00c643bff59432ea2f2c639feab0ee1a93f9

0 commit comments

Comments
 (0)