Repository: dusk-network/rusk (language: rust)

Issue:
rusk: embed verifier keys
#### Summary
Every node need verifier data available to preverify transactions

This lead to node operators to download vd or to run `rusk recovery keys` to generate them (even if node is not used for proving)

#### Possible solution design or implementation
Embed VD and let user run `rusk recovery keys` only if needed by prover

#### Additional context
`rusk recovery keys` it's quite slow even if the keys are already generated. This is because the CRS is not in uncompressed format anymore (maybe worth to restore the old format)


Discussion / hints:

Fix patch:
diff --git a/rusk/CHANGELOG.md b/rusk/CHANGELOG.md
index 0be844d1d..636c31219 100644
--- a/rusk/CHANGELOG.md
+++ b/rusk/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
+### Changed
+
+- Change plonk verification to use embed verification data by default [#3507]
+
 ## [1.1.0] - 2025-02-14
 
 ### Added
@@ -339,6 +343,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - Add build system that generates keys for circuits and caches them.
 
 <!-- Issues -->
+[#3507]: https://github.com/dusk-network/rusk/issues/3507
 [#3494]: https://github.com/dusk-network/rusk/issues/3494
 [#3481]: https://github.com/dusk-network/rusk/issues/3481
 [#3359]: https://github.com/dusk-network/rusk/issues/3359
diff --git a/rusk/Cargo.toml b/rusk/Cargo.toml
index df5ba76bf..f98f69c59 100644
--- a/rusk/Cargo.toml
+++ b/rusk/Cargo.toml
@@ -114,6 +114,7 @@ chain = ["dep:node", "dep:dusk-consensus", "dep:node-data"]
 archive = ["chain", "node/archive"]
 network-trace = ["node/network-trace"]
 http-wasm = []
+dynamic-verifier = []
 
 [[bench]]
 name = "block_ingestion"
diff --git a/rusk/src/assets/vd/0095785bd378e5cd3c7427c03b6d4420966c03156bf045b556f22419252fc8bc.vd b/rusk/src/assets/vd/0095785bd378e5cd3c7427c03b6d4420966c03156bf045b556f22419252fc8bc.vd
new file mode 100644
index 000000000..7d2d9352b
Binary files /dev/null and b/rusk/src/assets/vd/0095785bd378e5cd3c7427c03b6d4420966c03156bf045b556f22419252fc8bc.vd differ
diff --git a/rusk/src/assets/vd/1210b96327d25a0403be7b8e027cfe964370700b94ec7f47d22128ecbe7e9803.vd b/rusk/src/assets/vd/1210b96327d25a0403be7b8e027cfe964370700b94ec7f47d22128ecbe7e9803.vd
new file mode 100644
index 000000000..0b4ffb536
Binary files /dev/null and b/rusk/src/assets/vd/1210b96327d25a0403be7b8e027cfe964370700b94ec7f47d22128ecbe7e9803.vd differ
diff --git a/rusk/src/assets/vd/98c9786a8cf36f19bcbdf97f4bc140fe402ae5f72cef3f60f24b96071c0faa73.vd b/rusk/src/assets/vd/98c9786a8cf36f19bcbdf97f4bc140fe402ae5f72cef3f60f24b96071c0faa73.vd
new file mode 100644
index 000000000..07d654574
Binary files /dev/null and b/rusk/src/assets/vd/98c9786a8cf36f19bcbdf97f4bc140fe402ae5f72cef3f60f24b96071c0faa73.vd differ
diff --git a/rusk/src/assets/vd/c8fed2bfcc0e0e64709586b56636fc1831be5f0227e533363e9a49b8fae5cd2f.vd b/rusk/src/assets/vd/c8fed2bfcc0e0e64709586b56636fc1831be5f0227e533363e9a49b8fae5cd2f.vd
new file mode 100644
index 000000000..7b4422e11
Binary files /dev/null and b/rusk/src/assets/vd/c8fed2bfcc0e0e64709586b56636fc1831be5f0227e533363e9a49b8fae5cd2f.vd differ
diff --git a/rusk/src/lib/verifier.rs b/rusk/src/lib/verifier.rs
index 112d7cfce..462c04743 100644
--- a/rusk/src/lib/verifier.rs
+++ b/rusk/src/lib/verifier.rs
@@ -9,26 +9,58 @@
 use crate::error::Error;
 use crate::Result;
 
-use dusk_core::transfer::{
-    moonlight::Transaction as MoonlightTransaction,
-    phoenix::Transaction as PhoenixTransaction,
-};
+use dusk_core::transfer::moonlight::Transaction as MoonlightTransaction;
+use dusk_core::transfer::phoenix::Transaction as PhoenixTransaction;
 use dusk_vm::host_queries;
-use rusk_profile::Circuit as CircuitProfile;
 
-use std::sync::LazyLock;
+#[cfg(not(feature = "dynamic-verifier"))]
+mod embed {
+    pub static VD_EXEC_1_2: &[u8] =
+    include_bytes!("../assets/vd/c8fed2bfcc0e0e64709586b56636fc1831be5f0227e533363e9a49b8fae5cd2f.vd");
 
-pub static VD_EXEC_1_2: LazyLock<Vec<u8>> =
-    LazyLock::new(|| fetch_verifier("TxCircuitOneTwo"));
+    pub static VD_EXEC_2_2: &[u8] =
+    include_bytes!("../assets/vd/98c9786a8cf36f19bcbdf97f4bc140fe402ae5f72cef3f60f24b96071c0faa73.vd");
 
-pub static VD_EXEC_2_2: LazyLock<Vec<u8>> =
-    LazyLock::new(|| fetch_verifier("TxCircuitTwoTwo"));
+    pub static VD_EXEC_3_2: &[u8] =
+    include_bytes!("../assets/vd/1210b96327d25a0403be7b8e027cfe964370700b94ec7f47d22128ecbe7e9803.vd");
 
-pub static VD_EXEC_3_2: LazyLock<Vec<u8>> =
-    LazyLock::new(|| fetch_verifier("TxCircuitThreeTwo"));
+    pub static VD_EXEC_4_2: &[u8] =
+    include_bytes!("../assets/vd/0095785bd378e5cd3c7427c03b6d4420966c03156bf045b556f22419252fc8bc.vd");
+}
+#[cfg(not(feature = "dynamic-verifier"))]
+use embed::*;
+
+#[cfg(feature = "dynamic-verifier")]
+mod runtime {
+    use rusk_profile::Circuit as CircuitProfile;
+    use std::sync::LazyLock;
+    pub static VD_EXEC_1_2: LazyLock<Vec<u8>> =
+        LazyLock::new(|| fetch_verifier("TxCircuitOneTwo"));
+
+    pub static VD_EXEC_2_2: LazyLock<Vec<u8>> =
+        LazyLock::new(|| fetch_verifier("TxCircuitTwoTwo"));
+
+    pub static VD_EXEC_3_2: LazyLock<Vec<u8>> =
+        LazyLock::new(|| fetch_verifier("TxCircuitThreeTwo"));
 
-pub static VD_EXEC_4_2: LazyLock<Vec<u8>> =
-    LazyLock::new(|| fetch_verifier("TxCircuitFourTwo"));
+    pub static VD_EXEC_4_2: LazyLock<Vec<u8>> =
+        LazyLock::new(|| fetch_verifier("TxCircuitFourTwo"));
+
+    fn fetch_verifier(circuit_name: &str) -> Vec<u8> {
+        let circuit_profile = CircuitProfile::from_name(circuit_name)
+            .unwrap_or_else(|_| {
+                panic!(
+                    "There should be circuit data stored for {}",
+                    circuit_name
+                )
+            });
+        circuit_profile.get_verifier().unwrap_or_else(|_| {
+            panic!("there should be a verifier key stored for {}", circuit_name)
+        })
+    }
+}
+#[cfg(feature = "dynamic-verifier")]
+use runtime::*;
 
 /// Verifies the proof of the incoming transaction.
 pub fn verify_proof(tx: &PhoenixTransaction) -> Result<bool> {
@@ -64,13 +96,3 @@ pub fn verify_signature(tx: &MoonlightTransaction) -> Result<bool> {
         *tx.signature(),
     ))
 }
-
-fn fetch_verifier(circuit_name: &str) -> Vec<u8> {
-    let circuit_profile = CircuitProfile::from_name(circuit_name)
-        .unwrap_or_else(|_| {
-            panic!("There should be circuit data stored for {}", circuit_name)
-        });
-    circuit_profile.get_verifier().unwrap_or_else(|_| {
-        panic!("there should be a verifier key stored for {}", circuit_name)
-    })
-}


Test patch: