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

Commit

Permalink
chore: use multiformats sha3 impl (#3772)
Browse files Browse the repository at this point in the history
Use the `@multiformats/sha3` module instead of rolling our own
  • Loading branch information
achingbrain committed Jul 28, 2021
1 parent bb6113a commit 349cbd0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
16 changes: 4 additions & 12 deletions examples/traverse-ipld-graphs/eth.js
Expand Up @@ -3,28 +3,20 @@
const createNode = require('./create-node')
const path = require('path')
const { CID } = require('multiformats/cid')
const MultihashDigest = require('multiformats/hashes/digest')
const fs = require('fs').promises
const uint8ArrayToString = require('uint8arrays/to-string')
const { convert } = require('ipld-format-to-blockcodec')
const sha3 = require('js-sha3')
const { keccak256 } = require('@multiformats/sha3')

async function main () {
const ipfs = await createNode({
ipld: {
codecs: [
...Object.values(require('ipld-ethereum')).map(format => convert(format))
],
hashers: [{
name: 'keccak-256',
code: 0x1b,
digest: async (buf) => {
return MultihashDigest.create(
0x1b,
new Uint8Array(sha3.keccak256.arrayBuffer(buf))
)
}
}]
hashers: [
keccak256
]
}
})

Expand Down
4 changes: 2 additions & 2 deletions examples/traverse-ipld-graphs/package.json
Expand Up @@ -13,10 +13,10 @@
"test-ipfs-example": "^3.0.0"
},
"dependencies": {
"@multiformats/sha3": "^2.0.0",
"ipfs": "^0.56.0",
"ipld-ethereum": "^6.0.0",
"ipld-format-to-blockcodec": "0.0.1",
"ipld-git": "^0.6.1",
"js-sha3": "^0.8.0"
"ipld-git": "^0.6.1"
}
}

0 comments on commit 349cbd0

Please sign in to comment.