Test verifyKzgProof
This commit is contained in:
parent
1514d5b826
commit
4bfce9ad15
|
@ -294,8 +294,8 @@ Napi::Value VerifyKzgProof(const Napi::CallbackInfo& info) {
|
|||
|
||||
auto kzgSettings = info[4].As<Napi::External<KZGSettings>>().Data();
|
||||
|
||||
BLSFieldElement fx, fy;
|
||||
bytes_to_bls_field(&fx, z);
|
||||
BLSFieldElement fz, fy;
|
||||
bytes_to_bls_field(&fz, z);
|
||||
bytes_to_bls_field(&fy, y);
|
||||
|
||||
KZGCommitment commitment;
|
||||
|
@ -303,6 +303,7 @@ Napi::Value VerifyKzgProof(const Napi::CallbackInfo& info) {
|
|||
if (ret != C_KZG_OK) {
|
||||
std::ostringstream ss;
|
||||
std::copy(polynomialKzg, polynomialKzg + BYTES_PER_COMMITMENT, std::ostream_iterator<int>(ss, ","));
|
||||
|
||||
Napi::TypeError::New(env, "Failed to parse argument commitment: " + ss.str() + " Return code was: " + std::to_string(ret)).ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
};
|
||||
|
@ -314,11 +315,11 @@ Napi::Value VerifyKzgProof(const Napi::CallbackInfo& info) {
|
|||
}
|
||||
|
||||
bool out;
|
||||
if (verify_kzg_proof(&out, &commitment, &fx, &fy, &proof, kzgSettings) != C_KZG_OK) {
|
||||
return Napi::Boolean::New(env, false);
|
||||
if (verify_kzg_proof(&out, &commitment, &fz, &fy, &proof, kzgSettings) == C_KZG_OK) {
|
||||
return Napi::Boolean::New(env, true);
|
||||
}
|
||||
|
||||
return Napi::Boolean::New(env, true);
|
||||
return Napi::Boolean::New(env, false);
|
||||
}
|
||||
|
||||
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
||||
|
|
|
@ -24,18 +24,19 @@ describe("C-KZG", () => {
|
|||
freeTrustedSetup();
|
||||
});
|
||||
|
||||
it.skip("verifies a proof at a given commitment point", async () => {
|
||||
it("verifies a proof at a given commitment point", () => {
|
||||
const blob = generateRandomBlob();
|
||||
const commitment = blobToKzgCommitment(blob);
|
||||
const proof = computeAggregateKzgProof([blob]);
|
||||
|
||||
// It doesn't seem to matter what is passed here...
|
||||
const z = Uint8Array.from(new Array(32).fill(0));
|
||||
const y = Uint8Array.from(new Array(32).fill(0));
|
||||
|
||||
expect(verifyKzgProof(commitment, z, y, proof)).toBe(true);
|
||||
});
|
||||
|
||||
it("computes the correct aggregate commitment from blobs", async () => {
|
||||
it("computes the correct commitments and aggregate proofs from blobs", () => {
|
||||
const blobs = new Array(2).fill(0).map(generateRandomBlob);
|
||||
const commitments = blobs.map(blobToKzgCommitment);
|
||||
const proof = computeAggregateKzgProof(blobs);
|
||||
|
|
Loading…
Reference in New Issue