Skip to content

Instantly share code, notes, and snippets.

@smondet
Last active November 12, 2020 23:24
Show Gist options
  • Save smondet/96415b8b67d4421e7c546e4381a8ddf0 to your computer and use it in GitHub Desktop.
Save smondet/96415b8b67d4421e7c546e4381a8ddf0 to your computer and use it in GitHub Desktop.
;;
#require "fmt"
;;
#require "base"
open Base
let make metaseed =
let of_seed seed =
try
let pkh, pk, sk =
Tezos_crypto.Ed25519.generate_key ~seed:(Bytes.of_string seed) ()
in
Some
( seed,
Tezos_crypto.Ed25519.Public_key_hash.to_b58check pkh,
Tezos_crypto.Ed25519.Secret_key.to_b58check sk )
with _ -> None
in
let all =
let clean = String.filter ~f:(function '.' | ' ' -> false | _ -> true) in
let odd s =
let x = ref 0 in
String.filter
~f:(function
| _ when !x % 2 = 1 ->
Caml.incr x;
true
| _ ->
Caml.incr x;
false)
s
in
let even s =
let x = ref 0 in
String.filter
~f:(function
| _ when !x % 2 = 0 ->
Caml.incr x;
true
| _ ->
Caml.incr x;
false)
s
in
let blake2b s =
Tezos_crypto.Blake2B.hash_string [ s ] |> Tezos_crypto.Blake2B.to_string
in
let sha256 s =
Tezos_crypto.Hacl.Hash.SHA256.digest (Bytes.of_string s)
|> Bytes.to_string
in
let mirror s = s ^ String.rev s in
List.filter_map ~f:of_seed
[
metaseed;
String.lowercase metaseed;
String.uppercase metaseed;
clean metaseed;
String.lowercase (clean metaseed);
String.uppercase (clean metaseed);
odd metaseed;
odd (String.lowercase metaseed);
even metaseed;
even (String.lowercase metaseed);
blake2b metaseed;
blake2b (String.lowercase metaseed);
blake2b (String.uppercase metaseed);
sha256 metaseed;
sha256 (String.lowercase metaseed);
sha256 (String.uppercase metaseed);
String.rev metaseed;
String.rev (String.lowercase metaseed);
String.rev (String.uppercase metaseed);
mirror metaseed;
mirror (String.lowercase metaseed);
mirror (String.uppercase metaseed);
]
in
let truth = "tz1V7rDn1uhSnGPnfj3ebuHS5nqjYEBU3QGF" in
Fmt.pr "Metaseed: %S\n" metaseed;
List.iter all ~f:(fun (seed, pkh, sk) ->
Fmt.pr "%s %s (%S, %d)%s\n%!" pkh sk seed (String.length seed)
(if String.equal truth pkh then failwith seed else ""))
let () =
make "Pray to the Winds. They will prove to be mighty allies of Greece.";
make "Pray to the Winds.\nThey will prove to be mighty allies of Greece.";
make "Pray to the Winds.";
make ": Pray to the Winds. They will prove to be mighty allies of Greece.";
make "They will prove to be mighty allies of Greece.";
()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment