Git Product home page Git Product logo

dkglib's Introduction

DKGLib

Implements on-chain logic of DKG protocol described in "Secure Distributed Key Generation for Discrete-Log Based Cryptosystems" by R. Gennaro, S. Jarecki, H. Krawczyk, and T. Rabin.

How it works

Library communicates with Cosmos Application called RandApp

Transactions sent by light blockchain client (copy of Cosmos CliContext and TxBuilder but with explicit configuration)

How to use

// CLIContext implements a typical CLI context created in SDK modules for
// transaction handling and queries
// DKGLib uses own Context with explicit configuration
cliCtx, err := cliCTX.NewCLIContext(chainID, nodeEndpoint, validatorName, genOnly, broadcastMode, vfrHome, height, trustNode, cliHome, "")
if err != nil {
    return nil, nil, err
}
cliCtx = cliCtx.WithCodec(cdc).WithAccountDecoder(cdc)
accNumber, err := cliCtx.GetAccountNumber(cliCtx.FromAddress)
if err != nil {
    return nil, nil, err
}
kb, err := keys.NewKeyBaseFromDir(cliCtx.Home)
if err != nil {
    return nil, nil, err
}
// TxBuilder implements tx generation
txBldr := authtxb.NewTxBuilder(utils.GetTxEncoder(cdc), accNumber, 0, 0, 0.0, false, cliCtx.Verifier.ChainID(), "", nil, nil).WithKeybase(kb)
if err := cliCtx.EnsureAccountExists(); err != nil {
    return nil, nil, fmt.Errorf("failed to find account: %v", err)
}

// Create DKGClient
oc := lib.NewOnChainDKG(cli, txBldr)

// Start new round
if err := oc.StartRound(types.NewValidatorSet(vals), pval, mockF, logger, 0); err != nil {
    panic(fmt.Sprintf("failed to start round: %v", err))
}

// Process blocks
tk := time.NewTicker(time.Second)
for {
    select {
    case <-tk.C:
        if err, ok := oc.ProcessBlock(); err != nil {
            panic(fmt.Sprintf("failed to start round: %v", err))
        } else if ok {
            wg.Done()
            return
        }
    }
}

dkglib's People

Contributors

pr0n00gler avatar primalcs avatar zavgorodnii avatar

Stargazers

SuperXiaoLan avatar Denis Glotov avatar Jacob Gadikian avatar  avatar C H avatar

Watchers

James Cloos avatar Evgeny Danilenko avatar  avatar Gar|k avatar  avatar KRogLA avatar Ilia Shirobokov avatar

dkglib's Issues

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.