Calculates the new nonce hash based on the current attributes.

        :param new_nonce: the new nonce to be hashed.
        :param number: number to prepend before the hash.
        :return: the hash for the given new nonce.
356612
def calc_new_nonce_hash(self, new_nonce, number):
        
        new_nonce = new_nonce.to_bytes(32, 'little', signed=True)
        data = new_nonce + struct.pack('<BQ', number, self.aux_hash)

        # Calculates the message key from the given data
        return int.from_bytes(sha1(data).digest()[4:20], 'little', signed=True)
1323170
def create_from_hash(hash, ezo):
        '''
        
        '''

        cp, err = ezo.db.get("contracts", hash)
        if err:
            return None, err

        # create a new Contract
        c = Contract(cp["name"], ezo)
        c.abi = cp["abi"]
        c.bin = cp["bin"]
        c.hash = cp["hash"]
        c.source = cp["source"]
        c.timestamp = cp["timestamp"]
        c.te_map = cp['te-map']

        return c, None
25339
def validate_nonce(nonce, secret):
    '''
    
    '''
    nonce_components = nonce.split(':', 2)
    if not len(nonce_components) == 3:
        return False
    timestamp = nonce_components[0]
    salt = nonce_components[1]
    nonce_signature = nonce_components[2]

    calculated_nonce = calculate_nonce(timestamp, secret, salt)

    if not nonce == calculated_nonce:
        return False

    return True
1103430
def schnorr_generate_nonce_pair(self, msg, raw=False,
                                    digest=hashlib.sha256):
        
        if not HAS_SCHNORR:
            raise Exception("secp256k1_schnorr not enabled")

        msg32 = _hash32(msg, raw, digest)
        pubnonce = ffi.new('secp256k1_pubkey *')
        privnonce = ffi.new('char [32]')

        valid = lib.secp256k1_schnorr_generate_nonce_pair(
            self.ctx, pubnonce, privnonce, msg32, self.private_key,
            ffi.NULL, ffi.NULL)
        assert valid == 1

        return pubnonce, privnonce
872509
def derive(number)
      new_key = ExtPubkey.new
      new_key.depth = depth + 1
      new_key.number = number
      new_key.parent_fingerprint = fingerprint
      raise 'hardened key is not support' if number > (HARDENED_THRESHOLD - 1)
      data = pub.htb << [number].pack('N')
      l = Bitcoin.hmac_sha512(chain_code, data)
      left = l[0..31].bth.to_i(16)
      raise 'invalid key' if left >= CURVE_ORDER
      p1 = Bitcoin::Secp256k1::GROUP.generator.multiply_by_scalar(left)
      p2 = Bitcoin::Key.new(pubkey: pubkey, key_type: key_type).to_point
      new_key.pubkey = ECDSA::Format::PointOctetString.encode(p1 + p2, compression: true).bth
      new_key.chain_code = l[32..-1]
      new_key.ver = version
      new_key
    end
144766
def new(cls, signatures: [Signature]) -> 'MultiSignature':
        
        logger = logging.getLogger(__name__)
        logger.debug("MultiSignature::new: >>>")

        # noinspection PyCallingNonCallable,PyTypeChecker
        signature_c_instances = (c_void_p * len(signatures))()
        for i in range(len(signatures)):
            signature_c_instances[i] = signatures[i].c_instance

        c_instance = c_void_p()
        do_call(cls.new_handler, signature_c_instances, len(signatures), byref(c_instance))

        res = cls(c_instance)

        logger.debug("MultiSignature::new: <<< res: %r", res)
        return res
183804
def change_version_byte(address, new_version=None, new_crypto=None):
    
    if not new_version and new_crypto:
        try:
            new_version = crypto_data[new_crypto]['address_version_byte']
        except KeyError:
            raise CurrencyNotSupported("Unknown currency symbol: " + new_crypto)

        if not new_version:
            raise CurrencyNotSupported("Can't yet make %s addresses." % new_crypto)

    payload = b58decode_check(address)[1:]
    if is_py2:
        byte = chr(new_version)
    else:
        byte = bytes(chr(new_version), 'ascii')

    return b58encode_check(byte + payload)
443378
def check_nonce(self, nonce):
        
        lower, upper = self.nonce_length
        return (set(nonce) <= self.safe_characters and
                lower <= len(nonce) <= upper)
309715
def new(self, extension_sequence):
        # type: (int) -> None
        '''
        
        '''
        if self._initialized:
            raise pycdlibexception.PyCdlibInternalError('ES record already initialized!')

        self.extension_sequence = extension_sequence
        self._initialized = True
1125820
def to_hash
      _new_hash = ::Hash.new
      set_defaults(_new_hash)

      each do |key, value|
        _new_hash[key] = convert_value(value, for: :to_hash)
      end
      _new_hash
    end
596037
public static String createNonceCookieValue(String nonceValue, String state, ConvergedClientConfig clientConfig) {
        return HashUtils.digest(nonceValue + state + clientConfig.getClientSecret());
    }
704646
def get_last_nonce(app, key, nonce):
    
    uk = ses.query(um.UserKey).filter(um.UserKey.key==key)\
            .filter(um.UserKey.last_nonce<nonce * 1000).first()
    if not uk:
        return None
    lastnonce = copy.copy(uk.last_nonce)
    # TODO Update DB record in same query as above, if possible
    uk.last_nonce = nonce * 1000
    try:
        ses.commit()
    except Exception as e:
        current_app.logger.exception(e)
        ses.rollback()
        ses.flush()
    return lastnonce
202290
def newAddress(self, currency='btc', label=''):
        
        request = '/v1/deposit/' + currency + '/newAddress'
        url = self.base_url + request
        params = {
            'request': request,
            'nonce': self.get_nonce()
        }

        if label != '':
            params['label'] = label

        return requests.post(url, headers=self.prepare(params))
191321
def _hash(number, alphabet):
    """"""
    hashed = ''
    len_alphabet = len(alphabet)
    while True:
        hashed = alphabet[number % len_alphabet] + hashed
        number //= len_alphabet
        if not number:
            return hashed
384192
def generate_nonce():
        
        nonce = ''.join([str(randint(0, 9)) for i in range(8)])
        return HMAC(
            nonce.encode(),
            "secret".encode(),
            sha1
        ).hexdigest()
639855
def pack_balance_proof_update(
        nonce: Nonce,
        balance_hash: BalanceHash,
        additional_hash: AdditionalHash,
        canonical_identifier: CanonicalIdentifier,
        partner_signature: Signature,
) -> bytes:
    
    return pack_balance_proof(
        nonce=nonce,
        balance_hash=balance_hash,
        additional_hash=additional_hash,
        canonical_identifier=canonical_identifier,
        msg_type=MessageTypeId.BALANCE_PROOF_UPDATE,
    ) + partner_signature
49483
def _update_nonce_explicit(self):
        
        ne = self.nonce_explicit + 1
        self.nonce_explicit = ne % 2**(self.nonce_explicit_len * 8)