Implementing Pedersen commitments on the BLS12-381 curve using arkworks — Rust's ZK ecosystem. A minimal example showing the commitment scheme and its homomorphic property.
arkworks ecosystem
arkworks is the standard Rust library ecosystem for zero-knowledge proofs. It provides elliptic curve arithmetic, finite field operations, R1CS constraint systems, and proof system implementations.
Minimal Pedersen on BLS12-381
use ark_bls12_381::G1Projective as G;
use ark_ec::Group;
use ark_std::UniformRand;
fn pedersen_commit(
v: u64,
r: ark_bls12_381::Fr,
g: G,
h: G,
) -> G {
// C = v*G + r*H
g.mul_bigint(&[v]) + h * r
}
fn main() {
let mut rng = ark_std::test_rng();
let g = G::generator();
let h = G::rand(&mut rng);
let r = ark_bls12_381::Fr::rand(&mut rng);
let c1 = pedersen_commit(5, r, g, h);
let c2 = pedersen_commit(3, r, g, h);
// Homomorphic: c1 + c2 commits to 8
}
Why BLS12-381?
The BLS12-381 curve provides a 255-bit scalar field — enough for 128-bit security. It supports efficient pairings (needed for some proof systems) and has wide ecosystem support across Ethereum, Zcash, and Filecoin.
Homomorphic property
Because Pedersen commitments are additively homomorphic, you can compute on committed values without revealing them. C(v₁) + C(v₂) = C(v₁ + v₂) — this is the foundation for confidential transactions.
← Collapse