Hot answers tagged

9 votes

How are the originated contract addreses (KT1) computed?

In case someone needs precise calculations. Say, you have an operation group hash onvsLP3JFZia2mzZKWaFuFkWg2L5p3BDUhzh5Kr6CiDDN3rtQ1D and an origination index 0 which is increased for every ...
Michael Zaikin's user avatar
8 votes

How to hash a Tezos public key

Heres how to do it in python, where the variable pubkey is the bytes array of the public key P2HASH_MAGIC = bytes.fromhex('06a1a4') blake2bhash = blake2b(pubkey, digest_size=20).digest() shabytes = ...
Bo Byrd's user avatar
  • 879
7 votes

How are the originated contract addreses (KT1) computed?

KT1 addresses are computed from origination nonce. The origination nonce is made of operation hash (the operation that creates the origination) and its index (the index starts from 0 and it gets ...
Tomáš Zemanovič's user avatar
7 votes

How is the hash code of blocks generated?

Take a byte representation of a particular block header: http://rpc.tzkt.io/mainnet/chains/main/blocks/head/header/raw. The format of the block header is described in the docs. Get a BLAKE2b (32bit) ...
Michael Zaikin's user avatar
5 votes

How to hash a Tezos public key

Do you have the tezos repo built? If yes, you can run the ocaml CLI with tezos-crypto: $ dune utop src/lib_crypto and then: ocaml# open Tezos_crypto;; ocaml# Ed25519.Public_key.of_b58check_exn ...
Seb Mondet's user avatar
5 votes

Creating public key hash

Try https://github.com/murbard/pytezos/blob/master/pytezos/crypto.py from pytezos.crypto import Key key = Key(key='mnemonic', passphrase='******', email='[email protected]') key.public_key_hash() >>&...
Michael Zaikin's user avatar
4 votes

How to hash a Tezos public key

In python, using the git version of pytezos: from pytezos.crypto import Key public_key = 'edpkuoK2J2UVbDcSTdJgP85JmDN3gxBCswcgApbtY5d7zHVunwCKNR' hash = Key(public_key).public_key_hash() print(hash)
arvidj's user avatar
  • 2,378
4 votes

Properties of transaction hashes

I was unable to find a complete answer, but here are some pointers. First, to clarify, I think you're asking about the format of operation hashes. A block consists of a set of operations. An operation ...
arvidj's user avatar
  • 2,378
4 votes
Accepted

Get transaction detail from transaction hash in Tezos api

You can use TzKt's API for this. Transaction by Hash will get the transaction details, and Operation by Hash will get you any kind of operation details on Tezos. Examples: https://api.tzkt.io/v1/...
Ojuswi Rastogi's user avatar
3 votes

Which hash function is used when converting an address from raw bytes?

It’s not hashed. You simply need to compute the base58 translation with the right prefix. Proof that it’s not hashed: this process is reversible.
FFF's user avatar
  • 3,260
3 votes
Accepted

Converting a hash into an int within a range

There is no instruction in Michelson to interpret arbitrary bytes as numbers. The simplest way to achieve what you want is to use a constant table (as a Michelson map) from bytes of length 1 to their ...
Raphaël Cauderlier's user avatar
3 votes
Accepted

Pseudo-random numbers for NFT attribute random generation

So my specific questions: Is there a way to get the next block hash within a smart contract? No, there is no instruction in Michelson to query a block hash. Or some other way to get a value that isn'...
Raphaël Cauderlier's user avatar
2 votes
Accepted

Ledger Blake2b hash calculation

tl;dr: we serialize the michelson value to binary, we then hash those bytes it with Blake2b-256. We base58 encode the result. Long version Let's consider the case of the Ledger Blake2b has of the ...
arvidj's user avatar
  • 2,378
1 vote

Manipulable block hash by baker

blockhash can be manipulated by every single endorser. It should be avoided to be used as source of entropy.
Papers.ch's user avatar
1 vote

Choosing to validate a block or not & block hash ceation

I have block A, block B and block C. A baker is elected to bake the block B and C. You first have the bakers who are supposed to bake at given levels and rounds, and then later you may have or not ...
Eugen's user avatar
  • 1,000
1 vote

How to hash a Tezos public key

In NodeJS it is also possible to do it using sotez: import {Key} from 'sotez'; const sotezKey = new Key({ key: 'edpktx799pgw7M4z8551URER52VcENNCSZwE9f9cst4v6h5vCrQmJE' }); await sotezKey.ready; ...
K SS's user avatar
  • 95
1 vote

Authenticating users in contracts

You might want to have a look at the solution used in the Multisig contract supported by tezos-client. It is documented here. In essence: you can check signatures in Michelson using the ...
Raphaël Cauderlier's user avatar
1 vote
Accepted

Authenticating users in contracts

Yes, the original solution is unsafe. Cross checking the sender address of the hash is really important. Infact, the recent Wormhole Hack on a Solana contract was caused due to a vulnerability closely ...
Anshu Jalan's user avatar
1 vote
Accepted

Test vectors for calculating operation hash

You can test against the data that the official Tezos project uses for regression testing. This file might be of interest: https://gitlab.com/tezos/tezos/-/blob/master/tezt/_regressions/protocol.alpha....
Troels Bjørnskov's user avatar
1 vote

How to I get my Public Hash Keys

The PDF you received from the ICO contains everything you need to activate your address, including your public hash (starts with tz1, tz2, or tz3).
utdrmac's user avatar
  • 3,422
1 vote

How to get hash of operation without injecting in chain

You can forge operations remotly using a node, with the rpc : /chains/main/blocks/head/helpers/forge/operations. This is a POST request, you have to give a json file like: { "branch" : block_hash, "...
ocpmax's user avatar
  • 204
1 vote

How is the hash code of blocks generated?

Part 1 of my question was answered by Michael. What about the second part? Well, I just had a look at it. What I did is: extract the full series of hash codes, from block 1 to the latest (VERY LONG). ...
luchonacho's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible