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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ lib*.a

# Python ck-tap emulator
/emulator_env/
*.log
41 changes: 36 additions & 5 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,48 @@ fmt:

# lint the project
clippy: fmt
cargo clippy --all-features --tests
cargo clippy --all-features --all-targets

# build the project
build: fmt
cargo build --all-features --tests
cargo build --all-features --all-targets

# setup the cktap emulator venv
setup:
(test -d emulator_env || python3 -m venv emulator_env) && \
source emulator_env/bin/activate; pip install -r {{emulator_dir}}/requirements.txt > /dev/null 2>&1

# get cktap emulator options help
help:
source emulator_env/bin/activate; python3 coinkite/coinkite-tap-proto/emulator/ecard.py emulate --help

# start the cktap emulator on /tmp/ecard-pipe
start *OPTS: setup
source emulator_env/bin/activate; python3 coinkite/coinkite-tap-proto/emulator/ecard.py emulate {{OPTS}} &> emulator_env/output.log & \
echo $! > emulator_env/ecard.pid
echo "started emulator, pid:" `cat emulator_env/ecard.pid`

# stop the cktap emulator
stop:
if [ -f emulator_env/ecard.pid ]; then \
echo "killing emulator, pid:" `cat emulator_env/ecard.pid`; \
kill `cat emulator_env/ecard.pid` && rm emulator_env/ecard.pid; \
else \
echo "emulator pid file not found."; \
fi

# test the rust-cktap lib with the coinkite cktap card emulator
test: fmt
(test -d emulator_env || python3 -m venv emulator_env) && source emulator_env/bin/activate && pip install -r {{emulator_dir}}/requirements.txt
source emulator_env/bin/activate && cargo test -p rust-cktap --features emulator
test: fmt setup
source emulator_env/bin/activate && cargo test -p rust-cktap --features emulator -- --nocapture

# clean the project target directory
clean:
cargo clean

# run the cli locally with a usb pcsc card reader (HID OMNIKEY 5022 CL Rev:C)
run *CMD:
cargo run -p cktap-cli {{CMD}}

# run the cli locally with an emulated satscard (see start and stop recipes)
run_emu *CMD:
cargo run -p cktap-cli --features emulator -- {{CMD}}
54 changes: 36 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ It is up to the crate user to send and receive the raw cktap APDU messages via N
#### Shared Commands

- [x] [status](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#status)
- [x] [read](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#status) (messages)
- [x] response verification
- [x] [derive](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#derive) (messages)
- [x] [read](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#read)
- [x] response verification
- [x] [derive](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#derive)
- [ ] response verification
- [x] [certs](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#certs)
- [x] [new](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#new)
- [x] [nfc](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#nfc)
- [x] [sign](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#sign) (messages)
- [ ] response verification
- [ ] [nfc](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#nfc)
- [x] [sign](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#sign)
- [x] response verification
- [x] [wait](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#wait)

#### SATSCARD-Only Commands
Expand All @@ -39,31 +39,49 @@ It is up to the crate user to send and receive the raw cktap APDU messages via N
#### TAPSIGNER-Only Commands

- [x] [change](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#change)
- [x] [xpub](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#xpub)
- [ ] [xpub](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#xpub)
- [x] [backup](https://github.com/coinkite/coinkite-tap-proto/blob/master/docs/protocol.md#backup)

### Automated Testing with Emulator
### Automated and CLI Testing with Emulator

#### Prerequisites

1. Install dependencies for [cktap emulator](https://github.com/coinkite/coinkite-tap-proto/blob/master/emulator/README.md)
2. run tests with emulator: `just test`

#### Run tests with emulator

```
just test
```

#### Run CLI with emulated card reader

```
just start # for SATSCARD emulator
just start -t # for TAPSIGNER emulator
just run_emu --help
just run_emu certs
just run_emu read
just stop # stop emulator
```

### Manual Testing with real cards

#### Prerequisites

1. USB PCSC NFC card reader, for example:
1. Get USB PCSC NFC card reader, for example:
- [OMNIKEY 5022 CL](https://www.hidglobal.com/products/omnikey-5022-reader)
2. Coinkite SATSCARD, TAPSIGNER, or SATSCHIP cards
Install vendor PCSC driver
3. Connect NFC reader to desktop system
4. Place SATSCARD, TAPSIGNER, or SATSCHIP on reader
2. Get Coinkite SATSCARD, TAPSIGNER, or SATSCHIP cards
3. Install card reader PCSC driver
4. Connect USB PCSC NFC reader to desktop system
5. Place SATSCARD, TAPSIGNER, or SATSCHIP on reader

#### Run CLI
#### Run CLI with desktop USB PCSC NFC card reader

```
cargo run -p cktap-cli -- --help
cargo run -p cktap-cli -- certs
cargo run -p cktap-cli -- read
just run --help
just run certs
just run read
```

## Minimum Supported Rust Version (MSRV)
Expand Down
11 changes: 9 additions & 2 deletions cktap-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ repository.workspace = true

[lib]
name = "cktap_ffi"
crate-type = ["staticlib", "cdylib"]
crate-type = ["lib", "staticlib", "cdylib"]

[[bin]]
name = "cktap-uniffi-bindgen"
path = "cktap-uniffi-bindgen.rs"

[dependencies]
rust-cktap = { path = "../lib" }
uniffi = { version = "0.29", features = ["cli"] }

async-trait = "0.1.81"
futures = "0.3.30"
thiserror = "1.0"
uniffi = { git = "https://github.com/mozilla/uniffi-rs", features = ["cli", "tokio"] }

[features]
default = []
6 changes: 6 additions & 0 deletions cktap-ffi/cktap-uniffi-bindgen.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) 2025 rust-cktap contributors
// SPDX-License-Identifier: MIT OR Apache-2.0

fn main() {
uniffi::uniffi_bindgen_main()
}
3 changes: 0 additions & 3 deletions cktap-ffi/src/bin/uniffi-bindgen.rs

This file was deleted.

Loading
Loading