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
@@ -1,2 +1,3 @@
/target
/Cargo.lock
/.vscode
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"
ciborium = "0.2.0"
serde = "1"
serde_bytes = "0.11"
secp256k1 = { version = "0.26.0", features = ["rand-std", "bitcoin-hashes-std"] }
secp256k1 = { version = "0.26.0", features = ["rand-std", "bitcoin-hashes-std", "recovery"] }

# optional dependencies
pcsc = { version = "2", optional = true }
Expand Down
42 changes: 29 additions & 13 deletions examples/pcsc.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
extern crate core;

use rust_cktap::commands::Error;
use rust_cktap::pcsc::PcscTransport;
use rust_cktap::{rand_chaincode, CkTapCard, SharedCommands, Transport};
use rust_cktap::rand_nonce;
use rust_cktap::{pcsc::PcscTransport, rand_chaincode, CkTapCard, SharedCommands, Transport};
use secp256k1::rand;
use std::io;
use std::io::Write;
Expand All @@ -20,8 +20,12 @@ fn main() -> Result<(), Error> {
let card = PcscTransport::find_first()?;
dbg!(&card);

let rng = &mut rand::thread_rng();

match card {
CkTapCard::TapSigner(mut card) => {
let cvc: String = get_cvc();

// if auth delay call wait
while card.auth_delay.is_some() {
dbg!(card.auth_delay.unwrap());
Expand All @@ -30,21 +34,29 @@ fn main() -> Result<(), Error> {

// only do this once per card!
if card.path.is_none() {
let rng = &mut rand::thread_rng();
let chain_code = rand_chaincode(rng).to_vec();
let new_result = card.init(chain_code, get_cvc())?;
let new_result = card.init(chain_code, cvc.clone())?;
dbg!(new_result);
}

let nonce = rand_nonce(rng);
dbg!(card.certs_check(nonce.to_vec()).unwrap().name());

//let dump_result = card.dump();

let read_result = card.read(get_cvc())?;
dbg!(read_result);
// let read_result = card.read(cvc.clone())?;
// dbg!(read_result);

let nfc_result = card.nfc()?;
dbg!(nfc_result);
// let path = vec![2147483732, 2147483648, 2147483648];
// let derive_result = card.derive(path, cvc.clone())?;
// dbg!(&derive_result);

// let nfc_result = card.nfc()?;
// dbg!(nfc_result);
}
CkTapCard::SatsChip(mut card) => {
let cvc: String = get_cvc();

// if auth delay call wait
while card.auth_delay.is_some() {
dbg!(card.auth_delay.unwrap());
Expand All @@ -53,13 +65,12 @@ fn main() -> Result<(), Error> {

// only do this once per card!
if card.path.is_none() {
let rng = &mut rand::thread_rng();
let chain_code = rand_chaincode(rng).to_vec();
let new_result = card.init(chain_code, get_cvc())?;
dbg!(new_result);
}

let read_result = card.read(get_cvc())?;
let read_result = card.read(cvc.clone())?;
dbg!(read_result);

let nfc_result = card.nfc()?;
Expand All @@ -76,13 +87,18 @@ fn main() -> Result<(), Error> {
// let read_result = card.read()?;
// dbg!(read_result);

// let derive_result = card.derive()?;
// dbg!(&derive_result);

let nonce = rand_nonce(rng);
dbg!(card.certs_check(nonce.to_vec()));

// let nfc_result = card.nfc()?;
// dbg!(nfc_result);

// if let Some(slot) = card.slots.first() {
// if slot == &0 {
// // TODO must unseal first
// let rng = &mut rand::thread_rng();
// let chain_code = rand_chaincode(rng).to_vec();
// let new_result = card.new_slot(0, chain_code, get_cvc())?;
// }
Expand All @@ -97,8 +113,8 @@ fn main() -> Result<(), Error> {
// let dump_result = card.dump(0, None)?;
// dbg!(dump_result);

let dump_result = card.dump(0, Some(get_cvc()))?;
dbg!(dump_result);
// let dump_result = card.dump(0, Some(get_cvc()))?;
// dbg!(dump_result);
}
}

Expand Down
Loading