Hot answers tagged

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 = ...
user avatar
  • 869
8 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 ...
user avatar
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 ...
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) ...
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='foo@bar.com') key.public_key_hash() >>&...
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 ...
user avatar
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 ...
user avatar
  • 2,348
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)
user avatar
  • 2,348
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.
user avatar
  • 3,185
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 ...
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'...
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 ...
user avatar
  • 2,348
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 ...
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 ...
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....
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).
user avatar
  • 3,364
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; ...
user avatar
  • 95
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). ...
user avatar

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