Base58: regroup prefix definition.

This commit is contained in:
Grégoire Henry 2018-04-18 09:34:00 +02:00
parent 11ad8fa8ea
commit 40e63739ac
3 changed files with 7 additions and 2 deletions

View File

@ -327,6 +327,7 @@ module Prefix = struct
let ed25519_secret_key = "\043\246\078\007" (* edsk(98) *)
let ed25519_signature = "\009\245\205\134\018" (* edsig(99) *)
let secp256k1_signature = "\013\115\101\019\063" (* spsig1(99) *)
let generic_signature = "\004\130\043" (* sig(96) *)
(* 4 *)
let chain_id = "\087\082\000" (* Net(15) *)

View File

@ -27,6 +27,7 @@ module Prefix : sig
val secp256k1_public_key: string
val secp256k1_secret_key: string
val secp256k1_signature: string
val generic_signature: string
val chain_id: string
end

View File

@ -348,12 +348,15 @@ let of_string_opt s = of_bytes_opt (MBytes.of_string s)
type Base58.data += Data of t
let b58check_encoding =
Base58.register_encoding
~prefix: "\004\130\043"
~length: 96
~prefix: Base58.Prefix.generic_signature
~length: Ed25519.size
~to_raw: to_string
~of_raw: of_string_opt
~wrap: (fun x -> Data x)
let () =
Base58.check_encoded_prefix b58check_encoding "sig" 96
include Helpers.MakeRaw(struct
type nonrec t = t
let name = name