Merge pull request #14 from aeternity/add-verify_proof_from_hash

Add verify_proof_from_hash/4
This commit is contained in:
Juraj Hlista 2019-05-24 08:35:00 +00:00 committed by GitHub
commit 90b7ef8e76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,6 +29,7 @@
generate_from_hash/5, generate_from_hash/5,
verify/5, verify/5,
verify_proof/4, verify_proof/4,
verify_proof_from_hash/4,
get_target/2 get_target/2
]). ]).
@ -226,6 +227,10 @@ verify_proof(Data, Nonce, Solution, EdgeBits) ->
%% Cuckoo has an 80 byte header, we have to use that as well %% Cuckoo has an 80 byte header, we have to use that as well
%% packed Hash + Nonce = 56 bytes, add 24 bytes of 0:s %% packed Hash + Nonce = 56 bytes, add 24 bytes of 0:s
Hash = aeminer_blake2b_256:hash(Data), Hash = aeminer_blake2b_256:hash(Data),
verify_proof_from_hash(Hash, Nonce, Solution, EdgeBits).
-spec verify_proof_from_hash(hash(), nonce(), solution(), edge_bits()) -> boolean().
verify_proof_from_hash(Hash, Nonce, Solution, EdgeBits) ->
Header0 = pack_header_and_nonce(Hash, Nonce), Header0 = pack_header_and_nonce(Hash, Nonce),
Header = <<(list_to_binary(Header0))/binary, 0:(8*24)>>, Header = <<(list_to_binary(Header0))/binary, 0:(8*24)>>,
verify_proof_(Header, Solution, EdgeBits). verify_proof_(Header, Solution, EdgeBits).