You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
arnaucube 2c4a5c6089 Add Lagrange Interpolation & Zero polynomial 3 years ago
.github/workflows Add GHA 3 years ago
.golangci.yml Add initial implementation, simple flow works 3 years ago
LICENSE Init 3 years ago
README.md Add usage example at README.md 3 years ago
arithmetic.go Add Lagrange Interpolation & Zero polynomial 3 years ago
arithmetic_test.go Add Lagrange Interpolation & Zero polynomial 3 years ago
go.mod Add initial implementation, simple flow works 3 years ago
go.sum Add initial implementation, simple flow works 3 years ago
kzg.go Add usage example at README.md 3 years ago
kzg_test.go Add usage example at README.md 3 years ago

README.md

kzg-commitments-study GoDoc Go Report Card Test

Doing this to study and learn KZG commitments, do not use in production. More details at https://arnaucube.com/blog/kzg-commitments.html .

Thanks to Dankrad Feist, Alin Tomescu, Tom Walton-Pocock for their articles, which helped me understand a bit the KZG Commitments.

Usage

// p(x) = x^3 + x + 5
p := []*big.Int{
	big.NewInt(5),
	big.NewInt(1), // x^1
	big.NewInt(0), // x^2
	big.NewInt(1), // x^3
}
assert.Equal(t, "1x³ + 1x¹ + 5", PolynomialToString(p))

// TrustedSetup
ts, err := NewTrustedSetup(p)
assert.Nil(t, err)

// Commit
c := Commit(ts, p)

// p(z)=y --> p(3)=35
z := big.NewInt(3)
y := big.NewInt(35)

// z & y: to prove an evaluation p(z)=y
proof, err := EvaluationProof(ts, p, z, y)
assert.Nil(t, err)

// verification
v := Verify(ts, c, proof, z, y)
assert.True(t, v)