Skip to content

feat(debug): encode and sign stuff [AC-1572]

Ethan Reesor requested to merge AC-1572 into develop

Closes AC-1572. go build ./tools/cmd/debug and then:

  • Marshal a transaction: debug encode transaction '{...}' (argument must be a transaction)
  • Hash a transaction: debug encode transaction --hash '{...}' (argument must be a transaction)
  • Marshal a header: debug encode transaction header '{...}' (argument must be a transaction header)
  • Hash a header: debug encode transaction header --hash '{...}' (argument must be a transaction header)
  • Marshal a body: debug encode transaction body '{...}' (argument must be a transaction body)
  • Hash a body: debug encode transaction body --hash '{...}' (argument must be a transaction body)
  • Marshal a signature: debug encode signature '{...}' (argument must be a signature)
  • Hash a signature: debug encode signature --hash '{...}' (argument must be a signature)
  • Finalize a signature: debug sign '{...}' <private key> (first argument must be a signature)

When finalizing a signature, the first argument must include the following fields:

  • type - the signature type as a string, e.g. "ed25519"
  • signer - the URL of the signer as a string, e.g. "acc://ethan"
  • signerVersion - the version of the key page, or 1 for lite token accounts
  • transactionHash - the hash of the transaction being signed

When initiating a transaction, the signature must include the timestamp field. To initiate a transaction:

  • Calculate the signature metadata hash with debug encode signature --hash <signature metadata>. The signature metadata is all of the signature fields except for signature and transactionHash.
  • Use that as the initiator field of the transaction header.
  • Calculate the transaction hash with debug encode transaction --hash <transaction>.
  • Add that as the transactionHash field of the signature.
  • Finalize the signature with debug sign <incomplete signature> <private key>

You may be able to omit fields without debug raising an error, but that will almost certainly produce an invalid signature and/or transaction.

Note: PowerShell is dumb and forces you to escape all of the quotes even within quotes. For example, {"type": "foo"} has to be passed as '{\"type\": \"foo\"}'.

Review Checklist

If any item is not complete, the merge request is not ready to be reviewed and must be marked Draft:.

  • The merge request title is in the format <change type>(<change scope>): <short description> [<task id>]
    • For example, feat(cli): add QR code generation [AC-123]
    • For details, see CONTRIBUTING.md
  • The description includes Closes <jira task ID> (or rarely Updates <jira task ID>)
  • The change is fully validated by tests that are run during CI
    • In most cases this means a test in "validate.sh"
    • In some cases, a Go test may be acceptable
    • Validation is not applicable to things like documentation updates
    • Purely UI/UX changes can be manually validated, such as changes to human-readable output
    • For all other changes, automated validation tests are an absolute requirement unless a maintainer specifically explains why they are not in a comment on this merge request
  • The change is marked with one of the validation labels

Merge Checklist

  • CI is passing
  • Merge conflicts are resolved
  • All discussions are resolved

Related to AC-1572

Edited by Ethan Reesor

Merge request reports