Crypto: replace nocrypto sha256 with hacl
This commit is contained in:
parent
b619b29483
commit
5a26d23cf7
@ -65,20 +65,20 @@ module Step : sig
|
|||||||
|
|
||||||
end = struct
|
end = struct
|
||||||
|
|
||||||
type state = int * int * Cstruct.t
|
type state = int * int * MBytes.t
|
||||||
|
|
||||||
let init seed head =
|
let init seed head =
|
||||||
let seed =
|
let open Hacl.Hash in
|
||||||
Nocrypto.Hash.digest `SHA256 @@
|
let st = SHA256.init () in
|
||||||
Cstruct.concat
|
List.iter (SHA256.update st) [
|
||||||
[ Cstruct.of_bigarray @@ P2p_peer.Id.to_bytes seed.sender_id ;
|
P2p_peer.Id.to_bytes seed.sender_id ;
|
||||||
Cstruct.of_bigarray @@ P2p_peer.Id.to_bytes seed.receiver_id ;
|
P2p_peer.Id.to_bytes seed.receiver_id ;
|
||||||
Cstruct.of_bigarray @@ Block_hash.to_bytes head ] in
|
Block_hash.to_bytes head ] ;
|
||||||
(1, 9, seed)
|
(1, 9, SHA256.finish st)
|
||||||
|
|
||||||
let draw seed n =
|
let draw seed n =
|
||||||
Int32.to_int (MBytes.get_int32 (Cstruct.to_bigarray seed) 0) mod n,
|
Int32.to_int (MBytes.get_int32 seed 0) mod n,
|
||||||
Nocrypto.Hash.digest `SHA256 seed
|
Hacl.Hash.SHA256.digest seed
|
||||||
|
|
||||||
let next (step, counter, seed) =
|
let next (step, counter, seed) =
|
||||||
let random_gap, seed =
|
let random_gap, seed =
|
||||||
|
@ -112,11 +112,9 @@ let raw_decode ?(alphabet=Alphabet.default) s =
|
|||||||
|
|
||||||
let checksum s =
|
let checksum s =
|
||||||
let hash =
|
let hash =
|
||||||
Nocrypto.Hash.digest `SHA256 @@
|
Hacl.Hash.SHA256.(digest (digest (Bigstring.of_string s))) in
|
||||||
Nocrypto.Hash.digest `SHA256 @@
|
|
||||||
Cstruct.of_string s in
|
|
||||||
let res = Bytes.make 4 '\000' in
|
let res = Bytes.make 4 '\000' in
|
||||||
Cstruct.blit_to_bytes hash 0 res 0 4 ;
|
Bigstring.blit_to_bytes hash 0 res 0 4 ;
|
||||||
Bytes.to_string res
|
Bytes.to_string res
|
||||||
|
|
||||||
(* Append a 4-bytes cryptographic checksum before encoding string s *)
|
(* Append a 4-bytes cryptographic checksum before encoding string s *)
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
tezos-rpc
|
tezos-rpc
|
||||||
tezos-clic
|
tezos-clic
|
||||||
lwt
|
lwt
|
||||||
nocrypto
|
|
||||||
blake2
|
blake2
|
||||||
hacl
|
hacl
|
||||||
secp256k1
|
secp256k1
|
||||||
|
@ -15,7 +15,6 @@ depends: [
|
|||||||
"tezos-rpc"
|
"tezos-rpc"
|
||||||
"tezos-clic"
|
"tezos-clic"
|
||||||
"lwt"
|
"lwt"
|
||||||
"nocrypto"
|
|
||||||
"blake2"
|
"blake2"
|
||||||
"hacl"
|
"hacl"
|
||||||
"zarith"
|
"zarith"
|
||||||
|
Loading…
Reference in New Issue
Block a user