Comparing version 0.1.0 to 0.2.0
@@ -8,2 +8,7 @@ # Changelog | ||
## 0.2.0 - 2024-03-06 | ||
- Reuse WASM file for both ESM and CJS (build size), PR [#3](https://github.com/ethereumjs/kzg-wasm/pull/3) | ||
- Fix a severe bug affecting the results of all exposed methods, PR [#3](https://github.com/ethereumjs/kzg-wasm/pull/3) | ||
## 0.1.0 - 2024-02-28 | ||
@@ -10,0 +15,0 @@ |
@@ -5,3 +5,3 @@ "use strict"; | ||
const util_js_1 = require("./util.js"); | ||
const kzg_js_1 = require("./wasm/kzg.js"); | ||
const kzg_js_1 = require("./kzg.js"); | ||
/** | ||
@@ -17,4 +17,4 @@ * Initialization function that instantiates WASM code and returns an object matching the `KZG` interface exposed by `@ethereumjs/util` | ||
const computeBlobKzgProofWasm = module.cwrap('compute_blob_kzg_proof_wasm', 'string', ['array', 'array']); | ||
const verifyBlobKzgProofWasm = module.cwrap('verify_blob_kzg_proof_wasm', 'number', ['array', 'array', 'array']); | ||
const verifyKzgProofWasm = module.cwrap('verify_kzg_proof_wasm', 'number', ['array', 'array', 'array', 'array']); | ||
const verifyBlobKzgProofWasm = module.cwrap('verify_blob_kzg_proof_wasm', 'string', ['array', 'array', 'array']); | ||
const verifyKzgProofWasm = module.cwrap('verify_kzg_proof_wasm', 'string', ['array', 'array', 'array', 'array']); | ||
const blobToKzgCommitment = (blob) => { | ||
@@ -34,3 +34,3 @@ const blobHex = '0x' + blobToKzgCommitmentWasm(blob); | ||
const res = verifyBlobKzgProofWasm(blobs[x], commitments[x], proofs[x]); | ||
if (res !== 0) | ||
if (res !== 'true') | ||
return false; | ||
@@ -42,7 +42,7 @@ } | ||
const res = verifyBlobKzgProofWasm(blob, commitment, proof); | ||
return res === 0; | ||
return res === 'true'; | ||
}; | ||
const verifyKzgProof = (commitment, z, y, proof) => { | ||
const res = verifyKzgProofWasm(commitment, z, y, proof); | ||
return res === 0; | ||
return res === 'true'; | ||
}; | ||
@@ -49,0 +49,0 @@ return { |
import { hexToBytes } from './util.js'; | ||
import kzgWasm from './wasm/kzg.js'; | ||
import kzgWasm from './kzg.js'; | ||
/** | ||
@@ -13,4 +13,4 @@ * Initialization function that instantiates WASM code and returns an object matching the `KZG` interface exposed by `@ethereumjs/util` | ||
const computeBlobKzgProofWasm = module.cwrap('compute_blob_kzg_proof_wasm', 'string', ['array', 'array']); | ||
const verifyBlobKzgProofWasm = module.cwrap('verify_blob_kzg_proof_wasm', 'number', ['array', 'array', 'array']); | ||
const verifyKzgProofWasm = module.cwrap('verify_kzg_proof_wasm', 'number', ['array', 'array', 'array', 'array']); | ||
const verifyBlobKzgProofWasm = module.cwrap('verify_blob_kzg_proof_wasm', 'string', ['array', 'array', 'array']); | ||
const verifyKzgProofWasm = module.cwrap('verify_kzg_proof_wasm', 'string', ['array', 'array', 'array', 'array']); | ||
const blobToKzgCommitment = (blob) => { | ||
@@ -30,3 +30,3 @@ const blobHex = '0x' + blobToKzgCommitmentWasm(blob); | ||
const res = verifyBlobKzgProofWasm(blobs[x], commitments[x], proofs[x]); | ||
if (res !== 0) | ||
if (res !== 'true') | ||
return false; | ||
@@ -38,7 +38,7 @@ } | ||
const res = verifyBlobKzgProofWasm(blob, commitment, proof); | ||
return res === 0; | ||
return res === 'true'; | ||
}; | ||
const verifyKzgProof = (commitment, z, y, proof) => { | ||
const res = verifyKzgProofWasm(commitment, z, y, proof); | ||
return res === 0; | ||
return res === 'true'; | ||
}; | ||
@@ -45,0 +45,0 @@ return { |
{ | ||
"name": "kzg-wasm", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "", | ||
@@ -8,4 +8,5 @@ "scripts": { | ||
"build:ts": "scripts/ts-build.sh", | ||
"transpileCJS": "rm dist/cjs/wasm/kzg.js && babel src/wasm/kzg.js -d dist/cjs/wasm", | ||
"fixRequire": "sed -i.bak \"s/\\_require('url')/require('url')/g\" dist/cjs/wasm/kzg.js && rm dist/cjs/wasm/kzg.js.bak", | ||
"transpileCJS": "rm dist/cjs/kzg.js && babel src/kzg.js -d dist/cjs", | ||
"fixRequire": "sed -i.bak \"s/\\_require('url')/require('url')/g\" dist/cjs/kzg.js && rm dist/cjs/kzg.js.bak", | ||
"fixWasmDir": "sed -i.bak 's#./kzg.wasm#../wasm/kzg.wasm#g' src/kzg.js && rm src/kzg.js.bak", | ||
"clean": "rm -rf dist && rm -rf node_modules", | ||
@@ -12,0 +13,0 @@ "test": "vitest run test/*", |
import { hexToBytes } from './util.js' | ||
import kzgWasm from './wasm/kzg.js' | ||
import kzgWasm from './kzg.js' | ||
@@ -15,4 +15,4 @@ /** | ||
const computeBlobKzgProofWasm = module.cwrap('compute_blob_kzg_proof_wasm', 'string', ['array', 'array']) as (blob: Uint8Array, commitment: Uint8Array) => string | ||
const verifyBlobKzgProofWasm = module.cwrap('verify_blob_kzg_proof_wasm', 'number', ['array', 'array', 'array']) as (blob: Uint8Array, commitment: Uint8Array, proof: Uint8Array) => number | ||
const verifyKzgProofWasm = module.cwrap('verify_kzg_proof_wasm', 'number', ['array', 'array', 'array', 'array']) | ||
const verifyBlobKzgProofWasm = module.cwrap('verify_blob_kzg_proof_wasm', 'string', ['array', 'array', 'array']) as (blob: Uint8Array, commitment: Uint8Array, proof: Uint8Array) => string | ||
const verifyKzgProofWasm = module.cwrap('verify_kzg_proof_wasm', 'string', ['array', 'array', 'array', 'array']) | ||
@@ -35,3 +35,3 @@ const blobToKzgCommitment = (blob: Uint8Array) => { | ||
const res = verifyBlobKzgProofWasm(blobs[x], commitments[x], proofs[x]) | ||
if (res !== 0) return false | ||
if (res !== 'true') return false | ||
} | ||
@@ -43,3 +43,3 @@ return true | ||
const res = verifyBlobKzgProofWasm(blob, commitment, proof) | ||
return res === 0 | ||
return res === 'true' | ||
} | ||
@@ -49,3 +49,3 @@ | ||
const res = verifyKzgProofWasm(commitment, z, y, proof) | ||
return res === 0 | ||
return res === 'true' | ||
} | ||
@@ -52,0 +52,0 @@ return { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
889078
33
3337