Skip to content

Commit 06518ed

Browse files
committed
chore: rm c-kzg
1 parent 9047a75 commit 06518ed

File tree

5 files changed

+72
-66
lines changed

5 files changed

+72
-66
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,18 @@
5252
"@changesets/changelog-github": "^0.4.8",
5353
"@changesets/cli": "^2.27.9",
5454
"@ethereumjs/rlp": "^5.0.2",
55+
"@paulmillr/trusted-setups": "^0.1.2",
5556
"@pimlico/alto": "0.0.4",
5657
"@size-limit/preset-big-lib": "^11.1.6",
5758
"@types/bun": "^1.1.11",
5859
"@types/node": "^20.16.12",
5960
"@vitest/coverage-v8": "^1.0.4",
6061
"@vitest/ui": "^1.0.4",
6162
"bun": "^1.1.30",
62-
"c-kzg": "^2.1.2",
6363
"ethers": "^6.13.4",
6464
"glob": "^10.4.5",
6565
"knip": "^5.33.3",
66+
"micro-eth-signer": "^0.14.0",
6667
"permissionless": "^0.2.14",
6768
"prool": "0.0.23",
6869
"publint": "^0.2.11",
@@ -72,7 +73,6 @@
7273
"typescript": "5.6.2",
7374
"vitest": "^1.0.4"
7475
},
75-
"trustedDependencies": ["c-kzg"],
7676
"packageManager": "[email protected]",
7777
"engines": {
7878
"node": "23.x"

pnpm-lock.yaml

Lines changed: 40 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/kzg/defineKzg.test.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import { readFileSync } from 'node:fs'
22
import { resolve } from 'node:path'
3-
import * as cKzg from 'c-kzg'
43
import { describe, expect, test } from 'vitest'
54

6-
import '../../../test/src/kzg.js'
7-
import type { Kzg } from '../../types/kzg.js'
5+
import { kzg } from '../../../test/src/kzg.js'
86
import { hexToBytes } from '../index.js'
9-
import { defineKzg } from './defineKzg.js'
107

118
const blobToKzgCommitmentCases = JSON.parse(
129
readFileSync(
@@ -21,19 +18,6 @@ const computeBlobKzgProofCases = JSON.parse(
2118
),
2219
)
2320

24-
let kzg: Kzg
25-
26-
test('defineKzg', () => {
27-
kzg = defineKzg(cKzg)
28-
29-
expect(kzg).toMatchInlineSnapshot(`
30-
{
31-
"blobToKzgCommitment": [Function],
32-
"computeBlobKzgProof": [Function],
33-
}
34-
`)
35-
})
36-
3721
describe('blobToKzgCommitment', () => {
3822
for (const data of blobToKzgCommitmentCases) {
3923
test(data.name, () => {

src/utils/kzg/setupKzg.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
import * as cKzg from 'c-kzg'
21
import { expect, test } from 'vitest'
32

43
import { mainnetTrustedSetupPath } from '../../node/index.js'
54
import { setupKzg } from './setupKzg.js'
65

76
test('setupKzg', () => {
8-
const kzg = setupKzg(cKzg, mainnetTrustedSetupPath)
7+
const kzg = setupKzg(
8+
{
9+
loadTrustedSetup() {},
10+
blobToKzgCommitment() {
11+
return new Uint8Array()
12+
},
13+
computeBlobKzgProof() {
14+
return new Uint8Array()
15+
},
16+
},
17+
mainnetTrustedSetupPath,
18+
)
919

1020
expect(kzg).toMatchInlineSnapshot(`
1121
{

test/src/kzg.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
import { readFileSync } from 'node:fs'
22
import { resolve } from 'node:path'
3-
import * as cKzg from 'c-kzg'
4-
import { mainnetTrustedSetupPath } from '~viem/node/trustedSetups.js'
5-
import { setupKzg } from '~viem/utils/kzg/setupKzg.js'
3+
import { trustedSetup as fastSetup } from '@paulmillr/trusted-setups/fast.js'
4+
import { KZG } from 'micro-eth-signer/kzg'
5+
import { bytesToHex, defineKzg, hexToBytes } from '../../src/index.js'
66

7-
export const kzg = setupKzg(cKzg, mainnetTrustedSetupPath)
7+
const k = new KZG(fastSetup)
8+
export const kzg = defineKzg({
9+
blobToKzgCommitment(blob) {
10+
return hexToBytes(k.blobToKzgCommitment(bytesToHex(blob)) as `0x${string}`)
11+
},
12+
computeBlobKzgProof(blob, commitment) {
13+
return hexToBytes(
14+
k.computeBlobProof(
15+
bytesToHex(blob),
16+
bytesToHex(commitment),
17+
) as `0x${string}`,
18+
)
19+
},
20+
})
821

922
export const blobData = readFileSync(
1023
resolve(__dirname, '../kzg/lorem-ipsum.txt'),

0 commit comments

Comments
 (0)