Examples

The examples directoryarrow-up-right contains runnable demos.

Building

Build all examples with Make:

cd examples
make

key-generate

Generate a new Ed25519 keypair:

make run-key-generate
#include <stdio.h>
#include <tashi-vertex/tashi-vertex.h>

int main() {
  TVKeySecret secret;
  tv_key_secret_generate(&secret);

  TVKeyPublic public;
  tv_key_secret_to_public(&secret, &public);

  uint8_t der[TV_KEY_SECRET_DER_LENGTH];
  tv_key_secret_to_der(&secret, der, TV_KEY_SECRET_DER_LENGTH);

  char b58[tv_base58_encode_length(TV_KEY_SECRET_DER_LENGTH) + 1];
  size_t b58_len = sizeof(b58);
  tv_base58_encode(der, TV_KEY_SECRET_DER_LENGTH, b58, &b58_len);
  b58[b58_len] = '\0';

  printf("Secret: %s\n", b58);

  return 0;
}

key-parse

Parse Base58-encoded keys:

pingback

A full multi-peer consensus network with transaction exchange. Three nodes each send a transaction and reach consensus ordering.

Setup

Generate keypairs for three nodes:

Run

Start each node in a separate terminal, passing the other two nodes as peers:

Simplified Code

Expected Output

Once all three nodes are running, each will reach consensus and print the ordered events:

Last updated