Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 349cbd0

Browse files
authored
chore: use multiformats sha3 impl (#3772)
Use the `@multiformats/sha3` module instead of rolling our own
1 parent bb6113a commit 349cbd0

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

examples/traverse-ipld-graphs/eth.js

+4-12
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,20 @@
33
const createNode = require('./create-node')
44
const path = require('path')
55
const { CID } = require('multiformats/cid')
6-
const MultihashDigest = require('multiformats/hashes/digest')
76
const fs = require('fs').promises
87
const uint8ArrayToString = require('uint8arrays/to-string')
98
const { convert } = require('ipld-format-to-blockcodec')
10-
const sha3 = require('js-sha3')
9+
const { keccak256 } = require('@multiformats/sha3')
1110

1211
async function main () {
1312
const ipfs = await createNode({
1413
ipld: {
1514
codecs: [
1615
...Object.values(require('ipld-ethereum')).map(format => convert(format))
1716
],
18-
hashers: [{
19-
name: 'keccak-256',
20-
code: 0x1b,
21-
digest: async (buf) => {
22-
return MultihashDigest.create(
23-
0x1b,
24-
new Uint8Array(sha3.keccak256.arrayBuffer(buf))
25-
)
26-
}
27-
}]
17+
hashers: [
18+
keccak256
19+
]
2820
}
2921
})
3022

examples/traverse-ipld-graphs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
"test-ipfs-example": "^3.0.0"
1414
},
1515
"dependencies": {
16+
"@multiformats/sha3": "^2.0.0",
1617
"ipfs": "^0.56.0",
1718
"ipld-ethereum": "^6.0.0",
1819
"ipld-format-to-blockcodec": "0.0.1",
19-
"ipld-git": "^0.6.1",
20-
"js-sha3": "^0.8.0"
20+
"ipld-git": "^0.6.1"
2121
}
2222
}

0 commit comments

Comments
 (0)