Questions tagged [hash]
The hash tag has no usage guidance.
28
questions
4
votes
2
answers
70
views
Alternative to BlakeTwo256 for WASM Compatibility in a no_std Environment in Rust
I'm developing a Rust script that I need to convert to WebAssembly (WASM). In this script, I'm using the BlakeTwo256 hasher, which is imported from the sp_runtime crate. However, I'm unable to compile ...
0
votes
0
answers
19
views
How to verify merkle root with batch root and its adjacent_leaves inside a pallet?
I am using below code to create Merkle Root.
pub type MmrRootHash = H256;
pub fn create_merkle_root(leaves: Vec<MmrRootHash>) -> MmrRootHash {
sp_runtime::traits::BlakeTwo256::...
1
vote
1
answer
16
views
how to create merkle root of given hashes inside a pallet
I need to create merkle root of given hashes.
pub type MmrRootHash = H256;
pub fn create_merkle_root(leaves: Vec<MmrRootHash>) -> MmrRootHash {
..
}
Is there any library ...
0
votes
0
answers
23
views
Uncaught runtime errors: [u8;16]:: Expected input with 16 bytes (128 bits), found 21 bytes
I created a value id by this:
let encoded_payload = (owner.clone(), task_description.clone()).encode();
let id = frame_support::Hashable::blake2_128(&encoded_payload);// hashvalue of combined ...
1
vote
1
answer
141
views
Decode event data
I am learning to use polkadotjs api, I am trying to send a system.remarkWithEvent and then get the event that this created and decode de output to verify that the remark is there.
The sending of the ...
3
votes
1
answer
59
views
How I use Database Snapshot Services correct
I want use Database Snapshot Services, because making genesis to last block takes too much time.... so I used POLKACHU site, the code is.
" curl -o - -L https://snapshots.polkachu.com/snapshots/...
4
votes
1
answer
77
views
Why doesn't Substrate implement a CSPRNG (Cryptographically Secure Pseudorandom Number Generator)?
In the Rust documentation here it says that the hashing function that a Rust HashMap uses is SipHash. It says SipHash can provide resistance to DoS attacks involving hash tables, not that it will, ...
3
votes
2
answers
35
views
How to check if a `StorageMap` changed after the last access?
I am currently trying to iterate over a storage map over multiple blocks. For this I need to ensure that the StorageMap was not modified.
My plan is to derive a hash from the current StorageMap and ...
4
votes
1
answer
95
views
private key rotation
There's any private key rotation using substrate ? i ask this question regarding a did implementation, step are :
hash a data and signe it with an account
another account should be able to verify ...
2
votes
1
answer
61
views
TwoX128 hash for rpc.state.metadata pallet names not being a prefix for storage key
Following this tutorial: https://www.shawntabrizi.com/substrate/querying-substrate-storage-via-rpc/
we should have that a pallet named "Members" should have prefix "...
3
votes
1
answer
149
views
Is it expected that sp_core::blake2_256 gives a different result from sp_runtime::traits::BlakeTwo256?
There are (at least) two different functions for calculating a Blake2 256 hash in the Substrate codebase. More surprising is that they give different hashes for the same message. Is this intended?
...
1
vote
1
answer
106
views
Democracy proposal not enacted
First of all I am working on Polkadot-v0.9.29.
I am struggling to understand the right way to format a pallet call before submitting it as a proposal to the democracy pallet.
Let's the pallet call be ...
1
vote
1
answer
105
views
H256 to_string() function does not return complete string
I have a H256 value which is an extrinsic returned hash
0x8d19a2e575d583b8812418c71be304f16a978cfac2bfad54afcad824cb4d3471
but when i convert this to String using .to_string()
it does not return ...
1
vote
1
answer
209
views
How to use keccak256 sha256 in ink smart contracts?
I want to hash string using sha256 and then store it inside of my ink smart contract.
I tested this code in Rust and it works out for me:
use crypto::sha2::Sha256;
use crypto::digest::Digest;
let ...
2
votes
2
answers
696
views
Convert a H256 string to H256
I have a hash string "0xf8dd02cc2a3174933fac4e87d7f6360c3cc67167db105b28d0bc434a60674e49". How can i convert back to H256.
I used function below but it return difference H256 ...
0
votes
1
answer
165
views
What is the best practice for storing a hash?
I am about to make the decision on how to store some hash value inside the blockchain. A hash value is the best practice to minimise the size of the blockchain, but still allows people to verify ...
2
votes
1
answer
88
views
`sp_core::hash::H256::random()` not found
Trying to generate random 256 bytes hash-like data. But compiler tells
error[E0599]: no function or associated item named `random` found for struct `H256` in the current scope
--> /home/poh/...
4
votes
2
answers
389
views
StorageHasher: Blake2 vs Twox
When creating a StorageMap, a hashing algorithm needs to be chosen for the StorageHasher.
frame_support provides a few options:
Identity
Blake2_128
Blake2_128Concat
Blake2_256
Twox64Concat
Twox128
...
0
votes
1
answer
436
views
What is the best way to find the genesis hash for a chain?
My understanding is the following terms which are used in different contexts and applications all refer to the same thing: "genesis hash", "network key", "chain id". I ...
1
vote
1
answer
127
views
ink_env::ecdsa_recover is not returning the right public key
I am having an issue trying to verify ecdsa signature in ink! for my
test.
I am generating the signature this way
const keyring = new Keyring({type: 'ecdsa'});
const pair = keyring.addFromUri('//...
4
votes
1
answer
225
views
Can't get transaction hash from signAndSend of Polkadot.js
I'm new and I'm trying to get the transaction hash but I'm only getting undefined. I used this tutorial and this and below is my code.
const txHash = await polkadot.tx.balances
.transfer('5F1pZe........
0
votes
1
answer
53
views
Hash for an authorize-enact runtime upgrade?
Attempting a parachain runtime upgrade using .runtimes.compact.subwasm.parachain_authorize_upgrade_hash and .runtimes.compact.wasm from the [email protected] output. Enacting the runtime upgrade ends ...
6
votes
2
answers
696
views
Why could we find the same transaction hash in 3 different blocks?
We found that this transaction
0xf35238b1ef440e2a04576c8264ca8288100091a3d4c71069f0336c72078f366b was included into the following three different blocks :
10219793
10219254
10218427
Could you ...
2
votes
1
answer
122
views
How to obtain the transaction hash of each transaction
Getblock through RPC method. I can only see the block hash. But I want a hash for each transaction. What should I do?
0
votes
1
answer
60
views
Is there anyway to receive a transaction hash from a transaction that was signed by the keyring?
I am creating an application and signing an extrinsic with a keypair using the keyring. I was wondering if I can receive the transaction hash somehow after it has been signed
8
votes
1
answer
237
views
Generating a Storage Key when making an RPC request
I'm trying to make an RPC call to a Substrate node, but I can't generate a proper Storage Key. The Module and Method parts are fine, the problem is the Twox64Concat part. The sp_core::twox_64 of value ...
6
votes
3
answers
557
views
How to convert Public key (hex) to SS58 Address in JavaScript / Polkadot-JS?
I have a Public key (hex) and would like to convert it to an SS58 Address. What is the right function to use?
I found the docs here with an code-sniped: https://substrate-developer-hub.github.io/docs/...
6
votes
1
answer
53
views
How to create XOR Hashes in Substrate
Say you have two account ids Aid(A) and Aid(B) and you want to combine them.e.g. XOR( Aid(A), Aid(B) ).
Basically, I want to achieve this;
T::Hashing::hash_of(&(idA, idB)) == T::Hashing::hash_of(&...