You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+101-1Lines changed: 101 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# KZG-WASM
2
2
3
-
This module implements a JS wrapper around a WASM compilation of the [`c-kzg-4844`](https://github.com/ethereum/c-kzg-4844) C library built for use with EIP-4844.
3
+
This module implements a JS wrapper around a WASM compilation of the [`c-kzg-4844`](https://github.com/ethereum/c-kzg-4844) C library built for use with EIP-4844. Starting with v1.0.0, the library also support cell-based operations in the context of EIP-7594 (PeerDAS).
4
4
5
5
This library is produced by building the original C code to WASM using the [`empscripten`](https://empscripten.org) toolchain in [this fork](https://github.com/ETHCF/c-kzg-4844) of `c-kzg-4844`.
6
6
@@ -26,3 +26,103 @@ const main = async () => {
26
26
27
27
main()
28
28
```
29
+
30
+
## API Reference
31
+
32
+
The `loadKZG()` function returns an object that implements the KZG interface with the following methods:
loadTrustedSetup(trustedSetup: TrustedSetup=mainnetTrustedSetup, precompute: number=8): number
39
+
```
40
+
Loads a trusted setup for KZG operations. Returns 0 on success, non-zero on failure.
41
+
42
+
#### `freeTrustedSetup()`
43
+
```ts
44
+
freeTrustedSetup(): void
45
+
```
46
+
Frees the loaded trusted setup from memory.
47
+
48
+
#### `blobToKZGCommitment(blob)`
49
+
```ts
50
+
blobToKZGCommitment(blob: string): string
51
+
```
52
+
Converts a blob of data into a KZG commitment. Takes a prefixed hex string containing 4096 big endian KZG field elements and returns a 48-byte KZG commitment as a prefixed hex string.
Recovers all cells and proofs from partial cell data. Requires at least 50% of the total cells to be provided. Returns the complete set of proofs and cells.
Verifies multiple cell KZG proofs in batch. All arrays must have the same length and match `numCells`. Returns `true` if all proofs are valid, `false` otherwise.
103
+
104
+
### Compatibility Aliases
105
+
106
+
The library also provides aliases for compatibility with different naming conventions:
107
+
108
+
-`blobToKzgCommitment` - alias for `blobToKZGCommitment`
109
+
-`computeBlobProof` - alias for `computeBlobKZGProof`
110
+
111
+
### Types
112
+
113
+
#### `TrustedSetup`
114
+
```ts
115
+
typeTrustedSetup= {
116
+
g1_monomial:string
117
+
g1_lagrange:string
118
+
g2_monomial:string
119
+
}
120
+
```
121
+
122
+
#### `KZGProofWithCells`
123
+
```ts
124
+
typeKZGProofWithCells= {
125
+
proofs:string[] // Array of 128 proofs, each 48 bytes
126
+
cells:string[] // Array of 128 cells, each 2048 bytes
0 commit comments