Files
nym/integrations/bity
Jędrzej Stuczyński f328f3fa9e Feature/gateway api (#3970)
* Squashing all the changes

initial router

started expanding the API

initial empty openapi/swagger

populated build-info endpoint

wip: populating rest of swagger

missing swagger data + using closure capture for immutable state

running the api as a proper task in gateway 'run'

fixing some version/feature clashes

refactored routes structures

initial host information endpoint

expanded on gateway-related endpoints

signing host information

moved all models to separate crate

unified http api client

routes unification + node api client

new generic cache and refresher

nym-api caching node self described information

removed old cache type

temporarily wired up NymContractCache to NodeDescriptionProvider

caching self reported host info

clients using self-described gateway information

fixed request timeouts for wasm

fixed wasm builds

post rebase fixes

cargo fmt

brought in wg routes into nym-node router

added ErrorResponse for wireguard routes

basic swagger support for wg endpoints

turns out swagger can be happy with strongly typed requests

output type support for wg routes

using concrete error type for nym node request error

fixed the registration test

landing page configurability

increased configurability

fixed build and lints of other crates

added default user-agent to http-api-client

reduced severity of gateway details lookup failure

changed default http port from 80 to 8080

nym-api using new default port for queries

added health endpoint

nym-api trying multiple ports for the client

using camelcase for node status

corrected health endpoint description

restored and revamped 'force_tls' flag to filter all gateways that support the wss protocol

fixed 'pub_key' path param in open api schema

derived Debug on 'NymNodeDescription'

ensuring valid public ips

added init and run flags to set hostname and public ips

fixed listening address being pushed to public ip

fixed the positional local flag

logging remote ip address of the request

updated helper function to query for described gateways

enabled tls in gateway client

removed hack-opts from mix fetch

additional changes after rebasing against origin/develop

* clippy

* wasm-related target locking

* more clippy, but this time in tests
2023-10-19 12:36:53 +02:00
..
2023-04-06 09:04:49 +02:00
2023-10-19 12:36:53 +02:00

Buy NYM with Bity

This crate allows Bity to verify orders for purchasing NYM tokens. The same crate is used by the wallet to sign orders for purchases.

Signing

The Nym Wallet user will sign an order message provided by Bity to create a signed order with the following fields:

account_id: n1jw6mp7d5xqc7w6xm79lha27glmd0vdt3l9artf
message: "This is the order message from Bity"
order signature: 
{
  "account_id": "n1jw6mp7d5xqc7w6xm79lha27glmd0vdt3l9artf",
  "public_key": {
    "@type": "/cosmos.crypto.secp256k1.PubKey",
    "key": "A/zqdyeyPhCEXB9pyVLdNb5er+eds5ayboCdEEHK3Uom"
  },
  "signature_as_hex": "31C522B9B5C522A93CE14BE38E2D380CA166F69E952DF6F5D45B3B9CCDAAFE9115FBDF8539092986391C46885242E6E4CF806EEC1BB869A28D0E6D347C52121A"
}

The signature field of the order contains a JSON representation of:

  • the Cosmos address of the signer (account_id)
  • the Cosmos public key
  • a hex string digest of the Bity order message signed by the user

Note: the signature_as_hex is not in recoverable form (e.g. allows recovering the public key from the signature in secp256k1). This is why the public key is supplied along with the account id, as the prefix cannot be recovered.

Verification

Verification has been wrapped up into taking a single struct that can be parsed from JSON:

{
  "account_id": "n1jw6mp7d5xqc7w6xm79lha27glmd0vdt3l9artf",
  "message": "This is the order message from Bity",
  "signature": << ORDER SIGNATURE JSON GOES HERE >>
}

The following will be checked:

  • the account_id supplied matches:
    • the account id derived from the public key
    • the account id field in the order signature JSON
  • the account id is for Nym mainnet
  • the signature is for the message
  • all data structures parse correctly
    • nested structs
    • account ids
    • Cosmos public keys