@@ -60,13 +60,13 @@ Notes:
6060- ` std ` : enables I/O and serde for convenient loading.
6161- ` trace ` : prints detailed verifier internals (for debugging); off by default.
6262- ` alloc ` (default): required for ` no_std ` collections.
63- - ` soroban-bn254- precompile ` : routes MSM + pairing calls through a backend facade intended for a Soroban BN254 precompile.
63+ - ` soroban-precompile ` : routes MSM + pairing calls through a backend facade intended for a Soroban host precompile.
6464 For now, it falls back to Arkworks so behavior is unchanged, but gives a stable call site to switch to host calls later.
6565
66- ### Soroban BN254 precompile
67- - Purpose: Provide a seam to swap the EC hot paths (G1 MSM and pairing) to a Soroban BN254 precompile .
68- - Enable: ` --features soroban-bn254- precompile ` . If no backend is registered, it transparently falls back to the Arkworks implementation .
69- - Scope: Public API remains unchanged (` ec::g1_msm ` , ` ec::pairing_check ` ). Register a backend once at startup .
66+ ### Soroban precompile
67+ - Purpose: Provide seams to swap the EC hot paths (G1 MSM and pairing) and the transcript hash to Soroban host precompiles .
68+ - Enable: ` --features soroban-precompile ` . If no backend is registered, it transparently falls back to the Arkworks/Keccak implementations .
69+ - Scope: Public API remains unchanged (` ec::g1_msm ` , ` ec::pairing_check ` , ` hash::hash32 ` ). Register backends once during contract initialization .
7070
7171Backend contract
7272- Trait: ` ec::Bn254Ops ` (intended to be ` Send + Sync ` )
@@ -76,14 +76,19 @@ Backend contract
7676 - Must verify ` e(p0, rhs_g2) * e(p1, lhs_g2) == 1 ` using the fixed G2 constants defined in ` ec.rs ` .
7777
7878```
79- #[cfg(feature = "soroban-bn254- precompile")]
79+ #[cfg(feature = "soroban-precompile")]
8080{
81- use ultrahonk_rust_verifier::{ec::{self, Bn254Ops}, types::G1Point, field::Fr};
81+ use ultrahonk_rust_verifier::{
82+ ec::{self, Bn254Ops},
83+ hash::{self, HashOps},
84+ types::G1Point,
85+ field::Fr,
86+ };
8287 use ark_bn254::G1Affine;
8388
8489 // Example backend that calls the Soroban host precompile (pseudo-code)
85- struct SorobanOps { /* env: soroban_sdk::Env, ... */ }
86- impl Bn254Ops for SorobanOps {
90+ struct SorobanEcOps { /* env: soroban_sdk::Env, ... */ }
91+ impl Bn254Ops for SorobanEcOps {
8792 fn g1_msm(&self, coms: &[G1Point], scalars: &[Fr]) -> Result<G1Affine, String> {
8893 // host_msm(env, coms, scalars).map_err(|e| e.to_string())
8994 unimplemented!("call Soroban MSM precompile")
@@ -93,8 +98,16 @@ Backend contract
9398 unimplemented!("call Soroban pairing precompile")
9499 }
95100 }
101+ struct SorobanHashOps { /* env, ... */ }
102+ impl HashOps for SorobanHashOps {
103+ fn hash(&self, data: &[u8]) -> [u8; 32] {
104+ // host_poseidon(env, data)
105+ unimplemented!("call Soroban hash precompile")
106+ }
107+ }
96108
97- ec::set_soroban_bn254_backend(Box::new(SorobanOps { /* env, ... */ }));
109+ ec::set_soroban_bn254_backend(Box::new(SorobanEcOps { /* env, ... */ }));
110+ hash::set_soroban_hash_backend(Box::new(SorobanHashOps { /* env, ... */ }));
98111}
99112```
100113
0 commit comments