arnaucube
arnaucube/eth-kzg-ceremony-altPublic Self-hosted repository
use different taus for each powers batch
arnaucube root@arnaucube.com
Wed, 04 Jan 2023 11:38:40 +0100
commit

4c0c9ff7816cb90fc4b453d789e437458bd66f11

parent

a514115905e567efd45498ab66a9daddada9ccf3

5 files changed, 20 insertions(+), 13 deletions(-)

jump to
M cmd/cmd.go → cmd/cmd.go

@@ -17,7 +17,8 @@ )

func main() { fmt.Println("eth-kzg-ceremony-alt") - fmt.Printf("====================\n\n") + fmt.Printf("====================\n") + fmt.Printf(" https://github.com/arnaucube/eth-kzg-ceremony-alt\n\n") redB := color.New(color.FgRed, color.Bold) cyan := color.New(color.FgCyan)

@@ -29,7 +30,7 @@ var sequencerURL string

var randomness string var sleepTime uint64 flag.StringVarP(&sequencerURL, "url", "u", - "https://kzg-ceremony-sequencer-dev.fly.dev", "sequencer url") + "https://sequencer.ceremony.ethereum.org", "sequencer url") flag.StringVarP(&randomness, "rand", "r", "", fmt.Sprintf("randomness, needs to be bigger than %d", kzgceremony.MinRandomnessLen)) flag.Uint64VarP(&sleepTime, "sleeptime", "s",
M go.mod → go.mod

@@ -7,6 +7,7 @@ github.com/fatih/color v1.13.0

github.com/frankban/quicktest v1.14.4 github.com/kilic/bls12-381 v0.1.0 github.com/spf13/pflag v1.0.5 + golang.org/x/crypto v0.4.0 ) require (

@@ -16,5 +17,5 @@ github.com/kr/text v0.2.0 // indirect

github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/rogpeppe/go-internal v1.9.0 // indirect - golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect + golang.org/x/sys v0.3.0 // indirect )
M go.sum → go.sum

@@ -22,10 +22,12 @@ github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=

github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8= +golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
M powersoftau.go → powersoftau.go

@@ -4,6 +4,8 @@ import (

"fmt" "math/big" + "golang.org/x/crypto/blake2b" + bls12381 "github.com/kilic/bls12-381" )

@@ -81,7 +83,7 @@ for i := 0; i < len(cs.Transcripts); i++ {

ns.Transcripts[i].NumG1Powers = cs.Transcripts[i].NumG1Powers ns.Transcripts[i].NumG2Powers = cs.Transcripts[i].NumG2Powers - newSRS, proof, err := Contribute(cs.Transcripts[i].PowersOfTau, randomness) + newSRS, proof, err := Contribute(cs.Transcripts[i].PowersOfTau, i, randomness) if err != nil { return nil, err }

@@ -109,7 +111,7 @@ for i := 0; i < len(pb.Contributions); i++ {

nb.Contributions[i].NumG1Powers = pb.Contributions[i].NumG1Powers nb.Contributions[i].NumG2Powers = pb.Contributions[i].NumG2Powers - newSRS, proof, err := Contribute(pb.Contributions[i].PowersOfTau, randomness) + newSRS, proof, err := Contribute(pb.Contributions[i].PowersOfTau, i, randomness) if err != nil { return nil, err }

@@ -135,9 +137,10 @@ }

return &SRS{g1s, g2s} } -func tau(randomness []byte) *toxicWaste { +func tau(round int, randomness []byte) *toxicWaste { + val := blake2b.Sum256(randomness) tau := new(big.Int).Mod( - new(big.Int).SetBytes(randomness), + new(big.Int).SetBytes(val[:]), g2.Q()) tau_Fr := bls12381.NewFr().FromBytes(tau.Bytes()) TauG2 := g2.New()

@@ -176,12 +179,12 @@ }

// Contribute takes as input the previous SRS and a random // byte slice, and returns the new SRS together with the Proof -func Contribute(prevSRS *SRS, randomness []byte) (*SRS, *Proof, error) { +func Contribute(prevSRS *SRS, round int, randomness []byte) (*SRS, *Proof, error) { if len(randomness) < MinRandomnessLen { return nil, nil, fmt.Errorf("err randomness") // WIP } // set tau from randomness - tw := tau(randomness) + tw := tau(round, randomness) newSRS := computeContribution(tw, prevSRS)
M powersoftau_test.go → powersoftau_test.go

@@ -13,13 +13,13 @@ c := qt.New(t)

srs_0 := newEmptySRS(10, 10) - srs_1, proof_1, err := Contribute(srs_0, + srs_1, proof_1, err := Contribute(srs_0, 0, []byte("1111111111111111111111111111111111111111111111111111111111111111")) c.Assert(err, qt.IsNil) c.Assert(Verify(srs_0, srs_1, proof_1), qt.IsTrue) - srs_2, proof_2, err := Contribute(srs_1, + srs_2, proof_2, err := Contribute(srs_1, 0, []byte("2222222222222222222222222222222222222222222222222222222222222222")) c.Assert(err, qt.IsNil) c.Assert(Verify(srs_1, srs_2, proof_2), qt.IsTrue)