def big_map_query(self, path): """ Construct a query for big_map_get request :param path: BigMap key, string, int, or hex-string (since Babylon you can have more than one BigMap at arbitrary position) :param storage: :return: dict """ key = basename(path) big_map_path = dirname(path) big_map_id = self.big_map_id(join('/', big_map_path)) if big_map_path else None key_prim, _, _ = self._locate_big_map(big_map_id) encoded_key = encode_literal(key, key_prim) if big_map_id: query = dict( big_map_id=big_map_id, script_expr=base58_encode(blake2b_32(encoded_key.encode()), b'expr') ) else: query = dict( key=encoded_key, type={'prim': key_prim} ) return query
def hash(self): """ Calculate the Base58 encoded operation group hash. :return: str """ hash_digest = blake2b_32(self.binary_payload()).digest() return base58_encode(hash_digest, b'o').decode()
def get_key_hash(val_expr, type_expr, bin_path='') -> str: """ Get Big_map key hash from key and its type :param val_expr: key expression (Micheline expression) :param type_expr: type expression (can be key type or type of the whole storage) :param bin_path: binary path to the key (if storage type is passed to the prev argument) :returns: Base58 encoded key hash "expr..." """ for idx in bin_path: assert isinstance(type_expr, dict), f'type expression contains dict nodes only' type_expr = type_expr['args'][int(idx)] data = blake2b_32(pack(val_expr, type_expr)).digest() return base58_encode(data, b'expr').decode()
def calculate_pow_stamp(self): hash_digest = blake2b_32(self.forge() + '0' * 128).digest() return int.from_bytes(hash_digest, byteorder='big')
def calculate_hash(self): hash_digest = blake2b_32(self.raw()).digest() return base58_encode(hash_digest, b'B').decode()
def calculate_hash(self): hash_digest = blake2b_32(proto_to_bytes(self())).digest() return base58_encode(hash_digest, b'P').decode()
def hash(self): hash_digest = blake2b_32(proto_to_bytes(self._proto)).digest() return base58_encode(hash_digest, b'P').decode()
def calculate_hash(self): hash_digest = blake2b_32(self.signed_bytes()).digest() return base58_encode(hash_digest, b'o').decode()
def get_key_hash(val_expr, type_expr): data = blake2b_32(pack(val_expr, type_expr)).digest() return base58_encode(data, b'expr').decode()
def do_blake2b(ctx: Context, prim, args, annots): top = ctx.pop1() assert_stack_type(top, Bytes) res = Bytes(crypto.blake2b_32(bytes(top)).digest()) ctx.push(res, annots=annots)