Skip to content

refactor(inlines): deduplicate field types, add InlineSpec, typed advice#1371

Draft
0xAndoroid wants to merge 6 commits intomainfrom
ref/inlines2
Draft

refactor(inlines): deduplicate field types, add InlineSpec, typed advice#1371
0xAndoroid wants to merge 6 commits intomainfrom
ref/inlines2

Conversation

@0xAndoroid
Copy link
Copy Markdown
Collaborator

Summary

  • Generic Secp256k1Field<C> and GrumpkinField<C> eliminate ~550 lines of Fq/Fr duplication
  • InlineSpec trait connects reference implementations to test harness for formal verification
  • Typed Advice associated type on InlineOp enforces advice contracts at compile time

Stacked on #1343.

Changes

Field element deduplication (trait-based, no macros)

  • Secp256k1FieldConfig trait + generic Secp256k1Field<C> replaces duplicate Fq/Fr structs
  • GrumpkinFieldConfig trait + generic GrumpkinField<C> same pattern
  • ECField trait uses Add/Sub/Mul/Neg operator supertraits; method-based API removed
  • secp256k1_mulq_op! macro replaced with explicit newtypes

Shared helpers

  • load_u64_range, store_u64_range, load_u32_range, load_u32_range_paired, store_u32_range_paired on InstrAssemblerExt
  • Shared blake3_g() free function deduplicates Blake3/Keyed64 G-functions
  • inline_sequence() renamed to build() across all builders

InlineSpec trait

  • New InlineSpec trait in jolt-inlines-sdk with verify() and proptest() helpers
  • All exec.rs files replaced with spec.rs implementing InlineSpec
  • Specs: Sha256Compression, Keccak256Permutation, Blake3Compression, Blake3Keyed64, Blake2b, BigintMul256

Typed advice

  • InlineOp::Advice associated type with InlineAdvice trait
  • Hash inlines: type Advice = (); curve inlines: type Advice = VecDeque<u64>
  • __submit_inline_op! macro bridges typed advice to erased InlineRegistration

Testing

All 63 tests across 7 inline crates pass. Clippy clean in both host and host,zk modes.

cargo nextest run -p jolt-inlines-{sha2,keccak256,blake3,blake2,bigint,secp256k1,grumpkin} --features host
cargo clippy -p jolt-core --features host,zk -- -D warnings

@0xAndoroid 0xAndoroid changed the base branch from ref/inlines to main March 25, 2026 20:08
@0xAndoroid 0xAndoroid changed the base branch from main to ref/inlines March 25, 2026 20:09
@0xAndoroid 0xAndoroid force-pushed the ref/inlines2 branch 4 times, most recently from f188dfc to 439a4ab Compare March 25, 2026 21:37
Base automatically changed from ref/inlines to main March 26, 2026 21:34
…hared helpers

- Generic Secp256k1Field<C> replaces duplicate Secp256k1Fq/Secp256k1Fr structs
- Generic GrumpkinField<C> replaces duplicate GrumpkinFq/GrumpkinFr structs
- ECField trait uses Add/Sub/Mul/Neg operator supertraits; remove method-based API
- Add load/store range helpers to InstrAssemblerExt (load_u64_range, etc.)
- Extract shared blake3_g() free function from duplicate g_function impls
- Replace secp256k1_mulq_op! macro with explicit newtypes
- Rename inline_sequence() to build() for consistency across all builders
- Remove stale doc comment on Keccak256SequenceBuilder
…pec.rs

- Add InlineSpec trait to jolt-inlines-sdk with verify() and proptest() helpers
- Migrate all 5 exec.rs files to spec.rs with InlineSpec implementations:
  - Sha256CompressionSpec, Sha256CompressionInitialSpec
  - Keccak256PermutationSpec
  - Blake3CompressionSpec, Blake3Keyed64CompressionSpec
  - Blake2bCompressionSpec
  - BigintMul256Spec
- Each spec has typed Input/Output and connects reference impl to test harness
- Backward-compatible free functions preserved for sdk.rs host paths
- InlineOp now requires 'type Advice: InlineAdvice' (no default)
- InlineAdvice trait with into_values() bridges typed advice to VecDeque<u64>
- Hash inlines: type Advice = () (no advice needed)
- Secp256k1/grumpkin inlines: type Advice = VecDeque<u64>
- __submit_inline_op! macro wraps build_advice with .into_values()
- build_advice return type matches Advice (removes Option wrapper)
…ruct

- InlineSpec: InlineOp supertrait — no separate spec structs
- Implement InlineSpec directly on InlineOp structs (Sha256Compression, etc.)
- Remove free functions from spec modules; callers use Struct::reference()
- Keep internal helpers (execute_keccak_f, g, round, etc.) as pub(crate)
@socket-security
Copy link
Copy Markdown

socket-security bot commented Mar 26, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedalloy-eips@​1.8.2 ⏵ 1.7.310010093100100
Updatedenv_logger@​0.11.10 ⏵ 0.11.99910093100100

View full report

- Default instruction() on InlineSpec using Self::OPCODE/FUNCT3/FUNCT7
  from InlineOp, remove redundant overrides in all spec.rs files
- Rename message_words to w in blake2 spec reference impl
- Delete blake3 test_utils.rs, inline helpers into test modules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant