A chunk (#chunkNumber) containing the data C{chunkData} was verified, sent
        to us by the Q2QAddress C{who}.
483535
def chunkVerified(self, who, chunkNumber, chunkData):
        
        if self.mask[chunkNumber]:
            # already received that chunk.
            return
        self.file.seek(chunkNumber * CHUNK_SIZE)
        self.file.write(chunkData)
        self.file.flush()
        self.sha1sums[chunkNumber] = sha.new(chunkData).digest()

        if not self.mask[chunkNumber]:
            self.nexus.increaseScore(who)
            self.mask[chunkNumber] = 1
            self.writeMaskFile()
            self.changes += 1

            if self.changes > self.maximumChangeCountBeforeMaskUpdate:
                self.call.cancel()
                self.sendMaskUpdate()
                self.call = self.nexus.callLater(
                    self.maximumChangeCountBeforeMaskUpdate,
                    self.maybeUpdateMask)

            if not self.seed and not self.mask.countbits(0):
                # we're done, let's let other people get at that file.
                self.file.close()
                os.rename(self.incompletePath.path,
                          self.fullPath.path)
                self.file = self.fullPath.open()
                self.maskfile.close()
                os.unlink(self.maskfile.name)

            self.ui.updateHostMask(self.mask)
803242
private void readChunkIfNeeded() {
        if (workBufferSize > workBufferPosition) {
            return;
        }
        if (workBuffer == null) {
            workBuffer = bitmapProvider.obtainByteArray(WORK_BUFFER_SIZE);
        }
        workBufferPosition = 0;
        workBufferSize = Math.min(rawData.remaining(), WORK_BUFFER_SIZE);
        rawData.get(workBuffer, 0, workBufferSize);
    }
738542
function(id, responseParser) {
            var lastChunkIdx = handler._getTotalChunks(id) - 1,
                xhr = handler._getXhr(id, lastChunkIdx);

            if (responseParser) {
                return new qq.Promise().success(responseParser(xhr), xhr);
            }

            return new qq.Promise().success({}, xhr);
        }
1048869
private <T> ChunkData<T> chunkData(String identifier, World world, BlockPos pos)
	{
		return world != null ? chunkData(identifier, world, world.getChunkFromBlockCoords(pos)) : null;
	}
823094
def verify(data, sig)
      regenerate_pubkey unless @key.public_key
      sig = Bitcoin::OpenSSL_EC.repack_der_signature(sig)
      if sig
        @key.dsa_verify_asn1(data, sig)
      else
        false
      end
    end
1268660
private static int getSigOpCount(List<ScriptChunk> chunks, boolean accurate) throws ScriptException {
        int sigOps = 0;
        int lastOpCode = OP_INVALIDOPCODE;
        for (ScriptChunk chunk : chunks) {
            if (chunk.isOpCode()) {
                switch (chunk.opcode) {
                case OP_CHECKSIG:
                case OP_CHECKSIGVERIFY:
                    sigOps++;
                    break;
                case OP_CHECKMULTISIG:
                case OP_CHECKMULTISIGVERIFY:
                    if (accurate && lastOpCode >= OP_1 && lastOpCode <= OP_16)
                        sigOps += decodeFromOpN(lastOpCode);
                    else
                        sigOps += 20;
                    break;
                default:
                    break;
                }
                lastOpCode = chunk.opcode;
            }
        }
        return sigOps;
    }
940951
boolean checkChunkMac(byte[] headerNonce, long chunkNumber, ByteBuffer chunkBuf) {
		assert chunkBuf.remaining() >= NONCE_SIZE + MAC_SIZE;

		// get three components: nonce + payload + mac
		final ByteBuffer chunkNonceBuf = chunkBuf.asReadOnlyBuffer();
		chunkNonceBuf.position(0).limit(NONCE_SIZE);
		final ByteBuffer payloadBuf = chunkBuf.asReadOnlyBuffer();
		payloadBuf.position(NONCE_SIZE).limit(chunkBuf.limit() - MAC_SIZE);
		final ByteBuffer expectedMacBuf = chunkBuf.asReadOnlyBuffer();
		expectedMacBuf.position(chunkBuf.limit() - MAC_SIZE);

		// get nonce:
		final byte[] chunkNonce = new byte[NONCE_SIZE];
		chunkNonceBuf.get(chunkNonce);

		// get expected MAC:
		final byte[] expectedMac = new byte[MAC_SIZE];
		expectedMacBuf.get(expectedMac);

		// get actual MAC:
		final byte[] calculatedMac = calcChunkMac(macKey, headerNonce, chunkNumber, chunkNonce, payloadBuf);

		// time-constant equality check of two MACs:
		return MessageDigest.isEqual(expectedMac, calculatedMac);
	}
171991
@SuppressWarnings("unchecked")
	private <T> ChunkData<T> chunkData(String identifier, World world, Chunk chunk)
	{
		Table<String, Chunk, ChunkData<?>> data = datas.get();
		return (ChunkData<T>) data.get(identifier, chunk);

	}
1015591
ByteBuffer encryptChunk(ByteBuffer cleartextChunk, long chunkNumber, byte[] headerNonce, SecretKey fileKey) {
		try {
			// nonce:
			byte[] nonce = new byte[NONCE_SIZE];
			random.nextBytes(nonce);

			// payload:
			final Cipher cipher = CipherSupplier.AES_CTR.forEncryption(fileKey, new IvParameterSpec(nonce));
			final ByteBuffer outBuf = ByteBuffer.allocate(NONCE_SIZE + cipher.getOutputSize(cleartextChunk.remaining()) + MAC_SIZE);
			outBuf.put(nonce);
			int bytesEncrypted = cipher.doFinal(cleartextChunk, outBuf);

			// mac:
			final ByteBuffer ciphertextBuf = outBuf.asReadOnlyBuffer();
			ciphertextBuf.position(NONCE_SIZE).limit(NONCE_SIZE + bytesEncrypted);
			byte[] authenticationCode = calcChunkMac(macKey, headerNonce, chunkNumber, nonce, ciphertextBuf);
			assert authenticationCode.length == MAC_SIZE;
			outBuf.put(authenticationCode);

			// flip and return:
			outBuf.flip();
			return outBuf;
		} catch (ShortBufferException e) {
			throw new IllegalStateException("Buffer allocated for reported output size apparently not big enough.", e);
		} catch (IllegalBlockSizeException | BadPaddingException e) {
			throw new IllegalStateException("Unexpected exception for CTR ciphers.", e);
		}
	}
434574
def _finalize_chunk(self, dd, offsets):
        # type: (Downloader, blobxfer.models.download.Descriptor,
        #        blobxfer.models.download.Offsets) -> None
        
        if dd.entity.is_encrypted:
            dd.mark_unchecked_chunk_decrypted(offsets.chunk_num)
        # integrity check data and write to disk (this is called
        # regardless of md5/hmac enablement for resume purposes)
        dd.perform_chunked_integrity_check()
        # remove from disk set and add bytes to counter
        with self._disk_operation_lock:
            self._disk_set.remove(
                blobxfer.operations.download.Downloader.
                create_unique_disk_operation_id(dd, offsets))
            self._download_bytes_sofar += offsets.num_bytes
1284960
private byte[] getSha256(byte[] data) throws NoSuchAlgorithmException {
        MessageDigest digest = MessageDigest.getInstance("SHA-256");
        return digest.digest(data);
    }
1264466
function verify (transaction) {
	var remove = 64;

	if (transaction.signSignature) {
		remove = 128;
	}

	var bytes = getBytes(transaction);
	var data2 = Buffer.alloc(bytes.length - remove);

	for (var i = 0; i < data2.length; i++) {
		data2[i] = bytes[i];
	}

	var hash = crypto.createHash('sha256').update(data2.toString('hex'), 'hex').digest();

	var signatureBuffer = Buffer.from(transaction.signature, 'hex');
	var senderPublicKeyBuffer = Buffer.from(transaction.senderPublicKey, 'hex');
	var res = naclInstance.crypto_sign_verify_detached(signatureBuffer, hash, senderPublicKeyBuffer);

	return res;
}
1330719
function verify(rawMsg, rawSig, rawPub) {
  const msg = nacl.util.decodeUTF8(rawMsg);
  const sig = nacl.util.decodeBase64(rawSig);
  const pub = base58.decode(rawPub);
  const m = new Uint8Array(crypto_sign_BYTES + msg.length);
  const sm = new Uint8Array(crypto_sign_BYTES + msg.length);
  let i;
  for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
  for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];

  // Call to verification lib...
  return naclBinding.verify(m, sm, pub);
}
1234131
async def _send_chunk(self, chunk):
        
        self.__log_debug('> %s', chunk)
        await self.__transport._send_data(serialize_packet(
            self._local_port,
            self._remote_port,
            self._remote_verification_tag,
            chunk))
816337
def GET_confirmed_balance_insight( self, path_info, address ):
        
        if not BLOCKSTACK_TEST:
            return self._send_headers(status_code=404, content_type='text/plain')

        if not check_address(address):
            return self._reply_json({'error': 'Invalid address'}, status_code=400)

        res = self._get_balance(address, 1)
        if 'error' in res:
            return self._reply_json(res, status_code=502)

        return self._reply_json(res['balance'])
1057313
function () {
        if (utils.isNull(this.address)) {

            var pubKey = this.getPublicKey();
            if (pubKey.length !== 64) {
                pubKey = cryptoUtils.secp256k1.publicKeyConvert(pubKey, false).slice(1);
            }

            // The uncompressed form consists of a 0x04 (in analogy to the DER OCTET STRING tag) plus
            // the concatenation of the binary representation of the X coordinate plus the binary
            // representation of the y coordinate of the public point.
            pubKey = Buffer.concat([cryptoUtils.toBuffer(4), pubKey]);

            // Only take the lower 160bits of the hash
            var content = cryptoUtils.sha3(pubKey);
            content = cryptoUtils.ripemd160(content);
            // content = AddressPrefix + NormalType + content(local address only use normal type)
            content = Buffer.concat([cryptoUtils.toBuffer(AddressPrefix), cryptoUtils.toBuffer(NormalType), content]);
            var checksum = cryptoUtils.sha3(content).slice(0, 4);
            this.address = Buffer.concat([content, checksum]);
        }
        return this.address;
    }
435165
public static boolean isTransferEncodingChunked(HttpMessage message) {
        return message.headers().contains(HttpHeaderNames.TRANSFER_ENCODING, HttpHeaderValues.CHUNKED, true);
    }