Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ca16af0
feat: enforce min max fee
MarcosNicolau Jul 3, 2025
4354573
feat: enforce min bump in replacement messages
MarcosNicolau Jul 3, 2025
6568098
fix: underproced proof error message
MarcosNicolau Jul 3, 2025
a029194
fix: min bump calculation
MarcosNicolau Jul 3, 2025
d4981dd
feat: move constants to config file
MarcosNicolau Jul 4, 2025
6f32282
chore: address clippy warnings
MarcosNicolau Jul 4, 2025
546aba9
perf: drop latest_block_gas_price lock early
MarcosNicolau Jul 10, 2025
f534b84
chore: address juli's comments
MarcosNicolau Jul 10, 2025
e2e396e
fix: config file new fields syntax
MarcosNicolau Jul 10, 2025
b2f26b0
chore: rename proofs_to_cover_min_max_fee for amount_of_proofs_for_mi…
MarcosNicolau Jul 10, 2025
02e456b
chore: log min max fee in waiting for batch to finish
MarcosNicolau Jul 10, 2025
45b8a23
feat: compute min max fee only once
MarcosNicolau Jul 10, 2025
63ea290
chore: entry for entry_to_replace name in replacament message
MarcosNicolau Jul 10, 2025
9fdcd5e
fix: logs
JuArce Jul 10, 2025
f3cb180
docs: add replacement rules
JuArce Jul 11, 2025
999d9b0
Merge branch 'staging' into feat/min-max-fee-min-bump
MauroToscano Aug 20, 2025
a2045cf
Merge
MauroToscano Aug 25, 2025
201c366
Merge
MauroToscano Aug 25, 2025
718cd26
Merge branch 'staging' into feat/min-fee-merge
MauroToscano Aug 27, 2025
cb10892
Remove duplicated check
MauroToscano Aug 27, 2025
dacfb75
Remove extra newlines
MauroToscano Aug 27, 2025
0e33365
Rename and standarize arguments of estimate functions
MauroToscano Aug 27, 2025
cec54d3
update batcher circom verifier to accept raw pub inputs
MarcosNicolau Aug 28, 2025
c22391e
update operator circom verifier to accept raw pub inputs
MarcosNicolau Aug 28, 2025
ddb130b
feat: sdk and cli parse input.json to the raw numbers
MarcosNicolau Aug 28, 2025
a6696d0
feat: circom example rust program
MarcosNicolau Aug 28, 2025
d1be60a
feat: circom example circuits
MarcosNicolau Aug 28, 2025
cf6ae41
feat: circom example contract
MarcosNicolau Aug 28, 2025
c700281
feat: circom example readme
MarcosNicolau Aug 28, 2025
81efbd2
chore: update fork to org
MarcosNicolau Aug 29, 2025
ee4dfdf
feat: receive vk on deployment
MarcosNicolau Aug 29, 2025
1ad320a
feat: compute vk commitment script
MarcosNicolau Aug 29, 2025
a97d885
chore: pass vk commitment in deploy
MarcosNicolau Aug 29, 2025
1442040
feat: load config from env
MarcosNicolau Aug 29, 2025
a37d7ef
chore: makefile targets
MarcosNicolau Aug 29, 2025
c14a9c2
docs: how to run example
MarcosNicolau Aug 29, 2025
2b7baa2
chore: update go mod to point to main branch commit
MarcosNicolau Aug 29, 2025
6067e86
fix: avoid panic on invalid pub inputs length
MarcosNicolau Aug 29, 2025
adb4430
Merge branch 'fix/circom-public-inputs' into feat/circom-example
MarcosNicolau Aug 29, 2025
435315b
docs: missing step
MarcosNicolau Aug 29, 2025
0f46e92
Explain why the replacement in the go.mod
MauroToscano Aug 29, 2025
be11294
chore: no pub input proof
MarcosNicolau Aug 29, 2025
31b79ff
fix: docker no pub input circom target
MarcosNicolau Aug 29, 2025
70e398a
Merge branch 'fix/circom-public-inputs' into feat/circom-example
MarcosNicolau Aug 29, 2025
933577a
chore: forge-std submodule
MarcosNicolau Aug 29, 2025
45adcb9
Update examples/circom/.env.example
JuArce Aug 29, 2025
d56db1d
Merge branch 'fix/circom-public-inputs' of github.com:yetanotherco/al…
MauroToscano Aug 29, 2025
397ec6d
chore: update docker sent proofs
MarcosNicolau Aug 30, 2025
22f5049
chore: update docker sent proofs
MarcosNicolau Aug 30, 2025
d5505ee
Merge branch 'fix/circom-public-inputs' of github.com:yetanotherco/al…
MauroToscano Sep 1, 2025
1ab0936
Merge branch 'fix/circom-public-inputs' into feat/circom-example
MauroToscano Sep 1, 2025
37c0835
Merge
MauroToscano Sep 1, 2025
8471ad3
Fmt
MauroToscano Sep 1, 2025
074a491
Update README.md
MarcosNicolau Sep 1, 2025
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@
[submodule "examples/l2/contracts/lib/forge-std"]
path = examples/l2/contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "examples/circom/contracts/lib/forge-std"]
path = examples/circom/contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
6 changes: 6 additions & 0 deletions crates/batcher/go_verifiers_lib/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ module verifier

go 1.22.3

replace github.com/iden3/go-rapidsnark => github.com/yetanotherco/go-rapidsnark v0.0.0-20250829135025-99f9f6b11ecc

replace github.com/iden3/go-rapidsnark/types => github.com/yetanotherco/go-rapidsnark/types v0.0.0-20250829135025-99f9f6b11ecc

replace github.com/iden3/go-rapidsnark/verifier => github.com/yetanotherco/go-rapidsnark/verifier v0.0.0-20250829135025-99f9f6b11ecc

require (
github.com/consensys/gnark v0.12.0
github.com/consensys/gnark-crypto v0.17.0
Expand Down
8 changes: 4 additions & 4 deletions crates/batcher/go_verifiers_lib/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/iden3/go-iden3-crypto v0.0.17 h1:NdkceRLJo/pI4UpcjVah4lN/a3yzxRUGXqxbWcYh9mY=
github.com/iden3/go-iden3-crypto v0.0.17/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E=
github.com/iden3/go-rapidsnark/types v0.0.3 h1:f0s1Qdut1qHe1O67+m+xUVRBPwSXnq5j0xSrBi0jqM4=
github.com/iden3/go-rapidsnark/types v0.0.3/go.mod h1:ApgcaUxKIgSRA6fAeFxK7p+lgXXfG4oA2HN5DhFlfF4=
github.com/iden3/go-rapidsnark/verifier v0.0.5 h1:J7y0ovrEjDQoWtZmlrp4tgGng1A9faMeYsQH4igAEqA=
github.com/iden3/go-rapidsnark/verifier v0.0.5/go.mod h1:KgL3Yr9NehlFDI4EIWVLE3UDUi8ulyjbp7HcXSBfiGI=
github.com/ingonyama-zk/icicle/v3 v3.1.1-0.20241118092657-fccdb2f0921b h1:AvQTK7l0PTHODD06PVQX1Tn2o29sRIaKIDOvTJmKurY=
github.com/ingonyama-zk/icicle/v3 v3.1.1-0.20241118092657-fccdb2f0921b/go.mod h1:e0JHb27/P6WorCJS3YolbY5XffS4PGBuoW38OthLkDs=
github.com/leanovate/gopter v0.2.11 h1:vRjThO1EKPb/1NsDXuDrzldR28RLkBflWYcU9CvzWu4=
Expand All @@ -50,6 +46,10 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/yetanotherco/go-rapidsnark/types v0.0.0-20250829135025-99f9f6b11ecc h1:9d0e1bmYz6pv0p1V8zrx7jALDdgAIZ8bZWSCDxemgE4=
github.com/yetanotherco/go-rapidsnark/types v0.0.0-20250829135025-99f9f6b11ecc/go.mod h1:ApgcaUxKIgSRA6fAeFxK7p+lgXXfG4oA2HN5DhFlfF4=
github.com/yetanotherco/go-rapidsnark/verifier v0.0.0-20250829135025-99f9f6b11ecc h1:JLSkcXpSuKb4fzYMF1qNM0nO2oysvOkpNeCSQunTtUA=
github.com/yetanotherco/go-rapidsnark/verifier v0.0.0-20250829135025-99f9f6b11ecc/go.mod h1:KgL3Yr9NehlFDI4EIWVLE3UDUi8ulyjbp7HcXSBfiGI=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
Expand Down
50 changes: 40 additions & 10 deletions crates/batcher/go_verifiers_lib/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import "C"
import (
"bytes"
"encoding/json"
"github.com/iden3/go-rapidsnark/types"
"github.com/iden3/go-rapidsnark/verifier"
"fmt"
"math/big"

"log"
"unsafe"
Expand All @@ -24,6 +24,8 @@ import (
"github.com/consensys/gnark/backend/groth16"
"github.com/consensys/gnark/backend/plonk"
"github.com/consensys/gnark/backend/witness"
"github.com/iden3/go-rapidsnark/types"
"github.com/iden3/go-rapidsnark/verifier"
)

func listRefToBytes(listRef C.ListRef) []byte {
Expand Down Expand Up @@ -122,6 +124,20 @@ func verifyGnarkGroth16Proof(proofBytesRef C.ListRef, pubInputBytesRef C.ListRef
return err == nil
}

func bytesToBigInts32(b []byte) ([]*big.Int, error) {
if len(b)%32 != 0 {
return nil, fmt.Errorf("invalid length")
}

inputs := make([]*big.Int, 0, len(b)/32)
for i := 0; i < len(b); i += 32 {
chunk := b[i : i+32]
bi := new(big.Int).SetBytes(chunk)
inputs = append(inputs, bi)
}
return inputs, nil
}

//export VerifyCircomGroth16ProofBN256
func VerifyCircomGroth16ProofBN256(proofBytesRef C.ListRef, pubInputBytesRef C.ListRef, verificationKeyBytesRef C.ListRef) bool {
proofBytes := listRefToBytes(proofBytesRef)
Expand All @@ -131,26 +147,40 @@ func VerifyCircomGroth16ProofBN256(proofBytesRef C.ListRef, pubInputBytesRef C.L
proofData := &types.ProofData{}
err := json.Unmarshal(proofBytes, proofData)
if err != nil {
log.Printf("Could not marshal proof: %v", err)
log.Printf("Could not unmarshal proof: %v", err)
return false
}

parsedProofData, err := verifier.ParseProofData(*proofData)
if err != nil {
log.Printf("Could not parse proof: %v", err)
return false
}

var vkStr verifier.VkJSON
err = json.Unmarshal(verificationKeyBytes, &vkStr)
if err != nil {
log.Printf("Could not unmarshal vk: %v", err)
return false
}

var pubSignals []string
err = json.Unmarshal(pubInputBytes, &pubSignals)
vk, err := verifier.ParseVK(vkStr)
if err != nil {
log.Printf("Error unmarshaling JSON: %v", err)
log.Printf("Could not parse vk: %v", err)
return false
}

zkProof := types.ZKProof{
Proof: proofData,
PubSignals: pubSignals,
inputs, err := bytesToBigInts32(pubInputBytes)
if err != nil {
log.Printf("Could not parse pub inputs: %v", err)
return false
}

err = verifier.VerifyGroth16(zkProof, verificationKeyBytes)
err = verifier.VerifyRaw(vk, parsedProofData, inputs)
if err != nil {
log.Printf("Could not verify Groth16 proof: %v", err)
return false
}

return true
}
15 changes: 11 additions & 4 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,10 +926,17 @@ fn verification_data_from_args(args: &SubmitArgs) -> Result<VerificationData, Su
"--vk",
args.verification_key_file_name.clone(),
)?);
pub_input = Some(read_file_option(
"--public_input",
args.pub_input_file_name.clone(),
)?);
let pub_input_file =
read_file_option("--public_input", args.pub_input_file_name.clone())?;
let pub_inputs: Vec<String> = serde_json::from_slice(&pub_input_file)
.map_err(|e| SubmitError::MissingRequiredParameter(e.to_string()))?;

let decode_inputs = aligned_sdk::common::utils::encode_circom_pub_inputs(&pub_inputs)
.map_err(|_| {
SubmitError::MissingRequiredParameter("Invalid public inputs".into())
})?;

pub_input = Some(decode_inputs);
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/sdk/src/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod constants;
pub mod errors;
pub mod types;
pub mod utils;
32 changes: 32 additions & 0 deletions crates/sdk/src/common/utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use ethers::{abi::ethereum_types::FromDecStrErr, types::U256};

/// Encodes Circom public inputs into a single byte vector.
///
/// Circom normally outputs public inputs as a JSON array of strings, where each
/// entry is actually a big integer represented in decimal. For example:
///
/// ```json
/// { "pubInputs": ["123", "456", "789"] }
/// ```
///
/// For on-chain usage (e.g. in Solidity), working with JSON is inefficient.
/// Instead, we prefer the **raw form**: each input is converted to a 32-byte
/// big-endian encoding of the integer, concatenated together. This makes it
/// simple to compute commitments and verify proofs on-chain, since the contract
/// receives a compact `bytes` array rather than parsing JSON.
///
/// Each input must fit in 32 bytes (i.e. < 2^256).
pub fn encode_circom_pub_inputs(input: &[String]) -> Result<Vec<u8>, FromDecStrErr> {
let mut out = Vec::with_capacity(input.len() * 32);

for s in input {
// parse as decimal (base 10). Use from_str_radix(s, 16) if they're hex.
let n = U256::from_dec_str(s)?;
let mut bytes = [0u8; 32];
n.to_big_endian(&mut bytes);

out.extend_from_slice(&bytes);
}

Ok(out)
}
5 changes: 5 additions & 0 deletions examples/circom/.env.devnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ETH_RPC_URL=http://localhost:8545
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
# Deploy the contract with make deploy_contract_devnet
FIBONACCI_CONTRACT_ADDRESS=<FIBONACCI_CONTRACT_ADDRESS>
NETWORK=devnet
6 changes: 6 additions & 0 deletions examples/circom/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ETH_RPC_URL=<RPC_URL>
# Make sure it has founds on Aligned
Comment thread
JuArce marked this conversation as resolved.
Outdated
PRIVATE_KEY=<PRIVATE_KEY>
# Deploy the contract with make deploy_contract_devnet
FIBONACCI_CONTRACT_ADDRESS=<FIBONACCI_CONTRACT_ADDRESS>
NETWORK=<devnet|holesky|holeksy-stage|mainnet>
1 change: 1 addition & 0 deletions examples/circom/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading