revert beacon.rs to version a42ef24fc5

This commit is contained in:
jiangyuanshu 2020-05-22 19:43:15 +08:00
parent 6d18e24e00
commit 08cb7b6ebb
1 changed files with 2 additions and 29 deletions

View File

@ -7,8 +7,6 @@ extern crate byteorder;
#[macro_use]
extern crate hex_literal;
extern crate crypto;
use std::fs::File;
use std::io::{BufWriter, BufReader};
use blake2_rfc::blake2b::Blake2b;
@ -34,34 +32,9 @@ fn main() {
use byteorder::{ReadBytesExt, BigEndian};
use rand::{SeedableRng};
use rand::chacha::ChaChaRng;
use crypto::sha2::Sha256;
use crypto::digest::Digest;
// Place block hash here (block number #631600)
// choose block number BTC #631600 at 2020-05-21 15:00:00 UTC+8
// block #631600 generates at ?
// generate beacon successfully at ?
let mut beacon_value: [u8; 32] = hex!("00000000000000000008de28ff08672c5b85add6d51024b90fa9424dadc82691");
// Performs 2^n hash iterations over it
const N: usize = 32;
for i in 0..(1u64<<N) {
// Print 1024 of the interstitial states
// so that verification can be
// parallelized
if i % (1u64<<(N-10)) == 0 {
print!("{}: ", i);
for b in beacon_value.iter() {
print!("{:02x}", b);
}
println!("");
}
let mut h = Sha256::new();
h.input(&beacon_value);
h.result(&mut beacon_value);
}
// Place beacon value here (2^42 SHA256 hash of Bitcoin block hash #534861)
let beacon_value: [u8; 32] = hex!("2bf41a959668e5b9b688e58d613b3dcc99ee159a880cf764ec67e6488d8b8af3");
print!("Final result of beacon: ");
for b in beacon_value.iter() {