bitbox-api 0.12.0

A library to interact with BitBox hardware wallets
Documentation
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";
package shiftcrypto.bitbox02;

import "common.proto";

message CardanoXpubsRequest {
  repeated Keypath keypaths = 1;
}

message CardanoXpubsResponse {
  repeated bytes xpubs = 1;
}

enum CardanoNetwork {
  CardanoMainnet = 0;
  CardanoTestnet = 1;
}

message CardanoScriptConfig {
  message PkhSkh {
    repeated uint32 keypath_payment = 1;
    repeated uint32 keypath_stake = 2;
  }

  // Entries correspond to address types as described in:
  // https://github.com/cardano-foundation/CIPs/blob/6c249ef48f8f5b32efc0ec768fadf4321f3173f2/CIP-0019/CIP-0019.md
  // See also:
  // https://github.com/input-output-hk/cardano-ledger-specs/blob/d0aa86ded0b973b09b629e5aa62aa1e71364d088/eras/alonzo/test-suite/cddl-files/alonzo.cddl#L137
  oneof config {
    // Shelley PaymentKeyHash & StakeKeyHash
    PkhSkh pkh_skh = 1;
  }
}

message CardanoAddressRequest {
  CardanoNetwork network = 1;
  bool display = 2;
  CardanoScriptConfig script_config = 3;
}

// Max allowed transaction size is 16384 bytes according to
// https://github.com/cardano-foundation/CIPs/blob/master/CIP-0009/CIP-0009.md. Unlike with BTC, we
// can fit the whole request in RAM and don't need to stream.
//
// See also: https://github.com/input-output-hk/cardano-ledger-specs/blob/d0aa86ded0b973b09b629e5aa62aa1e71364d088/eras/alonzo/test-suite/cddl-files/alonzo.cddl#L50
message CardanoSignTransactionRequest {
  message Input {
    repeated uint32 keypath = 1;
    bytes prev_out_hash = 2;
    uint32 prev_out_index = 3;
  }

  // https://github.com/input-output-hk/cardano-ledger/blob/d0aa86ded0b973b09b629e5aa62aa1e71364d088/eras/alonzo/test-suite/cddl-files/alonzo.cddl#L358
  message AssetGroup {
    bytes policy_id = 1;

    message Token {
      bytes asset_name = 1;
      // Number of tokens transacted of this asset.
      uint64 value = 2;
    }

    repeated Token tokens = 2;
  }

  message Output {
    string encoded_address = 1;
    uint64 value = 2;
    // Optional. If provided, this is validated as a change output.
    CardanoScriptConfig script_config = 3;
    repeated AssetGroup asset_groups = 4;
  }

  // See https://github.com/IntersectMBO/cardano-ledger/blob/cardano-ledger-conway-1.12.0.0/eras/conway/impl/cddl-files/conway.cddl#L273
  message Certificate {
    message StakeDelegation {
      repeated uint32 keypath = 1;
      bytes pool_keyhash = 2;
    }
    message VoteDelegation {
      enum CardanoDRepType {
        KEY_HASH = 0;
        SCRIPT_HASH = 1;
        ALWAYS_ABSTAIN = 2;
        ALWAYS_NO_CONFIDENCE = 3;
      }

      // keypath in this instance refers to stake credential
      repeated uint32 keypath = 1;
      CardanoDRepType type = 2;
      optional bytes drep_credhash = 3;
    }
    oneof cert {
      Keypath stake_registration = 1;
      Keypath stake_deregistration = 2;
      StakeDelegation stake_delegation = 3;
      VoteDelegation vote_delegation = 10;
    }
  }

  message Withdrawal {
    repeated uint32 keypath = 1;
    uint64 value = 2;
  }

  CardanoNetwork network = 1;
  repeated Input inputs = 2;
  repeated Output outputs = 3;
  uint64 fee = 4;
  uint64 ttl = 5;
  repeated Certificate certificates = 6;
  repeated Withdrawal withdrawals = 7;
  uint64 validity_interval_start = 8;
  bool allow_zero_ttl = 9; // include ttl even if it is zero
  // Tag arrays in the transaction serialization with the 258 tag.
  // See https://github.com/IntersectMBO/cardano-ledger/blob/6e2d37cc0f47bd02e89b4ce9f78b59c35c958e96/eras/conway/impl/cddl-files/extra.cddl#L5
  bool tag_cbor_sets = 10;
}

message CardanoSignTransactionResponse {
  message ShelleyWitness {
    bytes public_key = 1;
    bytes signature = 2;
  }

  repeated ShelleyWitness shelley_witnesses = 1;
}

message CardanoRequest {
  oneof request {
    CardanoXpubsRequest xpubs = 1;
    CardanoAddressRequest address = 2;
    CardanoSignTransactionRequest sign_transaction = 3;
  }
}

message CardanoResponse {
  oneof response {
    CardanoXpubsResponse xpubs = 1;
    PubResponse pub = 2;
    CardanoSignTransactionResponse sign_transaction = 3;
  }
}