Clarified README
This commit is contained in:
parent
6b591947d0
commit
e1d0a2d6d2
1 changed files with 11 additions and 26 deletions
37
README.md
37
README.md
|
@ -1,6 +1,8 @@
|
||||||
# PoW-SHA256
|
# PoW-SHA256
|
||||||
|
|
||||||
Rust crate which generates SHA256 Proofs of Work on serializable datatypes. Any type that implements `serde::Deserialize` can be used.
|
Rust crate which generates SHA256 Proofs of Work on serializable datatypes.
|
||||||
|
|
||||||
|
Any type that implements `serde::Deserialize` can be used.
|
||||||
|
|
||||||
This is a fork of the [`Pow` library](https://github.com/bddap/pow) by bddap with some new additions. Primary of these being:
|
This is a fork of the [`Pow` library](https://github.com/bddap/pow) by bddap with some new additions. Primary of these being:
|
||||||
|
|
||||||
|
@ -45,33 +47,16 @@ struct Block<T> {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
# Score scheme
|
# Hashing Scheme
|
||||||
|
|
||||||
To score a proof of work for a given (target, PoW) pair:
|
SHA256 is calculated over the concatenation of the:
|
||||||
Sha256 is calculated over the concatenation SALT + target + PoW.
|
- SALT
|
||||||
The first 16 bytes of the hash are interpreted as a 128 bit unsigned integer.
|
- Serialized Input `T`
|
||||||
That integer is the score.
|
- Nonce
|
||||||
A constant, SALT, is used as prefix to prevent PoW reuse from other systems such as proof
|
|
||||||
of work blockchains.
|
|
||||||
|
|
||||||
In other words:
|
The first 16 bytes of the resulting hash are interpreted as a 128 bit unsigned integer.
|
||||||
|
|
||||||
```rust
|
A randomly generated constant, `SALT`, is used as prefix to prevent PoW reuse from other systems such as proof of work blockchains.
|
||||||
fn score<T: Serialize>(target: &T, PoW_tag: &PoW<T>) -> u128 {
|
|
||||||
let bytes = serialize(&SALT) + serialize(target) + serialize(PoW_tag);
|
|
||||||
let hash = sha256(&bytes);
|
|
||||||
deserialize(&hash[..16])
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
# Serialization encoding.
|
|
||||||
|
|
||||||
It shouldn't matter to users of this library, but the bincode crate is used for cheap
|
|
||||||
deterministic serialization. All values are serialized using network byte order.
|
|
||||||
|
|
||||||
# Threshold scheme
|
|
||||||
|
|
||||||
Given a minimum score m. A PoW p satisfies the minimum score for target t iff score(t, p) >= m.
|
|
||||||
|
|
||||||
# Choosing a difficulty setting.
|
# Choosing a difficulty setting.
|
||||||
|
|
||||||
|
@ -102,4 +87,4 @@ fn average(difficulty: u128) -> u128 {
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
This project is licensed under either of Apache License, Version 2.0 or MIT license, at your option.
|
This project is dual-licensed under `Apache License Version 2.0` & `MIT license`.
|
||||||
|
|
Loading…
Reference in a new issue