B: Server public key
        b: Server private key
977227
def server_seed(v, b=random.randrange(0, 1 << SRP_KEY_SIZE)):
    
    N, g, k = get_prime()
    if DEBUG:
        b = DEBUG_PRIVATE_KEY
    gb = pow(g, b, N)
    kv = (k * v) % N
    B = (kv + gb) % N
    if DEBUG_PRINT:
        print("v", binascii.b2a_hex(long2bytes(v)), end='\n')
        print('b=', binascii.b2a_hex(long2bytes(b)), end='\n')
        print("gb", binascii.b2a_hex(long2bytes(gb)), end='\n')
        print("k", binascii.b2a_hex(long2bytes(k)), end='\n')
        print("v", binascii.b2a_hex(long2bytes(v)), end='\n')
        print("kv", binascii.b2a_hex(long2bytes(kv)), end='\n')
        print('B=', binascii.b2a_hex(long2bytes(B)), end='\n')
    return B, b
1131624
def private_key_to_address(private_key: Union[str, bytes]) -> ChecksumAddress:
    
    if isinstance(private_key, str):
        private_key_bytes = to_bytes(hexstr=private_key)
    else:
        private_key_bytes = private_key
    pk = PrivateKey(private_key_bytes)
    return public_key_to_address(pk.public_key)
174719
def pubkey(self):
        
        if not self.is_public:
            if self._sibling is None or isinstance(self._sibling, weakref.ref):
                # create a new key shell
                pub = PGPKey()
                pub.ascii_headers = self.ascii_headers.copy()

                # get the public half of the primary key
                pub._key = self._key.pubkey()

                # get the public half of each subkey
                for skid, subkey in self.subkeys.items():
                    pub |= subkey.pubkey

                # copy user ids and user attributes
                for uid in self._uids:
                    pub |= copy.copy(uid)

                # copy signatures that weren't copied with uids
                for sig in self._signatures:
                    if sig.parent is None:
                        pub |= copy.copy(sig)

                # keep connect the two halves using a weak reference
                self._sibling = weakref.ref(pub)
                pub._sibling = weakref.ref(self)

            return self._sibling()
        return None
173861
private void serverKeyExchange(DH_ServerKeyExchange mesg)
            throws IOException {
        if (debug != null && Debug.isOn("handshake")) {
            mesg.print(System.out);
        }
        dh = new DHCrypt(mesg.getModulus(), mesg.getBase(),
                                            sslContext.getSecureRandom());
        serverDH = mesg.getServerPublicKey();
    }
7456
def key=(*args)
      cert, passphrase = args.flatten
      ssl_context.key = OpenSSL::PKey::RSA.new(cert, passphrase)
    end
689520
def subkey(self, path):
        
        t = path.split("/")
        if len(t) == 2:
            n, for_change = t
        else:
            n, = t
            for_change = 0
        b = (str(n) + ':' + str(for_change) + ':').encode("utf8") + self.master_public_key()
        offset = from_bytes_32(double_sha256(b))
        if self.secret_exponent():
            return self.__class__(
                master_private_key=((self.master_private_key() + offset) % self._generator.order())
            )
        p1 = offset * self._generator
        x, y = self.public_pair()
        p2 = self._generator.Point(x, y)
        p = p1 + p2
        return self.__class__(public_pair=p)
979642
def newkeys(nbits=1024):
        
        pubkey, privkey = rsa.newkeys(nbits, poolsize=1)
        return pubkey, privkey
152661
public OneKey PublicKey()
    {
        OneKey newKey = new OneKey();
        CBORObject val = this.get(KeyKeys.KeyType);
        if (val.equals(KeyKeys.KeyType_Octet)) {
            return null;
        }
        else if (val.equals(KeyKeys.KeyType_EC2)) {
            newKey.add(KeyKeys.EC2_Curve, get(KeyKeys.EC2_Curve));
            newKey.add(KeyKeys.EC2_X, get(KeyKeys.EC2_X));
            newKey.add(KeyKeys.EC2_Y, get(KeyKeys.EC2_Y));
        }
        /*
        else if (val.equals(KeyKeys.KeyType_OKP)) {
            newKey.add(KeyKeys.OKP_Curve, get(KeyKeys.OKP_Curve));
            newKey.add(KeyKeys.OKP_X, get(KeyKeys.OKP_X));
        }
        */
        else {
            return null;
        }
        
        //  Allow them to use the same underlying public key object
        
        newKey.publicKey = publicKey;

        for (CBORObject obj : keyMap.getKeys()) {
            val = keyMap.get(obj);
            if (obj.getType() == CBORType.Number) {
                if (obj.AsInt32() > 0) {
                    newKey.add(obj, val);
                }
            }
            else if (obj.getType() == CBORType.TextString) {
                newKey.add(obj, val);
            }
        }
        return newKey;
    }
813038
function sign(private_key, data) {
  var key = new bitcoinjs.ECKey(new BigInteger(private_key, 16), false);
  var hash = bitcoinjs.crypto.hash256(new Buffer(data, 'hex'));
  return key.sign(hash).toDER().toString('hex');
}
546613
function pemToRsaSSHKey(pem, comment) {
    assert.equal('string', typeof (pem), 'typeof pem');

    var k = sshpk.parseKey(pem, 'pem');
    k.comment = comment;
    return (k.toString('ssh'));
  }
1359317
def add_encrypted(public, encrypted_a, encrypted_b, output):
    
    log("Loading public key")
    publickeydata = json.load(public)
    pub = load_public_key(publickeydata)

    log("Loading first encrypted number")
    enc_a = load_encrypted_number(encrypted_a, pub)

    log("Loading second encrypted number")
    enc_b = load_encrypted_number(encrypted_b, pub)

    log("Adding encrypted numbers together")

    enc_result = enc_a + enc_b
    serialised_result = serialise_encrypted(enc_result)
    print(serialised_result, file=output)
1170920
def bech32_addr
      segwit_addr = Bech32::SegwitAddr.new
      segwit_addr.hrp = Bitcoin.chain_params.bech32_hrp
      segwit_addr.script_pubkey = to_payload.bth
      segwit_addr.addr
    end
150248
function ecp_pubkey(Q, p, a, G, d, l) {
	var R = ecp_new(l);
	ecp_proj(Q, ecp_mul(R, d, G, a, p, l), p, l);
}
584389
def register_pubkey(self):
        
        p = pkcs_os2ip(self.dh_p)
        g = pkcs_os2ip(self.dh_g)
        pn = dh.DHParameterNumbers(p, g)

        y = pkcs_os2ip(self.dh_Ys)
        public_numbers = dh.DHPublicNumbers(y, pn)

        s = self.tls_session
        s.server_kx_pubkey = public_numbers.public_key(default_backend())

        if not s.client_kx_ffdh_params:
            s.client_kx_ffdh_params = pn.parameters(default_backend())
687360
function(key, value) {
          const key2 = key.toLowerCase().replace(/[^a-z0-9]/ig, '');
          res.serverassist.headers[key]    = value;
          res.serverassist.headers2[key2]  = value;
        }
491538
function(privateKey, cb = null){
        if(isFunction(cb)){
            try {
                return cb(null, ethUtils.privateToPublic(privateKey))
            }
            catch(err){
                return cb(err)
            }
        } else {
            try {
                return ethUtils.privateToPublic(privateKey)
            }
            catch(err){
                return err
            }
        }
    }
1129538
async function encryptPBES2(binKey, passphrase, kdfAlgorithm, prf, iterationCount, cipher){
  // kdf
  const pBuffer = jseu.encoder.stringToArrayBuffer(passphrase);
  const salt = await jscrandom.getRandomBytes(
    params.keyDerivationFunctions[kdfAlgorithm].defaultSaltLen
  ); // TODO: currently only salt length of 8 is available
  const keyLength = params.encryptionSchemes[cipher].keyLength; // get keyLength

  let key;
  if (kdfAlgorithm === 'pbkdf2') {
    key = await pbkdf.pbkdf2(pBuffer, salt, iterationCount, keyLength, params.pbkdf2Prfs[prf].hash);
  } else throw new Error('UnsupportedKDF');

  // encrypt
  let iv;
  let encryptedData;
  if (cipher === 'des-ede3-cbc') { // TODO other encryption schemes
    iv = Buffer.from(await jscrandom.getRandomBytes(params.encryptionSchemes[cipher].ivLength));
    const CBC = des.CBC.instantiate(des.EDE);
    const ct = CBC.create({ type: 'encrypt', key: Buffer.from(key), iv });
    encryptedData = Buffer.from(ct.update(binKey).concat(ct.final()));
  }
  else if (cipher === 'aes128-cbc' || cipher === 'aes192-cbc' || cipher === 'aes256-cbc'){
    iv = await jscrandom.getRandomBytes(params.encryptionSchemes[cipher].ivLength);
    encryptedData = Buffer.from( await jscaes.encrypt(
      new Uint8Array(binKey), key, {name: 'AES-CBC', iv}
    ));
    iv = Buffer.from(iv);
  } else throw new Error('UnsupportedCipher');

  // structure
  return {
    encryptedData,
    encryptionAlgorithm: {
      algorithm: 'pbes2',
      parameters: {
        keyDerivationFunc: {
          algorithm: kdfAlgorithm,
          parameters: {
            salt: {type: 'specified', value: Buffer.from(salt)},
            iterationCount: new BN(iterationCount),
            prf: {algorithm: prf, parameters: Buffer.from([0x05, 0x00])}
          }
        },
        encryptionScheme: { algorithm: cipher, parameters: iv }
      }
    }
  };
}