{"id":15956107,"url":"https://github.com/jsign/go-kzg-ceremony-client","last_synced_at":"2025-03-16T07:31:56.119Z","repository":{"id":65170160,"uuid":"584894887","full_name":"jsign/go-kzg-ceremony-client","owner":"jsign","description":"Ethereum EIP-4844 KZG Powers of Tau ceremony client","archived":false,"fork":false,"pushed_at":"2023-06-09T21:58:39.000Z","size":47835,"stargazers_count":75,"open_issues_count":0,"forks_count":26,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-02-27T05:25:40.418Z","etag":null,"topics":["bls12-381","cryptography","eip4844","ethereum","kzg","powers-of-tau"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsign.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-03T19:45:40.000Z","updated_at":"2025-02-06T06:17:30.000Z","dependencies_parsed_at":"2024-06-20T05:57:28.856Z","dependency_job_id":null,"html_url":"https://github.com/jsign/go-kzg-ceremony-client","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsign%2Fgo-kzg-ceremony-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsign%2Fgo-kzg-ceremony-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsign%2Fgo-kzg-ceremony-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsign%2Fgo-kzg-ceremony-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsign","download_url":"https://codeload.github.com/jsign/go-kzg-ceremony-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806035,"owners_count":20350775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bls12-381","cryptography","eip4844","ethereum","kzg","powers-of-tau"],"created_at":"2024-10-07T13:28:28.316Z","updated_at":"2025-03-16T07:31:51.108Z","avatar_url":"https://github.com/jsign.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/jsign/go-kzg-ceremony-client)](https://goreportcard.com/report/github.com/jsign/go-kzg-ceremony-client) ![test](https://github.com/jsign/go-kzg-ceremony-client/actions/workflows/test.yaml/badge.svg) ![releases](https://github.com/jsign/go-kzg-ceremony-client/actions/workflows/release.yaml/badge.svg)\n\n\n# Ethereum EIP-4844 Powers of Tau ceremony client\n\nThis repository contains an implementation of a client to participate in the Powers of Tau ceremony for EIP-4844 in  Ethereum. This is a multi-party ceremony to generate an SRS needed for KZG commitments.\n\nFor _bls12-381_ elliptic curve operations such as group multiplication and pairings, the implementation uses the [gnark-crypto](https://github.com/ConsenSys/gnark-crypto) library ([audited Oct-2022](https://github.com/ConsenSys/gnark-crypto/blob/master/audit_oct2022.pdf)).\n\nUsed by:\n- Multiple individual contributors\n- [Proof-of-cat](https://proofof.cat/)\n- [Dappnode](https://twitter.com/eduadiez/status/1623963202500304896)\n- [Dodgekzg](https://www.dogekzg.com/) (WASM)\n- [Raspberry Pi contributor](https://twitter.com/bruderbuck/status/1617424902256041985)\n- [cryptosat](https://twitter.com/ymcrcat/status/1643698029311176704)\n- [KZGamer](https://hackmd.io/@RoboCopsGoneMad/Bk3zqWDij) \n \n\n\n## Table of content\n- [Ethereum EIP-4844 Powers of Tau ceremony client](#ethereum-eip-4844-powers-of-tau-ceremony-client)\n  - [Table of content](#table-of-content)\n  - [What are the Powers of Tau ceremony, EIP-4844 and KZG commitments?](#what-are-the-powers-of-tau-ceremony-eip-4844-and-kzg-commitments)\n  - [Features](#features)\n  - [I want to participate in the ceremony, how should I use this client?](#i-want-to-participate-in-the-ceremony-how-should-i-use-this-client)\n    - [Step 1 - Get the `kzgcli` CLI command](#step-1---get-the-kzgcli-cli-command)\n    - [Step 2 - Get your session-id keys](#step-2---get-your-session-id-keys)\n    - [Step 3 - Contribute!](#step-3---contribute)\n    - [Step 4 (optional) - Check that your contribution is in the new transcript](#step-4-optional---check-that-your-contribution-is-in-the-new-transcript)\n  - [External entropy](#external-entropy)\n  - [Offline contributions](#offline-contributions)\n  - [Testing ceremony environment](#testing-ceremony-environment)\n  - [Verify the current sequencer transcript](#verify-the-current-sequencer-transcript)\n  - [Tests and benchmarks](#tests-and-benchmarks)\n  - [Side-effects of this ceremony client work](#side-effects-of-this-ceremony-client-work)\n  - [Potential improvements](#potential-improvements)\n  - [License](#license)\n\n## What are the Powers of Tau ceremony, EIP-4844 and KZG commitments?\nIf you're confused about these terms, the best place to understand them better is the [official ceremony](https://ceremony.ethereum.org/) website which gives a high-level explanation of these concepts. It also has a useful FAQ section that digs a bit deeper into the details.\n\n## Features\nThis client implementation has the following features:\n- Supports the expected flow for contributing to the ceremony both with Github and Ethereum addresses. All clients should, at a minimum, implement this to contribute to the ceremony as expected.\n- Supports a special command to pull the current transcript from the ceremony sequencer, and check locally that it's valid. This can be done at any point in the ceremony to check that the sequencer is being honest. No login/authentication is needed!\n- The entropy source used to generate the contributions secret is at a minimum a [CSRNG](https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator) from the Go standard-library.\n- It supports two opt-in sources of entropy which add entropy on top of the CSRNG:\n  - Entropy generated by the [drand network](https://drand.love/) at the contribution point.\n  - Entropy from an external REST API to pull entropy from an arbitrary source. This can be helpful for people contributing creative entropy sources.\n- For each of the sub-ceremonies, a different secret is generated from the entropy sources as recommended (i.e: **not** use the same secret in sub-ceremonies)\n\nUsing external entropy **does not** interfere with contribution time. It's pulled before starting to ask for our turn to the sequencer, so drand and/or the REST API can't add a failure case or extra delays. This is important to contribute as fast as possible, and allow the sequencer to give the turn to another contributor!\n\n\n## I want to participate in the ceremony, how should I use this client? \nContributing to the ceremony is very easy, you only need at least one of:\n- An Ethereum address that has sent at least 3 transactions at the Merge block number.\n- A GitHub account that has a commit dated before 1 August 2022 00:00 UTC.\n\n### Step 1 - Get the `kzgcli` CLI command\nThe `kzgcli` command is the CLI of this ceremony client, you can get it in different ways:\n- Compiling from source: For this, you'll need to have installed the `go` compiler. Pull this repo, and run `make build` or `go build -o kzgcli ./cmd/kzgcli`. This will leave the `kzgcli` binary in your current folder (you might want to `sudo mv kzgcli /usr/local/bin` or your PATH for convenience).\n- Download binaries from the [releases section](https://github.com/jsign/go-kzg-ceremony-client/releases).\n\n\n### Step 2 - Get your session-id keys\nYou'll need a `session-id` to participate in the ceremony. A `session-id` is a GUID string that you'll need to pass to the `kzgcli` CLI as a flag.\n\nTo get your `session-id` do the following:\n- Open the [request_link](https://seq.ceremony.ethereum.org/auth/request_link) endpoint in your browser.\n- You'll be presented with two links, one for Ethereum address participation and one for GitHub account participation. Open the corresponding link and follow the explained steps.\n- In the end, you'll receive a JSON that has a `session_id` field with a value _similar to_ `504d898c-e975-4e13-9a48-4f8b95d754fb`. This string is your `session-id`, copy it to your clipboard.\n\nNote that this step of the process is done on an external website unrelated to this ceremony client. This website is related to the sequencer which all clients target and is managed by the Ethereum Foundation.\n\nIf you got an error trying to get your `session-id`, it could be one of the following ones:\n- `AuthErrorPayload::UserCreatedAfterDeadline`: your Ethereum address isn't matching the sequencer minimal conditions. Your Ethereum address should have sent at least 3 transactions at block 15537393. If that isn't true, you can't participate with this Ethereum address.\n- `AuthErrorPayload::InvalidAuthCode`: your request link got stale. Start the login process from scratch.\n- `AuthErrorPayload::UserAlreadyContributed`: you can only contribute once per GitHub account or Ethereum address.\n\n### Step 3 - Contribute!\n\nOptionally, you can first check the status of the lobby:\n```bash\n$ kzgcli status\nLobby size: 0\nNumber of contributions: 7915\nSequencer address: 0x5afE36d82dE8990B777f82651B96608Ec54d190d\n```\nThis can provide some context around how many people are waiting for their turn to contribute and a sense of waiting times.\n\nContribute to the ceremony by running:\n```\n$ kzgcli contribute --session-id \u003cpaste-your-session-id\u003e\nWaiting for our turn to contribute...\nIt's our turn! Contributing...\nContribution ready, took 2.91s\nSending contribution...\nSuccess!\n```\nThat's it! Two files will appear in your current directory:\n- `my_contribution.json` is exactly the contribution that was submitted to the sequencer.\n- `contribution_receipt.json` is the receipt returned by the sequencer for your contribution.\n\nIf you want to leverage the optional external sources of entropy, you can provide some extra flags. Please check the _External entropy_ section below for more details and examples.\n\n### Step 4 (optional) - Check that your contribution is in the new transcript\nThe sequencer has a public transcript that contains everyone that has participated correctly in the ceremony.\nA friendly way is looking at the [ceremony website contributors list](https://ceremony.ethereum.org/#/record).\n\n## External entropy\nThe `kzgcli contribute` command has two optional flags:\n- `--drand`: if this flag is provided, the client will pull the latest entropy available from the [drand network](https://drand.love/), which will be mixed with the CSRNG source when contributing to the ceremony.\n- `--urlrand \u003curl\u003e`: is a URL that the client will do a `GET` request, and use the returned body bytes as entropy to be mixed with the CSRNG source when contributing to the ceremony.\n\nYou can provide only one of these flags, or both at the same time:\n```\n$ kzgcli contribute --session-id \u003csession-id\u003e --drand --urlrand https://ihagopian.com\nPulling entropy from drand... Got it! (length: 32, round: 2578668)\nPulling entropy from https://ihagopian.com... Got it! (length: 52919)\nWaiting for our turn to contribute...\nIt's our turn! Contributing...\nContribution ready, took 3.01s\nSending contribution...\nSuccess!\n```\n\nIf you want to understand in more detail how the external entropy is mixed with the CSRNG, please see [this code section](https://github.com/jsign/go-kzg-ceremony-client/blob/main/contribution/batchcontribution.go#L24-L35).\n\n## Offline contributions\nThis section is only interesting if you're contributing from constrained environments.\n\nApart from conforming to the specification for the Powers of Tau protocol, participating in the ceremony involves interacting with the sequencer in a defined API flow. If you are contributing from a constraint environment (e.g: air-gapped or bandwidth constrained), you might be interested in narrowing down the contribution step independently from getting the state and sending the contribution.\n\nThe CLI tool provides an _offline_ subcommand:\n\n- `kzgcli offline download-state \u003cfile-path\u003e`: downloads the current state of the ceremony from the sequencer and saves it in a file.\n- `kzgcli offline contribute \u003ccurrent-state-path\u003e \u003ccontribution-path\u003e`: opens a previously downloaded current state of the ceremony, makes the contribution and saves it in a new file.\n- `kzgcli offline send-contribution --session-id \u003c...\u003e \u003ccontribution-path\u003e`: sends a previously generated contribution file to the sequencer.\n\nYou might not need `kzgcli offline download-state` you're pulling the current state out-of-band (e.g: direct download or the sequencer sent it to you). If that isn't the case, you can use it in an environment that has internet access (not necessarily your contribution environment).\n\nThe `kzgcli offline contribute` command doesn't require internet access, and will probably be the only command you'll run in your constrained environment. This command also accepts the `--urlrand` and `--hex-entropy` flag if you want to pull entropy from an external source of randomness available in your environment or provided directly to the client, respectively.\n\nThe `kzgcli offline send-contribution` command sends the previously generated file by `kzgcli offline contribute` to the sequencer.\n\nAn example of running the first two commands:\n```\n$ kzgcli offline download-state current.json\nDownloading current state... OK\nEncoding and saving to current.json... OK\nSaved current state in current.json\n$ kzgcli offline contribute current.json new.json\nOpening and parsing offline current state file...OK\nCalculating contribution... OK\nSuccess, saved contribution in new.json\n```\n\n## Testing ceremony environment\n\nIn all commands you can use the `--sequencer-url` flag to override the sequencer API URL to target a different sequencer than in the _mainnet_ environment. For example, `--sequencer-url \"https://kzg-ceremony-sequencer-dev.fly.dev\"`.\n\n## Verify the current sequencer transcript\nThe sequencer has [an API that provides a full transcript](https://seq.ceremony.ethereum.org/info/current_state) of all the contributions, so anyone can double-check the calculations to see if the result matches all the received contributions.\n\nHaving clients double-check sequencer calculations avoids having to trust that the sequencer is in the latest powers of Tau calculation.\n\nTo verify the current transcript:\n```\n$ kzgcli verify-transcript\nPulling current transcript from sequencer... OK\nVerifying transcript... Valid! (took 13.08s)\n```\nNote that you don't need a `--session-id`, so anyone can run the verifying logic.\n\n## Tests and benchmarks\nYou can run the tests for the repo doing `make test` or `go test ./... -race`.\n\nYou can run benchmarks with `make bench` or `go test ./... -run=none -bench=.`:\n```\ngoos: linux\ngoarch: amd64\npkg: github.com/jsign/go-kzg-ceremony-client/contribution\ncpu: AMD Ryzen 7 3800XT 8-Core Processor            \nBenchmarkDecodeJSON-16                 1        2341867398 ns/op\nBenchmarkContribute-16                 1        2964969708 ns/op\n```\n\nAs shown, in a modern desktop CPU the contribution calculation takes less than 3 seconds. The only \"optimization\" done in the client is leveraging multiple cores to calculate your contribution. If your CPU is ~modern, gnark-crypto library might leverage special CPU instructions such as [ADX](https://en.wikipedia.org/wiki/Intel_ADX) to do some elliptic curve operations way faster (no configuration needed).\n\n## Side-effects of this ceremony client work\nWhile creating this ceremony client, I contributed to other repositories in the ecosystem:\n- To validate this client implementation without a sequencer, I created the [kzg-ceremony-test-vectors](https://github.com/jsign/kzg-ceremony-test-vectors) repository which generates batch contributions from the spec initialContribution.json file with a fixed set of secrets producing a deterministic/reproducible output that clients can check against the sequencer reference implementation. [You can see the unit-test leveraging this test vector](https://github.com/jsign/go-kzg-ceremony-client/blob/917d4b5da6a54da4879fd8869e84344dd57ad950/contribution/contribution_test.go#L33).\n- I detected a slight bug in one of the Rust clients and [fixed it](https://github.com/crate-crypto/small-powers-of-tau/pull/4).\n- While trying to add ECDSA EIP-721 signature verification for the transcript, I found [an inconsistency](https://hackmd.io/@jsign/kzg-ceremony-eip712-problem) in how `eth-rs` or `go-ethereum` implement the EIP. This potential bug doesn't allow this client to verify ECDSA signatures in the transcript. ~~This situation is under investigation.~~ ([fixed in `go-ethereum` PR](https://github.com/ethereum/go-ethereum/pull/26462))\n\n\n## Potential improvements\nDespite this client is ready to contribute to the ceremony, there're a couple of things that it doesn't support but could if I can convince myself of some tradeoffs:\n- The `gnark-crypto` library [doesn't support BLS signing yet](https://github.com/ConsenSys/gnark-crypto/issues/116), which is incredibly unfortunate. This doesn't allow the client to do BLS signing or verification in the transcript. This is an optional feature for clients, so it isn't a big deal or create any risk. Despite gnark-crypto has support for group multiplication and pairings, the biggest pending work for signing is implementing the _hash to curve_ step of signing which isn't entirely trivial. As a workaround, I could use a separate BLS library to do signing/verification, but that would mean using two BLS libraries and I'd prefer to be 100% clear about which library is used in this repo for _all_ cryptographic operations just by looking at the [go.mod](go.mod) file.\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsign%2Fgo-kzg-ceremony-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsign%2Fgo-kzg-ceremony-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsign%2Fgo-kzg-ceremony-client/lists"}