Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2023-2024 Shift Crypto AG, Switzerland. All rights reserved.
Copyright 2023-2025 Shift Crypto AG, Switzerland. All rights reserved.

Apache License
Version 2.0, January 2004
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

npm_version=$(shell cat NPM_VERSION)

build-protos:
Expand Down
1 change: 1 addition & 0 deletions ci.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0

set -e

Expand Down
2 changes: 2 additions & 0 deletions examples/btc_miniscript.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use std::str::FromStr;

use bitbox_api::pb;
Expand Down
2 changes: 2 additions & 0 deletions examples/btc_sign_msg.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use bitbox_api::pb;

async fn signmsg<R: bitbox_api::runtime::Runtime>() {
Expand Down
2 changes: 2 additions & 0 deletions examples/btc_sign_op_return.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use std::str::FromStr;

use bitbox_api::{pb, Keypath};
Expand Down
2 changes: 2 additions & 0 deletions examples/btc_sign_psbt.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use bitbox_api::pb;
use std::str::FromStr;

Expand Down
2 changes: 2 additions & 0 deletions examples/btc_signtx.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use bitbox_api::pb;

async fn signtx<R: bitbox_api::runtime::Runtime>() {
Expand Down
2 changes: 2 additions & 0 deletions examples/cardano.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use bitbox_api::pb;

async fn demo<R: bitbox_api::runtime::Runtime>() {
Expand Down
2 changes: 2 additions & 0 deletions examples/eth.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

const EIP712_MSG: &str = r#"
{
"types": {
Expand Down
2 changes: 2 additions & 0 deletions examples/multithreaded.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

fn multithreading_type_check<T: Sync + Send>(_t: &T) {}

async fn demo<R: bitbox_api::runtime::Runtime + Sync + Send>() {
Expand Down
2 changes: 2 additions & 0 deletions examples/simulator.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

async fn demo<R: bitbox_api::runtime::Runtime + Sync + Send>() {
let noise_config = Box::new(bitbox_api::NoiseConfigNoCache {});
let bitbox = bitbox_api::BitBox::<R>::from_simulator(None, noise_config)
Expand Down
2 changes: 2 additions & 0 deletions examples/singlethreaded.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

async fn demo<R: bitbox_api::runtime::Runtime>() {
let noise_config = Box::new(bitbox_api::NoiseConfigNoCache {});
let bitbox = bitbox_api::BitBox::<R>::from_hid_device(
Expand Down
2 changes: 2 additions & 0 deletions sandbox/src/Accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import { useState } from 'react';
import './Accordion.css';

Expand Down
2 changes: 2 additions & 0 deletions sandbox/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import { useState } from 'react'
import * as bitbox from 'bitbox-api';
import './App.css'
Expand Down
2 changes: 2 additions & 0 deletions sandbox/src/Bitcoin.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import { ChangeEvent, FormEvent, useState } from 'react'
import * as bitbox from 'bitbox-api';

Expand Down
2 changes: 2 additions & 0 deletions sandbox/src/Cardano.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import { ChangeEvent, FormEvent, useState } from 'react'
import * as bitbox from 'bitbox-api';
import hexToArrayBuffer from 'hex-to-array-buffer'
Expand Down
2 changes: 2 additions & 0 deletions sandbox/src/Error.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import * as bitbox from 'bitbox-api';
import { ErrorNotification } from './ErrorNotification';
import { useEffect, useState } from 'react';
Expand Down
2 changes: 2 additions & 0 deletions sandbox/src/ErrorNotification.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import { useEffect } from "react";
import "./ErrorNotification.css";

Expand Down
2 changes: 2 additions & 0 deletions sandbox/src/Ethereum.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import { FormEvent, useState } from 'react'
import * as bitbox from 'bitbox-api';
import hexToArrayBuffer from 'hex-to-array-buffer'
Expand Down
2 changes: 2 additions & 0 deletions sandbox/src/General.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import { FormEvent, useState } from 'react'
import * as bitbox from 'bitbox-api';

Expand Down
2 changes: 2 additions & 0 deletions sandbox/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
Expand Down
3 changes: 3 additions & 0 deletions sandbox/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/// <reference types="vite/client" />
// SPDX-License-Identifier: Apache-2.0

// Intentionally only contains top-level type references.
2 changes: 2 additions & 0 deletions sandbox/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import wasm from "vite-plugin-wasm";
Expand Down
2 changes: 2 additions & 0 deletions scripts/build-protos.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

//! ```cargo
//! [dependencies]
//! # If you change this, also change the version of prost in Cargo.toml.
Expand Down
2 changes: 2 additions & 0 deletions src/antiklepto.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use thiserror::Error;

use bitcoin::hashes::sha256;
Expand Down
2 changes: 2 additions & 0 deletions src/btc.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

//! Functions and methods related to Bitcoin.

use crate::runtime::Runtime;
Expand Down
2 changes: 2 additions & 0 deletions src/cardano.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use crate::runtime::Runtime;

use crate::error::Error;
Expand Down
2 changes: 2 additions & 0 deletions src/communication.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use super::u2fframing::{self, U2FFraming};
use crate::runtime::Runtime;
use crate::util::Threading;
Expand Down
2 changes: 2 additions & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

#[cfg(any(feature = "wasm", feature = "usb"))]
pub const VENDOR_ID: u16 = 0x03eb;
#[cfg(any(feature = "wasm", feature = "usb"))]
Expand Down
2 changes: 2 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use thiserror::Error;

#[cfg(feature = "wasm")]
Expand Down
2 changes: 2 additions & 0 deletions src/eth.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use crate::runtime::Runtime;

use crate::error::Error;
Expand Down
2 changes: 2 additions & 0 deletions src/keypath.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use crate::error::Error;

pub const HARDENED: u32 = 0x80000000;
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

//! Rust BitBox hardware wallet client library.

#[cfg(all(feature = "wasm", feature = "multithreaded"))]
Expand Down
2 changes: 2 additions & 0 deletions src/noise.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use crate::util::Threading;
use thiserror::Error;

Expand Down
2 changes: 2 additions & 0 deletions src/runtime.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use async_trait::async_trait;

#[cfg_attr(feature = "multithreaded", async_trait)]
Expand Down
2 changes: 2 additions & 0 deletions src/simulator.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use async_trait::async_trait;
use std::io::{Read, Write};
use std::net::TcpStream;
Expand Down
14 changes: 1 addition & 13 deletions src/u2fframing.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
// Copyright 2020 Shift Cryptosecurity AG
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// SPDX-License-Identifier: Apache-2.0

use byteorder::BigEndian;
use byteorder::ReadBytesExt;
Expand Down
2 changes: 2 additions & 0 deletions src/usb.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use super::constants::{PRODUCT_ID, VENDOR_ID};
use async_trait::async_trait;
use thiserror::Error;
Expand Down
2 changes: 2 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

pub fn remove_leading_zeroes(list: &[u8]) -> Vec<u8> {
if let Some(first_non_zero) = list.iter().position(|&x| x != 0) {
list[first_non_zero..].to_vec()
Expand Down
2 changes: 2 additions & 0 deletions src/wasm/connect.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use super::{noise, types::TsOnCloseCb, BitBox, JavascriptError};
use crate::communication;
use wasm_bindgen::prelude::*;
Expand Down
2 changes: 2 additions & 0 deletions src/wasm/localstorage.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

pub fn get<T: serde::de::DeserializeOwned>(key: &str) -> Result<T, ()> {
let window = web_sys::window().ok_or(())?;
let local_storage = match window.local_storage() {
Expand Down
2 changes: 2 additions & 0 deletions src/wasm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use std::str::FromStr;

mod connect;
Expand Down
2 changes: 2 additions & 0 deletions src/wasm/noise.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use super::localstorage;

use crate::noise::{ConfigError, NoiseConfigData};
Expand Down
2 changes: 2 additions & 0 deletions src/wasm/types.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

use super::JavascriptError;

use wasm_bindgen::prelude::*;
Expand Down
2 changes: 2 additions & 0 deletions tests/test_btc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![cfg(feature = "simulator")]
// SPDX-License-Identifier: Apache-2.0

// Simulators only run on linux/amd64.
#![cfg(all(target_os = "linux", target_arch = "x86_64"))]

Expand Down
2 changes: 2 additions & 0 deletions tests/test_btc_psbt.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![cfg(feature = "simulator")]
// SPDX-License-Identifier: Apache-2.0

// Simulators only run on linux/amd64.
#![cfg(all(target_os = "linux", target_arch = "x86_64"))]

Expand Down
2 changes: 2 additions & 0 deletions tests/test_cardano.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![cfg(feature = "simulator")]
// SPDX-License-Identifier: Apache-2.0

// Simulators only run on linux/amd64.
#![cfg(all(target_os = "linux", target_arch = "x86_64"))]

Expand Down
2 changes: 2 additions & 0 deletions tests/test_device.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![cfg(feature = "simulator")]
// SPDX-License-Identifier: Apache-2.0

// Simulators only run on linux/amd64.
#![cfg(all(target_os = "linux", target_arch = "x86_64"))]

Expand Down
2 changes: 2 additions & 0 deletions tests/util/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

// Since each integration test file is compiled independently and not all integration tests use all
// of the util functions, the ones that are not used by all integration test files produce a
// warning.
Expand Down
2 changes: 2 additions & 0 deletions webhid.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

export async function jsSleep(ms) {
await new Promise(resolve => setTimeout(resolve, ms));
}
Expand Down