-
Notifications
You must be signed in to change notification settings - Fork 550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rosetta-compatible signer.exe #5863
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fa1c1b6
rosetta/leverage-docker-caching Leverage docker caching to speed up d…
lk86 d4cf4f1
Merge remote-tracking branch 'origin/develop' into rosetta/leverage-d…
lk86 3ee8e52
WIP
bkase ddf5683
Forgot to add signer.ml
bkase a090577
Adds signer.opam
bkase 9f012e2
Merge remote-tracking branch 'origin/develop' into rosetta/mini-signe…
bkase 2d8714e
Also builds rosetta with archive node
bkase b893ed9
Changes signature scheme to match rosetta-spec name
bkase a9b98ba
Merge remote-tracking branch 'origin/develop' into rosetta/mini-signe…
bkase 7a8c905
Merge remote-tracking branch 'origin/rosetta/mini-signer-exe' into ro…
bkase 081177c
Merge pull request #5864 from CodaProtocol/rosetta/proper-name
lk86 73fe952
rosetta/mini-signer-exe Address nits
lk86 20dd27b
Merge branch 'develop' into rosetta/leverage-docker-caching
lk86 4ac1ef1
Merge branch 'develop' into rosetta/mini-signer-exe
mergify[bot] 33eebd5
Merge pull request #5865 from CodaProtocol/rosetta/leverage-docker-ca…
lk86 2d8db72
rosetta/mini-signer-exe Fix mkdir error
lk86 2b09b51
rosetta/mini-signer-exe Pull docker image to use as cache
lk86 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
yojson | ||
archive_lib | ||
signature_lib | ||
secrets | ||
unsigned_extended | ||
) | ||
(preprocess (pps | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
(executable | ||
(package signer) | ||
(name signer) | ||
(public_name signer) | ||
(modes native) | ||
(libraries | ||
async | ||
async_ssl | ||
core_kernel | ||
logger | ||
rosetta_models | ||
lib | ||
ppx_deriving_yojson.runtime | ||
yojson | ||
) | ||
(preprocess (pps | ||
graphql_ppx | ||
ppx_coda | ||
ppx_deriving.show | ||
ppx_deriving_yojson | ||
ppx_jane | ||
ppx_version | ||
ppx_deriving.eq | ||
)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
(** An agent that pokes at Coda and peeks at Rosetta to see if things look alright *) | ||
|
||
open Core_kernel | ||
open Async | ||
open Rosetta_lib | ||
open Signature_lib | ||
open Lib | ||
|
||
let sign_command = | ||
let open Command.Let_syntax in | ||
let%map_open unsigned_transaction = | ||
flag "unsigned-transaction" | ||
~doc:"Unsigned transaction string returned from Rosetta" | ||
(required string) | ||
and private_key = | ||
flag "private-key" ~doc:"Private key hex bytes" (required string) | ||
in | ||
let open Deferred.Let_syntax in | ||
fun () -> | ||
let keys = Signer.Keys.of_private_key_bytes private_key in | ||
match | ||
Signer.sign ~keys ~unsigned_transaction_string:unsigned_transaction | ||
with | ||
| Ok signature -> | ||
printf "%s\n" signature ; return () | ||
| Error e -> | ||
eprintf "Failed to sign transaction %s" (Errors.show e) ; | ||
exit 1 | ||
|
||
let verify_command = | ||
let open Command.Let_syntax in | ||
let%map_open signed_transaction = | ||
flag "signed-transaction" | ||
~doc:"Signed transaction string returned from Rosetta" (required string) | ||
and public_key = | ||
flag "public-key" ~doc:"Public key hex bytes" (required string) | ||
in | ||
let open Deferred.Let_syntax in | ||
fun () -> | ||
match | ||
Signer.verify ~public_key_hex_bytes:public_key | ||
~signed_transaction_string:signed_transaction | ||
with | ||
| Ok b when b -> | ||
return () | ||
| Ok _b (* when not _b *) -> | ||
eprintf "Signature does not verify against this public key" ; | ||
exit 1 | ||
| Error e -> | ||
eprintf "Failed to verify signature %s" (Errors.show e) ; | ||
exit 1 | ||
|
||
let derive_command = | ||
let open Command.Let_syntax in | ||
let%map_open private_key = | ||
flag "private-key" ~doc:"Private key hex bytes" (required string) | ||
in | ||
let open Deferred.Let_syntax in | ||
fun () -> | ||
printf "%s\n" | ||
Signer.Keys.(of_private_key_bytes private_key).public_key_hex_bytes ; | ||
return () | ||
|
||
let generate_command = | ||
let open Deferred.Let_syntax in | ||
Command.Param.return | ||
@@ fun () -> | ||
let keypair = Keypair.create () in | ||
printf "%s\n" Signer.Keys.(of_keypair keypair |> to_private_key_bytes) ; | ||
return () | ||
|
||
let () = | ||
Command.run | ||
(Command.group | ||
~summary:"OCaml reference signer implementation for Rosetta." | ||
[ ( "sign" | ||
, Command.async ~summary:"Sign an unsigned transaction" sign_command | ||
) | ||
; ( "verify" | ||
, Command.async | ||
~summary: | ||
"Verify the signature of a signed transaction. Exits 0 if the \ | ||
signature verifies." | ||
verify_command ) | ||
; ( "derive-public-key" | ||
, Command.async ~summary:"Import a private key, returns a public-key" | ||
derive_command ) | ||
; ( "generate-private-key" | ||
, Command.async ~summary:"Generate a new private key" generate_command | ||
) ]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
opam-version: "1.2" | ||
version: "0.1" | ||
build: [ | ||
["dune" "build" "--only" "src" "--root" "." "-j" jobs "@install"] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ | |
lib | ||
ppx_deriving_yojson.runtime | ||
yojson | ||
secrets | ||
) | ||
(preprocess (pps | ||
graphql_ppx | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
type curvetype = (* tweedle *) string [@@deriving yojson, show] | ||
|
||
type signaturetype = (* schnorr *) string [@@deriving yojson, show] | ||
type signaturetype = (* schnorr_poseidon *) string [@@deriving yojson, show] | ||
|
||
type coinaction = () [@@deriving yojson, show, eq] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think you could get away with
Core_kernel
, rather thanAsync
here; seedump_dhall_types.ml
. That one usesCore
, because it does things likechdir
, but I believe it could otherwise useCore_kernel
.No need to change this PR. I'm standing atop my "minimal dependencies" soapbox, is all.