Skip to content

Commit

Permalink
fix: On malformed proof, return false instead of throwing
Browse files Browse the repository at this point in the history
* update rust verkle

* add a test with a prestate root that is false

* replace test data with explicitly wrong preState root

---------

Co-authored-by: Gabriel Rocheleau <[email protected]>
  • Loading branch information
kevaundray and gabrocheleau authored May 15, 2024
1 parent f5250a8 commit d72e573
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src.rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ default = ["console_error_panic_hook"]
serde = { version = "1.0", features = ["derive"] }
serde-wasm-bindgen = "0.3.0"
wasm-bindgen = { version = "0.2.90", features = ["serde-serialize"] }
ipa-multipoint = { git = "https://github.com/crate-crypto/rust-verkle", rev = "1c2cd88661e0bf54df29239333baba4bd115c3d3" }
banderwagon = { git = "https://github.com/crate-crypto/rust-verkle", rev = "1c2cd88661e0bf54df29239333baba4bd115c3d3" }
ffi_interface = { git = "https://github.com/crate-crypto/rust-verkle", rev = "1c2cd88661e0bf54df29239333baba4bd115c3d3" }
ipa-multipoint = { git = "https://github.com/crate-crypto/rust-verkle", rev = "309cdcba4088e698689dc33b8ee071c2d064b2ae" }
banderwagon = { git = "https://github.com/crate-crypto/rust-verkle", rev = "309cdcba4088e698689dc33b8ee071c2d064b2ae" }
ffi_interface = { git = "https://github.com/crate-crypto/rust-verkle", rev = "309cdcba4088e698689dc33b8ee071c2d064b2ae" }

hex = "0.4.3"
# This is needed so that we can enable the js feature, which is being used in ark-serialize
Expand Down
11 changes: 9 additions & 2 deletions src.ts/tests/ffi.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bytesToHex } from '@ethereumjs/util'
import { bytesToHex, randomBytes } from '@ethereumjs/util'
import { beforeAll, describe, expect, test } from 'vitest'

import { VerkleCrypto, loadVerkleCrypto } from '../index.js'
Expand Down Expand Up @@ -192,7 +192,6 @@ describe('bindings', () => {
expect(verified).toBe(true)
})

// This one is for a much larger block (~100 txs) and currently fails
test('verifyExecutionProof: block with many txs', () => {
// Src: Kaustinen6 testnet, block 72 state root (parent of block 73)
const prestateRoot = '0x18d1dfcc6ccc6f34d14af48a865895bf34bde7f3571d9ba24a4b98122841048c'
Expand All @@ -202,6 +201,14 @@ describe('bindings', () => {
expect(verified).toBe(true)
})

test('verifyExecutionProof: invalid state root', () => {
const prestateRoot = bytesToHex(randomBytes(32))
const executionWitness = JSON.stringify(kaustinenBlock73.executionWitness)

const verified = verifyExecutionWitnessPreState(prestateRoot, executionWitness)
expect(verified).toBe(false)
})

test('smoke test errors are thrown', () => {
const scalar = new Uint8Array([0])

Expand Down

0 comments on commit d72e573

Please sign in to comment.