Skip to content

Commit

Permalink
Merge pull request #7738 from MinaProtocol/fix/vary-signature-for-mai…
Browse files Browse the repository at this point in the history
…nnet

Vary signature for mainnet
  • Loading branch information
mrmr1993 authored Feb 2, 2021
2 parents 12ee9bd + 65b9f9e commit 718eba4
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/config/features/dev.mlh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[%%define feature_tokens true]
[%%define feature_snapps true]

[%%define mainnet false]
2 changes: 1 addition & 1 deletion src/config/features/mainnet.mlh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[%%define feature_tokens false]
[%%define feature_snapps false]

[%%define mainnet true]
3 changes: 3 additions & 0 deletions src/config/features/public_testnet.mlh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[%%define feature_tokens false]
[%%define feature_snapps false]
[%%define mainnet false]
2 changes: 1 addition & 1 deletion src/config/testnet_postake_medium_curves.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
[%%define daemon_expiry "2024-12-10 14:00:00-07:00"]
[%%define test_full_epoch false]
[%%import "/src/config/fork.mlh"]
[%%import "/src/config/features/mainnet.mlh"]
[%%import "/src/config/features/public_testnet.mlh"]
(* 2*block_window_duration *)
[%%define compaction_interval 360000]
2 changes: 1 addition & 1 deletion src/lib/hash_prefix_states/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
(libraries snark_params mina_compile_config random_oracle)
(preprocessor_deps ../../config.mlh)
(preprocess
(pps ppx_snarky ppx_version ppx_optcomp ppx_inline_test ppx_deriving.eq ppx_deriving_yojson))
(pps ppx_custom_printf ppx_snarky ppx_version ppx_optcomp ppx_inline_test ppx_deriving.eq ppx_deriving_yojson))
(instrumentation (backend bisect_ppx))
(synopsis "Values corresponding to the internal state of the Pedersen hash function on the prefixes used in Coda"))
11 changes: 10 additions & 1 deletion src/lib/hash_prefix_states/hash_prefix_states.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,16 @@ let coinbase_merkle_tree =

let vrf_message = salt vrf_message

let signature = salt signature
[%%if
mainnet]

let signature = salt signature_mainnet

[%%else]

let signature = salt signature_testnet

[%%endif]

let vrf_output = salt vrf_output

Expand Down
4 changes: 3 additions & 1 deletion src/lib/hash_prefixes/hash_prefixes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ let base_snark = create "CodaBaseSnark"

let transition_system_snark = create "CodaTransitionSnark"

let signature = create "CodaSignature"
let signature_testnet = create "CodaSignature"

let signature_mainnet = create "MinaSignatureMainnet"

let receipt_chain_user_command = create "CodaReceiptUC"

Expand Down
16 changes: 15 additions & 1 deletion src/lib/signature_lib/schnorr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,26 @@ module Message = struct

type t = (Field.t, bool) Random_oracle.Input.t [@@deriving sexp]

[%%if
mainnet]

let network_id = Char.of_int_exn 1

[%%else]

let network_id = Char.of_int_exn 0

[%%endif]

let derive t ~private_key ~public_key =
let input =
let x, y = Tick.Inner_curve.to_affine_exn public_key in
Random_oracle.Input.append t
{ field_elements= [|x; y|]
; bitstrings= [|Tock.Field.unpack private_key|] }
; bitstrings=
[| Tock.Field.unpack private_key
; Fold_lib.Fold.(
to_list (string_bits (String.of_char network_id))) |] }
in
Random_oracle.Input.to_bits ~unpack:Field.unpack input
|> Array.of_list |> Blake2.bits_to_string |> Blake2.digest_string
Expand Down

0 comments on commit 718eba4

Please sign in to comment.