Coder Social home page Coder Social logo

dsrvlabs / czg-keremony Goto Github PK

View Code? Open in Web Editor NEW
13.0 7.0 4.0 10.2 MB

JavaScript-based client to participate in Ethereum KZG Ceremony

Home Page: https://dsrv.com

License: MIT License

JavaScript 98.86% Shell 0.61% Dockerfile 0.20% Makefile 0.33%
bls12-381 eip4844 ethereuem javascript kzg kzg-commitment nodejs powers-of-tau

czg-keremony's People

Contributors

hqueue avatar kim201212 avatar niooss-ledger avatar rootwarp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

czg-keremony's Issues

Add signature

Spec.

Signing the contributions

The signing of contributions with Ethereum ECDSA keys and BLS signing the user's identity is RECOMMENDED.

  • Getting the encoded identity:
    • Depending on whether the user logged in with an Ethereum Address or a GitHub handle, they will encode their identity into bytes via either
  • BLS-Sign Identity (RECOMMENDED):
    • Use the secret x as a private key to sign the user's encoded identity.
  • ECDSA Sign the user's PoT Pubkeys (RECOMMENDED)
    • Only perform these steps if using an Ethereum Address to login
    • Build the EIP712 TypedData JSON object as per contributionSigning.md
    • Use web3.eth.signTypedData() to sign the message
def sign_identity(contribution: Contribution, x: int, identity: str) -> Contribution:
    encoded_identity = b''
    if identity[:2] == '0x':
        # Identity is a Ethereum address
        encoded_identity = eth_address_to_identity(identity).encode()
    else:
        # Identity is an GitHub ID
        encoded_identity = github_handle_to_identity(identity).encode()
    signature = bls.Sign(x, encoded_identity)
    contribution.bls_signature = signature
def sign_contribution(batch_contribution: BatchContribution, ethereum_address: Optional[str]) -> BatchContribution:
    typed_data = contribution_to_typed_data_str(batch_contribution)  # function defined in contributionSigning.md
    batch_contribution.ecdsa_signature = web3.eth.sign_typed_data(ethereum_address, json.loads(typed_data))
    return batch_contribution

Signing and calculating contribution file.

contribution contents from try_contribute

contributions: [
    {
      numG1Powers: 4096,
      numG2Powers: 65,
      powersOfTau: [Object],
      potPubkey: '0x93e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8',
      blsSignature: ''
    },
    {
      numG1Powers: 8192,
      numG2Powers: 65,
      powersOfTau: [Object],
      potPubkey: '0x93e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8',
      blsSignature: ''
    },
    {
      numG1Powers: 16384,
      numG2Powers: 65,
      powersOfTau: [Object],
      potPubkey: '0x93e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8',
      blsSignature: ''
    },
    {
      numG1Powers: 32768,
      numG2Powers: 65,
      powersOfTau: [Object],
      potPubkey: '0x93e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8',
      blsSignature: ''
    }
  ],
  ecdsaSignature: ''

Apply workers to decode powers

Current single thread implementation takes about 5 minutes to complete the ceremony.
Multi-thread approach is required to reduce this.


Separate decode and power of tau calculation.
Power of tau calculation will be handled on another isseu.

Let's check the next steps

From #3, the new commitment seems successfully submitted.

So, let's step forward.

  • #12
  • #15
  • #13
  • #17
  • #21
  • Web interface?
  • Log and show running status.
  • Add signature.
  • Consider the new interaction flows.
    • Simply, just provide one step command. ex. ./join_ceremony
    • Ask account type(ethereum or github)
    • Provide authentication url.
    • guide user to attach session id. input prompt should be provided.
    • show progress bar.

Enhance random source

Random Spec.

Generating randomness

The randomness that each participant contributes to a set of Powers of Tau is in the form of an integer in the range (1, bls.r).

The participant MUST generate 4 different secrets from a cryptographically-secure pseudo-random number generator (CSPRNG) of their choosing.

Each secret MUST meet the following requirements:

  • Sourced from a CSPRNG
  • Contain at least 255 bits of entropy
  • Be different from the other 3 secrets used in the other sub-ceremonies
  • Be cleared from memory after the contribution is complete

Furthermore, each secret SHOULD meet the following requirements:

  • Be uniformly distributed across $\mathbb{F}_r$. (i.e. avoid modulo bias with respect to bls.r).

KeyGen

A good method for meeting the above requirements would be to make use of the KeyGen function offered by all compliant BLS libraries. This function takes in a seed of at least 32 bytes and returns a uniformly sampled integer of $\mathbb{F}_r$.

Task

  • Generate randomness for each contribution
  • Receive seed words with a flag
  • Apply mnemonic words

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.