Have ideas to improve npm?Join in the discussion! »

    jingtum-base-lib-guomi

    1.0.3 • Public • Published

    #The Jingtum Base JavaScript Library

    Basic function for development, include generate wallet, check secret and check address.

    jingtum-base-lib-guomi connects to the Jingtum base lib and runs in Node.js as well as in the browser.

    ##Getting jingtum-base-lib-guomi

    Via npm for Node.js

      $ npm install jingtum-base-lib-guomi
    

    Build from the source using gulp

      $ git clone http://git.jingtum.com/root/jingtum-base-lib.git
      $ npm install
      $ gulp production
    

    Then use the minified dist/jingtum-base-*-min.js in your webpage

    ##Quickstart

        var base = require('jingtum-base-lib-guomi');
        var Wallet = base.Wallet;
        var wallet1 = Wallet.generate();//get a wallet
        var wallet2 = Wallet.fromSecret('snvdjvSszL1o1w76a7pXqt9AZQKk7');//get a wallet by secret
        var ret = Wallet.isValidAddress('jpgiTFdNPABbUoZFQcmqzgvJ9ELrxhwUf9');// whether the address is valid
        var ret = Wallet.isValidSecret('shLKRB9saLkamkswVzK18AuESPvC5');// whether the secret is valid
    

    ##Signature verification

      var wt = new Wallet('shLKRB9saLkamkswVzK18AuESPvC5');
      var pubkey = wt.getPublicKey();
    
    
      // Sign message can be an array or a hex string
      var sdata = "F95EFF5A4127E68D2D86F9847D9B6DE5C679EE7D9F3241EC8EC67F99C4CDA923";
    
      var sign =wt.signTx(sdata);
    
      // Signature MUST be either:
      // 1) hex-string of DER-encoded signature; or
      // 2) DER-encoded signature as buffer; or
      // 3) object with two hex-string properties (r and s)
      // Verify the signature 
      if ( wt.verifyTx(sdata, sign) == true)
      {
        console.log("Verify sjcl signature successfully!");
      }else
        console.log("Cannot verify sjcl sig");
    
    

    TODO

    Check if work in browser env

    Install

    npm i jingtum-base-lib-guomi

    DownloadsWeekly Downloads

    0

    Version

    1.0.3

    License

    Apache-2.0

    Unpacked Size

    29.7 kB

    Total Files

    15

    Last publish

    Collaborators

    • avatar