Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
181 commits
Select commit Hold shift + click to select a range
2a51f3d
chore: release SP1 v5.2.4 (#2517)
leruaa Dec 15, 2025
69eaac7
PVUGC initial check-in
Dec 18, 2025
5c8a31b
add paramgen
Dec 18, 2025
c736dae
add test-artifacts
Dec 18, 2025
2895210
Update main.rs
Dec 18, 2025
8a3fc81
Update lib.rs
Dec 18, 2025
2fec903
standardize around icicle pos2
Dec 19, 2025
75d7674
Update babybear.go
Dec 19, 2025
4fb24c3
Update poseidon2_bls12377_rc3.rs
Dec 19, 2025
65df352
Update poseidon2_bls12377_rc3.rs
Dec 19, 2025
633c10a
add missing bins
Dec 19, 2025
bd324ca
assert both sets of constants are same
Dec 19, 2025
dd77f21
link in go
Dec 19, 2025
1917277
fix baby bear MSB truncation
Dec 19, 2025
592ddd2
fix bit-decomposition in split_32
Dec 19, 2025
8cf8a3f
Update challenger.rs
Dec 19, 2025
6e30613
MSB back to 3 bits again
Dec 19, 2025
8159704
Update lib.rs
Dec 19, 2025
2debf02
Update lib.rs
Dec 19, 2025
cf7a062
Update verify.rs
Dec 19, 2025
c8b1215
modulus width of fr377 is 253
Dec 19, 2025
155a726
Update lib.rs
Dec 19, 2025
a0f0736
ToBinary enforces reducedness by default
Dec 19, 2025
ffe5a8c
Update challenger.rs
Dec 19, 2025
4e3ee22
use groth backend in tests
Dec 19, 2025
8bd70b1
Update tests.rs
Dec 19, 2025
a8d47f3
make gorth backend datadir aware
Dec 19, 2025
7aa8bf5
test injective mod proof of fr377
Dec 19, 2025
3e791c1
fix packing re fr377
Dec 19, 2025
18d13c0
revert test
Dec 19, 2025
405ce2b
Revert "make gorth backend datadir aware"
Dec 19, 2025
cedcf91
vendor p3-field 0.2.3-succinct
Dec 19, 2025
dd3f53e
update reduce_32 in p3-field helpers
Dec 19, 2025
d29c9ec
update cargo
Dec 19, 2025
17af127
Update Cargo.toml
Dec 19, 2025
1439241
update to our p3-field
Dec 19, 2025
ecd5c02
Update tests.rs
Dec 19, 2025
284e3eb
Update tests.rs
Dec 19, 2025
513618c
align fr377 with 252 bit masking (injective gaurantee)
Dec 22, 2025
fe40816
add R1CS compiler backend for DslIr
Jan 5, 2026
f103255
lift to frog for LF+
Jan 12, 2026
2c1388a
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
0b5906d
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
b5a559c
lift true_mul_only
Jan 12, 2026
5718912
carry count for poseidon
Jan 12, 2026
ae73793
cleanup
Jan 12, 2026
6b2a11d
dump witness
Jan 12, 2026
966a79a
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
8e47b4c
Revert "Update dump_shrink_verify_constraints.rs"
Jan 12, 2026
5f7ba98
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
9506610
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
3c0b498
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
cc4ba5f
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
a0084b4
fix lift_r1cs_to_lf_with_linear_carries_and_witness panic
Jan 12, 2026
0fd6569
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
d03c1f8
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
2ce2093
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
4a137fd
parallel lift
Jan 12, 2026
6a06e58
Update lf.rs
Jan 12, 2026
bdea5b3
write with buffer
Jan 12, 2026
dc847ee
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
30dfdb8
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
4381c06
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
06d5c61
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
399f0ba
Update lf.rs
Jan 12, 2026
48409cf
Update lf.rs
Jan 12, 2026
82ea42b
add dbg for unsat row
Jan 12, 2026
d4fb021
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
cbf5815
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
cef7d1e
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
2e10da6
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
37a976f
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
f8cd5b8
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
adc0134
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
54cb571
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
5a9866e
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
5356455
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
ec89a73
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
58e98f7
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
7830bbd
Update dump_shrink_verify_constraints.rs
Jan 12, 2026
dbacca8
Update dump_shrink_verify_constraints.rs
Jan 13, 2026
2b4ac09
deterministic compiler
Jan 13, 2026
0275251
Update compiler.rs
Jan 13, 2026
fb057e6
Update dump_shrink_verify_constraints.rs
Jan 13, 2026
08b5edf
Update dump_shrink_verify_constraints.rs
Jan 13, 2026
9f37139
Update compiler.rs
Jan 13, 2026
2435131
Update compiler.rs
Jan 13, 2026
a5416ed
Update compiler.rs
Jan 13, 2026
c25f53e
Update compiler.rs
Jan 13, 2026
dfd6e73
Update compiler.rs
Jan 13, 2026
797a008
Update compiler.rs
Jan 13, 2026
3c37fc8
Update compiler.rs
Jan 13, 2026
4e4f985
Update compiler.rs
Jan 13, 2026
e15f5c9
Update compiler.rs
Jan 13, 2026
d2122b3
Update compiler.rs
Jan 13, 2026
3c1cff0
Update compiler.rs
Jan 13, 2026
4604706
Update poseidon2.rs
Jan 13, 2026
d3f5e7e
Update poseidon2.rs
Jan 13, 2026
7e21db3
Update compiler.rs
Jan 13, 2026
d4d3047
Update compiler.rs
Jan 13, 2026
1a942a5
Update compiler.rs
Jan 13, 2026
65d4f79
Update dump_shrink_verify_constraints.rs
Jan 13, 2026
6acf9b0
Update dump_shrink_verify_constraints.rs
Jan 13, 2026
ff8c20b
Update compiler.rs
Jan 13, 2026
234f365
Update compiler.rs
Jan 13, 2026
22432a2
Update compiler.rs
Jan 13, 2026
d9240b1
Update compiler.rs
Jan 13, 2026
0bf8219
Update dump_shrink_verify_constraints.rs
Jan 13, 2026
872bdc4
Update compiler.rs
Jan 13, 2026
299c5ef
Update compiler.rs
Jan 13, 2026
cbe776c
Update compiler.rs
Jan 13, 2026
3f63c8e
Update compiler.rs
Jan 13, 2026
561ca17
Update compiler.rs
Jan 13, 2026
b5e0f94
Update compiler.rs
Jan 13, 2026
4096c31
Update compiler.rs
Jan 13, 2026
527c6b8
Update compiler.rs
Jan 13, 2026
dfa675e
Update compiler.rs
Jan 13, 2026
be2f2fa
Update compiler.rs
Jan 13, 2026
67893d1
Update compiler.rs
Jan 13, 2026
c70c0db
Update compiler.rs
Jan 13, 2026
07eae85
Update compiler.rs
Jan 13, 2026
3f0ef30
Update compiler.rs
Jan 13, 2026
fc0fae5
Update compiler.rs
Jan 13, 2026
b153384
Update compiler.rs
Jan 13, 2026
35cc78f
Update compiler.rs
Jan 13, 2026
9b38e4e
Update compiler.rs
Jan 13, 2026
c904ada
cleanup
Jan 13, 2026
2458f68
r1cs audit
Jan 13, 2026
fb0c88b
Update dump_shrink_verify_constraints.rs
Jan 13, 2026
fd23499
fix shape only merkle tree height
Jan 16, 2026
fc22af7
Update dump_shrink_verify_constraints.rs
Jan 16, 2026
f56ad92
Update dump_shrink_verify_constraints.rs
Jan 16, 2026
09d18f0
audit_no_wrap_frog64_lifted
Jan 16, 2026
7969bd2
Update dump_shrink_verify_constraints.rs
Jan 16, 2026
5feecd8
Update dump_shrink_verify_constraints.rs
Jan 16, 2026
d75bbd6
Update dump_shrink_verify_constraints.rs
Jan 16, 2026
b1f84a6
Update dump_shrink_verify_constraints.rs
Jan 16, 2026
4ac2351
Public inputs are counted but not made contiguous + Enforce BabyBear …
Jan 16, 2026
a5e4ff0
add edge case in 31 bit check
Jan 16, 2026
c76a22c
hardening
Jan 16, 2026
a19fb2e
hardening v2
Jan 16, 2026
ca88c1e
Update dump_shrink_verify_constraints.rs
Jan 16, 2026
ff339ef
Revert "Update dump_shrink_verify_constraints.rs"
Jan 16, 2026
1ecae6e
dump out witness package
Jan 17, 2026
b6aa796
Update dump_shrink_verify_constraints.rs
Jan 17, 2026
aefc1f7
Update dump_shrink_verify_constraints.rs
Jan 17, 2026
f162374
Update dump_shrink_verify_constraints.rs
Jan 17, 2026
ab7af08
Update dump_shrink_verify_constraints.rs
Jan 17, 2026
b0f8f90
Update dump_shrink_verify_constraints.rs
Jan 17, 2026
796e5dc
public input committing
Jan 17, 2026
50bbe68
Update dump_shrink_verify_constraints.rs
Jan 17, 2026
42a057a
Update dump_shrink_verify_constraints.rs
Jan 17, 2026
ac3c359
Update dump_shrink_verify_constraints.rs
Jan 17, 2026
9b02901
Update dump_shrink_verify_constraints.rs
Jan 17, 2026
3fbe040
export digest
Jan 20, 2026
37e3a59
Update compress.rs
Jan 20, 2026
7461feb
Update compress.rs
Jan 20, 2026
3726e33
Update mod.rs
Jan 20, 2026
d15590f
Update mod.rs
Jan 20, 2026
aa3751f
Update mod.rs
Jan 20, 2026
a394652
Update dump_shrink_verify_constraints.rs
Jan 20, 2026
137a54d
Update compress.rs
Jan 20, 2026
2b639e3
compile
Jan 20, 2026
2618fa7
Update dump_shrink_verify_constraints.rs
Jan 20, 2026
9dba80c
Update dump_shrink_verify_constraints.rs
Jan 20, 2026
3dff033
Update dump_shrink_verify_constraints.rs
Jan 20, 2026
18f468a
Update dump_shrink_verify_constraints.rs
Jan 20, 2026
eff5619
Update dump_shrink_verify_constraints.rs
Jan 20, 2026
543dc5f
Update dump_shrink_verify_constraints.rs
Jan 20, 2026
d558b25
Update dump_shrink_verify_constraints.rs
Jan 20, 2026
41d33f6
Create PVUGC.code-workspace
Jan 20, 2026
5fb2505
Update dump_shrink_verify_constraints.rs
Jan 20, 2026
48bbb86
Update dump_shrink_verify_constraints.rs
Jan 20, 2026
2a717ef
Update dump_shrink_verify_constraints.rs
Jan 20, 2026
f99f545
Update root.rs
Jan 20, 2026
885ace6
revert
Jan 20, 2026
d7f45f3
Update root.rs
Jan 20, 2026
06b9bb4
export digest
Jan 20, 2026
cf6d272
api rework
Jan 21, 2026
461b13a
Update shrink_export.rs
Jan 21, 2026
52a1d4c
Fix: Align public-input checks with digest-only export
Jan 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,117 changes: 1,095 additions & 1,022 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ p3-field = { version = "=0.2.3-succinct" }
p3-air = { version = "=0.2.3-succinct" }
p3-baby-bear = { version = "=0.2.3-succinct" }
p3-bn254-fr = { version = "=0.2.3-succinct" }
p3-bls12-377-fr = { path = "crates/p3-bls12-377-fr", version = "0.2.3-succinct-pvugc.0" }
p3-poseidon2 = { version = "=0.2.3-succinct" }
p3-symmetric = { version = "=0.2.3-succinct" }
p3-dft = { version = "=0.2.3-succinct" }
Expand Down Expand Up @@ -120,3 +121,4 @@ print_stdout = "deny"

[patch.crates-io]
sp1-lib = { path = "crates/zkvm/lib" }
p3-field = { git = "https://github.com/syscoin/p3-field", branch = "main" }
110 changes: 110 additions & 0 deletions PVUGC_FORK.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# SP1 Fork for PVUGC (BLS12-377)

This is a minimal fork of [SP1](https://github.com/succinctlabs/sp1) that changes the final Groth16 wrapper from BN254 to BLS12-377 for PVUGC integration.

## Changes Made

### 0. `p3-field` `reduce_32` packing base (Fr377 soundness / consistency)

SP1’s outer recursion uses the Plonky3 “multi-field” sponge/challenger (`p3-symmetric` /
`p3-challenger`) which packs BabyBear limbs into the native field via `p3_field::reduce_32`.
After migrating the Groth16 wrapper to **BLS12-377 Fr (~252 bits)**, the historical base \(2^{32}\)
packing is **not injective** under our limb bounds (BabyBear limbs are < \(2^{31}\)), and it can also cause native-vs-circuit transcript mismatches.

We therefore vendor `p3-field` and patch `reduce_32` to use **base \(2^{31}\)** so:
- the packing is injective under SP1’s limb bounds for Fr377, and
- the **native** prover transcript matches the **circuit** transcript.

This is related to the general “multi-field challenger packing/bias” audit themes (see `audits/rkm0959.md`).

### 1. `crates/recursion/gnark-ffi/go/sp1/build.go`

Modified the existing `BuildGroth16(...)` path to compile and set up the Groth16 circuit over **BLS12-377** (instead of BN254):

```go
// Key change: ecc.BN254 → ecc.BLS12_377
r1cs, err := frontend.Compile(ecc.BLS12_377.ScalarField(), r1cs.NewBuilder, &circuit)
```

### 2. `crates/recursion/gnark-ffi/go/sp1/prove.go`

Modified the existing `ProveGroth16(...)` path to use **BLS12-377** (including its in-process caches):

```go
var globalR1cs constraint.ConstraintSystem = groth16.NewCS(ecc.BLS12_377)
var globalPk groth16.ProvingKey = groth16.NewProvingKey(ecc.BLS12_377)
```

### 3. `crates/recursion/gnark-ffi/go/main.go`

The CGO exports remain (historically) named `*Bn254` for compatibility, but they invoke the Groth16 path which is now **BLS12-377**:
- `ProveGroth16Bn254`
- `BuildGroth16Bn254`
- `FreeGroth16Bn254Proof`

## What's Unchanged

- **SP1 Core**: All BabyBear STARK proving remains unchanged
- **Recursion layers**: Reduce, Compress, Shrink - all unchanged
- **Circuit logic**: The wrapper circuit verifies the same SP1 recursive proof
- **Constraint IR**: The opcodes and simulation logic are identical

## Poseidon2 (outer recursion) parameters

- **Field**: BLS12-377 scalar field (Fr)
- **Width**: \(t = 3\)
- **S-box exponent**: \(\alpha = 11\)
- **Rounds**: \(R_F = 8\), \(R_P = 37\) (ICICLE instance)
- **Round constants (RC3)**:
- Rust: `crates/recursion/core/src/stark/poseidon2_bls12377_rc3.rs`
- Go: `crates/recursion/gnark-ffi/go/sp1/poseidon2/constants.go` (inlined in `init_rc3()`)

## Usage

### Build the Circuit (One-time setup)

```bash
# Generate Groth16 artifacts for BLS12-377
BuildGroth16("/path/to/data")
```

### Prove

```bash
# Generate BLS12-377 Groth16 proof
proof := ProveGroth16("/path/to/data", "/path/to/witness.json")
```

### In Rust (PVUGC)

```rust
use pvugc::sp1_bridge::{
decode_sp1_proof_hex,
parse_gnark_proof_bls12_377,
};

// Decode SP1's hex output
let proof_bytes = decode_sp1_proof_hex(&sp1_proof.raw_proof)?;
let proof = parse_gnark_proof_bls12_377(&proof_bytes)?;

// Use with PVUGC outer circuit
```

#### Note on proof/VK wire formats

- This fork standardizes on gnark's **`WriteRawTo` / `ReadFrom`** encoding for Groth16 proof + verifying key.
- `raw_proof` is the hex encoding of gnark `(*Proof).WriteRawTo(...)`.
- `encoded_proof` is unused for Groth16(BLS12-377) and is left empty (no Solidity encoding).

## Upstream Tracking

- **Base**: Forked from upstream SP1
- **SP1 repo**: https://github.com/succinctlabs/sp1

## Security Notes

1. **New trusted setup required**: BLS12-377 requires its own trusted setup
2. **VK changes**: The verification key will be different from BN254
3. **Proof format**: Same structure, different curve points


26 changes: 26 additions & 0 deletions crates/p3-bls12-377-fr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "p3-bls12-377-fr"
version = "0.2.3-succinct-pvugc.0"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Plonky3 field wrapper for the BLS12-377 scalar field (PVUGC local crate)."

[lib]
name = "p3_bls12_377_fr"
path = "src/lib.rs"

[dependencies]
ff = { version = "0.13", features = ["derive", "derive_bits"] }
num-bigint = { version = "0.4.3", default-features = false }
p3-field = { version = "=0.2.3-succinct" }
p3-poseidon2 = { version = "=0.2.3-succinct" }
p3-symmetric = { version = "=0.2.3-succinct" }
rand = "0.8.5"
serde = { version = "1.0", features = ["derive"], default-features = false }

[dev-dependencies]
p3-field-testing = { version = "=0.2.3-succinct" }
num-traits = "0.2.16"
serde_json = "1.0.113"


Loading