How to use the bcrypto/lib/secp256k1.privateKeyGenerate function in bcrypto

To help you get started, we’ve selected a few bcrypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bcoin-org / bmultisig / test / util / cosigner-context.js View on Github external
assert(hd.PrivateKey.isHDPrivateKey(options.master),
        'Bad master key.');
      master = options.master;
    } else {
      master = hd.generate();
    }

    let joinPrivKey;
    if (options.joinPrivKey != null) {
      assert(Buffer.isBuffer(options.joinPrivKey),
        'joinPrivKey must be a buffer.');
      assert(secp256k1.privateKeyVerify(options.joinPrivKey),
        'joinPrivKey is not a private key.');
      joinPrivKey = options.joinPrivKey;
    } else {
      joinPrivKey = secp256k1.privateKeyGenerate();
    }

    let authPrivKey;
    if (options.authPrivKey != null) {
      assert(Buffer.isBuffer(options.authPrivKey),
        'authPrivKey must be a buffer.');
      assert(secp256k1.privateKeyVerify(options.authPrivKey),
        'authPrivKey is not a private key.');

      authPrivKey = options.authPrivKey;
    } else {
      authPrivKey = secp256k1.privateKeyGenerate();
    }

    this.joinPrivKey = joinPrivKey;
    this.joinPubKey = secp256k1.publicKeyCreate(this.joinPrivKey, true);
github bcoin-org / bmultisig / test / util / cosigner-context.js View on Github external
'joinPrivKey is not a private key.');
      joinPrivKey = options.joinPrivKey;
    } else {
      joinPrivKey = secp256k1.privateKeyGenerate();
    }

    let authPrivKey;
    if (options.authPrivKey != null) {
      assert(Buffer.isBuffer(options.authPrivKey),
        'authPrivKey must be a buffer.');
      assert(secp256k1.privateKeyVerify(options.authPrivKey),
        'authPrivKey is not a private key.');

      authPrivKey = options.authPrivKey;
    } else {
      authPrivKey = secp256k1.privateKeyGenerate();
    }

    this.joinPrivKey = joinPrivKey;
    this.joinPubKey = secp256k1.publicKeyCreate(this.joinPrivKey, true);

    this.authPrivKey = authPrivKey;
    this.authPubKey = secp256k1.publicKeyCreate(this.authPrivKey, true);

    this.master = master;
    this.fingerPrint = getFingerprint(master);
    this.accountPrivKey = this.master.deriveAccount(44, this.purpose, 0);
    this.accountKey = this.accountPrivKey.toPublic();
  }
github handshake-org / hsd / lib / node / node.js View on Github external
genKey() {
    if (this.network.identityKey)
      return this.network.identityKey;
    return secp256k1.privateKeyGenerate();
  }
github handshake-org / hsd / lib / net / pool.js View on Github external
this.publicHost = '0.0.0.0';
    this.publicPort = this.network.port;
    this.maxOutbound = 8;
    this.maxInbound = 8;
    this.createSocket = this._createSocket.bind(this);
    this.createServer = tcp.createServer;
    this.resolve = this._resolve.bind(this);
    this.proxy = null;
    this.onion = false;
    this.upnp = false;
    this.selfish = false;
    this.version = common.PROTOCOL_VERSION;
    this.agent = common.USER_AGENT;
    this.authPeers = [];
    this.knownPeers = {};
    this.identityKey = secp256k1.privateKeyGenerate();
    this.banScore = common.BAN_SCORE;
    this.banTime = common.BAN_TIME;
    this.feeRate = -1;
    this.seeds = this.network.seeds;
    this.nodes = [];
    this.invTimeout = 60000;
    this.blockMode = 0;
    this.services = common.LOCAL_SERVICES;
    this.requiredServices = common.REQUIRED_SERVICES;
    this.memory = true;

    this.fromOptions(options);
  }
github handshake-org / hsd / lib / hd / private.js View on Github external
static generate() {
    const key = secp256k1.privateKeyGenerate();
    const entropy = random.randomBytes(32);
    return HDPrivateKey.fromKey(key, entropy);
  }