Giter Club home page Giter Club logo

ckb-system-scripts's Issues

Support P2SH Style MultiSign Script

Background

In Bitcoin, a multisign script is written like this:

M <Public Key 1> <Public Key 2> ... <Public Key N> N CHECKMULTISIG

One can embed this script in a TX's output, and provide enough legal signatures to unlock. However, the most popular multisign method in Bitcoin is P2SH. P2SH allows users embed the Hash160 of multisign script in an UTXO, and provide original script and signatures to unlock it later.

P2SH reduces the script size to a 20bytes hash, and thus it is easy to be encoded to a multisign address.

Multisign Script Support on CKB

Current multisign script on CKB is plain mode, which means the lock script has to embed and exposure all of the PKs. It costs more capacity, lack of security and privacy, and hard to be encoded to a short address.

So i suggest we follow Bitcoin's P2SH multisign method. Lock script only includes the script hash, and we use witness to provide full script.

Demo Implement

int main(argc, args[]) {
    if (argc == 2) {
          //  do single signature verification.
    } else if (argc == 3) {
           multisign_PK_hash = args[1]
           multisign_script = args[2]
           signers = []
           PK_hash = hash()
           for (signature in witness) {
                   PK = signature.recover()
                   PK_hash.append(PK)
                   signers.add(PK)
           }
           if (PK_hash != multisign_PK_hash) return -1;
           
           return check_multisign_script(signers, multisign_script)
    } 
}

Keep multisign_script simple, like "2/3",and "3/5!1!4". Where "n/m" means at least n of m signature should be provided, and "!i" means one of signature must match the i-th PK.

CKB System Scripts Automation and Security Requirements Epic

This is an Epic, please start new issue for each objective listed below.

Reproducible Docker Builder

  • Provide a Dockerfile to show how we create the builder.

Security Requirements:

  • The Dockerfile must verify the downloaded gcc package checksum.

Build using an existing Docker Builder image

  • Ease building the scripts using a docker image.

Security Requirements:

  • The build script must verify the checksum of the builder image

CI has already been setup in #15

Binary Build and Crate Publish via CI

  • Do not store the binaries in the repository. Developer and CI must build the scripts into binaries by themselves.

Setup CI to automate the publishing workflow:

  • Build binaries
  • Run test
  • Publish the Rust crate including the binaries.

Security Requirements:

  • Publish the code hashes of each system scripts in the release.

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.