Code Monkey home page Code Monkey logo

oasis-signature-tool's Introduction

Oasis Signature Tools

Tessellated Logo By Tessellated // tessellated.io


This repository contains tooling and documentation for manually generating and signing airgapped transactions on Oasis Protocol.

Usage

This program formulates bytes to sign from the outputs of Oasis network's tools.

Usage:

go run main.go <base64 raw value>

Transaction Signing Mini Manual

You need a few things to sign a transaction.

Creating the bytes to sign

First, get the Oasis CLI tools:

git clone https://github.com/oasisprotocol/cli
cd cli && make && mv ./oasis ~/go/bin/oasis-cli

Grab your nonce from OasisScan

export NONCE=31

Use Oasis tools to generate a dummy account. This account prevents the CLI from complaining you don't have a private key.

oasis-cli wallet create insecure_dummy

Use the Oasis tool to build a transaction from the dummy account. We do this so that we can get the raw bytes of the transaction. The CLI will estimate gas and fees automatically, but we have to override the nonce since the CLI is signign from a different account:

Note: You can mess around with the CLI's node endpoints by running ./oasis networks list and related commands

Here's an example for casting a governace vote, but this will work with any transaction at the consensus layer:

oasis-cli network governance cast-vote --account insecure_dummy --format json --nonce $NONCE --output-file tmp-dummy-tx.json 4 yes

Extract the raw bytes and cleanup the dummy transaction file

export RAW_BYTES=$(cat tmp-dummy-tx.json | jq -r .untrusted_raw_value)
rm tmp-dummy-tx.json

The program in this repository will generate bytes to sign for the transaction.

Note: This program only works with consensus layer transactions. If you need to make a different transaction, consider introspecting this code in a debugger.

From this repository's root:

go run main.go $RAW_BYTES

Sign Tx Bytes

Sign the bytes output from above in whatever way you want to. This tool can help you check that your signatures is valid.

Assemble the Final Transaction

The final transaction JSON file is in the following format.

{
  "untrusted_raw_value": "",
  "signature": {
    "public_key": "",
    "signature": ""
  }
}

Set:

  • untrusted_raw_value: To be the raw value outputted by the Oasis CLI (the value we saved in $RAW_BYTES)
  • public_key: To be your public key
  • signature: To be the base64 encoded signature you created

Here's an example:

{
  "untrusted_raw_value": "pGNmZWWiY2dhcxkE2WZhbW91bnRAZGJvZHmiYmlkBGR2b3RlAWVub25jZRgeZm1ldGhvZHNnb3Zlcm5hbmNlLkNhc3RWb3Rl",
  "signature": {
    "public_key": "RS+saioy8ukcohygmbUH0IKGXhLjaE6BWrkdOBBqpDc=",
    "signature": "s7Y5qOojP4U+ku+ZKyRpB0m071vFsKbaDs1XeVeLLh5PDzWCyculhaK7HJIop2KQr7kgD4w/Ef0ll30ZSvFyDA=="
  }
}

Save this to a file, like tx.json.

Broadcast

Lastly, broadcast with the Oasis CLI and cleanup.

oasis-cli tx submit tx.json
rm tx.json

oasis-signature-tool's People

Contributors

keefertaylor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.