diff --git a/Cargo.lock b/Cargo.lock index 8a3724ee..80351f91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,6 +80,12 @@ version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + [[package]] name = "assert_cmd" version = "2.0.14" @@ -314,6 +320,28 @@ version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "bitvec-nom2" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4863ce31b7ff8812568eaffe956024c824d845a1f9f08c329706166c357cae53" +dependencies = [ + "bitvec", + "nom", +] + [[package]] name = "blake2" version = "0.9.2" @@ -402,6 +430,15 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" +dependencies = [ + "num-traits", +] + [[package]] name = "clap" version = "4.5.3" @@ -454,6 +491,12 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "const_panic" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6051f239ecec86fde3410901ab7860d458d160371533842974fc61f96d15879b" + [[package]] name = "cookie" version = "0.18.0" @@ -473,6 +516,31 @@ dependencies = [ "libc", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + [[package]] name = "crunchy" version = "0.2.2" @@ -649,6 +717,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "either" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" + [[package]] name = "elliptic-curve" version = "0.13.8" @@ -729,6 +803,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futures-channel" version = "0.3.30" @@ -1028,12 +1108,27 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +[[package]] +name = "jzon" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ab85f84ca42c5ec520e6f3c9966ba1fd62909ce260f8837e248857d2560509" + [[package]] name = "k256" version = "0.13.3" @@ -1076,6 +1171,35 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "kairos-tx" +version = "0.1.0" +dependencies = [ + "num-traits", + "rasn", + "thiserror", +] + +[[package]] +name = "konst" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d712a8c49d4274f8d8a5cf61368cb5f3c143d149882b1a2918129e53395fdb0" +dependencies = [ + "const_panic", + "konst_kernel", + "typewit", +] + +[[package]] +name = "konst_kernel" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dac6ea8c376b6e208a81cf39b8e82bebf49652454d98a4829e907dac16ef1790" +dependencies = [ + "typewit", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -1153,6 +1277,12 @@ dependencies = [ "unicase", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.2" @@ -1173,6 +1303,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "normalize-line-endings" version = "0.3.0" @@ -1503,6 +1643,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.8.5" @@ -1542,6 +1688,64 @@ dependencies = [ "rand_core", ] +[[package]] +name = "rasn" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9b0d03fbc7d2dcfdd35086c43ce30ac5ff62ed7eff4397e4f4f2995a2b0e2a" +dependencies = [ + "arrayvec", + "bitvec", + "bitvec-nom2", + "bytes", + "chrono", + "either", + "jzon", + "konst", + "nom", + "num-bigint", + "num-integer", + "num-traits", + "once_cell", + "rasn-derive", + "snafu", +] + +[[package]] +name = "rasn-derive" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbaf7105cd254b632f4732fbcc243ce750cef87d8335826125ef6df5733b5a0c" +dependencies = [ + "either", + "itertools", + "proc-macro2", + "quote", + "rayon", + "syn 1.0.109", + "uuid", +] + +[[package]] +name = "rayon" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "redox_syscall" version = "0.4.1" @@ -1849,6 +2053,29 @@ version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +[[package]] +name = "snafu" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4de37ad025c587a29e8f3f5605c00f70b98715ef90b9061a815b9e59e9042d6" +dependencies = [ + "backtrace", + "doc-comment", + "snafu-derive", +] + +[[package]] +name = "snafu-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990079665f075b699031e9c08fd3ab99be5029b96f3b78dc0709e8f77e4efebf" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "socket2" version = "0.5.6" @@ -1915,6 +2142,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "tempfile" version = "3.10.1" @@ -2156,6 +2389,21 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "typewit" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6fb9ae6a3cafaf0a5d14c2302ca525f9ae8e07a0f0e6949de88d882c37a6e24" +dependencies = [ + "typewit_proc_macros", +] + +[[package]] +name = "typewit_proc_macros" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e36a83ea2b3c704935a01b4642946aadd445cea40b10935e3f8bd8052b8193d6" + [[package]] name = "uint" version = "0.9.5" @@ -2227,6 +2475,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +dependencies = [ + "getrandom", +] + [[package]] name = "valuable" version = "0.1.0" @@ -2417,6 +2674,15 @@ version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "yansi" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index e9e499d3..c0942185 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ resolver = "2" members = [ "kairos-cli", "kairos-server", + "kairos-tx", ] [workspace.package] diff --git a/kairos-tx/Cargo.toml b/kairos-tx/Cargo.toml new file mode 100644 index 00000000..5123d60a --- /dev/null +++ b/kairos-tx/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "kairos-tx" +version.workspace = true +edition.workspace = true + +[lib] + +[dependencies] +num-traits = "0.2.18" +rasn = { version = "0.12.5", default-features = false, features = ["macros"] } +thiserror = "1.0.57" diff --git a/kairos-tx/schema.asn b/kairos-tx/schema.asn new file mode 100644 index 00000000..049315ea --- /dev/null +++ b/kairos-tx/schema.asn @@ -0,0 +1,42 @@ +---- + +TxSchema DEFINITIONS AUTOMATIC TAGS ::= BEGIN + + -- Basic types. + PublicKey ::= OCTET STRING + Amount ::= INTEGER (0..18446744073709551615) + Nonce ::= INTEGER (0..18446744073709551615) + + -- Transaction payload for signing. + SigningPayload ::= SEQUENCE { + nonce Nonce, + body TransactionBody, + ... + } + + -- Generic transaction body. + TransactionBody ::= CHOICE { + deposit [0] Deposit, + transfer [1] Transfer, + withdrawal [2] Withdrawal, + ... + } + + -- Detailed definitions of each transaction type. + Deposit ::= SEQUENCE { + amount Amount, + ... + } + + Transfer ::= SEQUENCE { + recipient PublicKey, + amount Amount, + ... + } + + Withdrawal ::= SEQUENCE { + amount Amount, + ... + } + +END diff --git a/kairos-tx/src/asn.rs b/kairos-tx/src/asn.rs new file mode 100644 index 00000000..1e695455 --- /dev/null +++ b/kairos-tx/src/asn.rs @@ -0,0 +1,170 @@ +use crate::error::TxError; + +// Expose types for the public API. +pub use rasn::types::{Integer, OctetString}; + +use num_traits::cast::ToPrimitive; +use rasn::types::AsnType; +use rasn::{Decode, Encode}; + +#[derive(AsnType, Encode, Decode, Debug)] +#[rasn(delegate)] +pub struct PublicKey(pub(crate) OctetString); + +// Converts an ASN.1 decoded public key into raw byte representation. +impl From for Vec { + fn from(value: PublicKey) -> Self { + value.0.into() + } +} + +#[derive(AsnType, Encode, Decode, Debug)] +#[rasn(delegate)] +pub struct Amount(pub(crate) Integer); + +// Attempts to convert an ASN.1 decoded amount (which is represented as a big integer) +// into a `u64`. This conversion can fail if the decoded value is outside the `u64` range, +// thereby enforcing the specified ASN.1 constraints on the value: `INTEGER +// (0..18446744073709551615)`. +impl TryFrom for u64 { + type Error = TxError; + + fn try_from(value: Amount) -> Result { + value + .0 + .to_u64() + .ok_or(TxError::ConstraintViolation { field: "amount" }) + } +} + +#[derive(AsnType, Encode, Decode, Debug)] +#[rasn(delegate)] +pub struct Nonce(pub(crate) Integer); + +// Similar to `Amount`, attempts to convert an ASN.1 decoded nonce into a `u64`. +// This is crucial for validating that the nonce adheres to expected constraint: +// `INTEGER (0..18446744073709551615)`. +impl TryFrom for u64 { + type Error = TxError; + + fn try_from(value: Nonce) -> Result { + value + .0 + .to_u64() + .ok_or(TxError::ConstraintViolation { field: "nonce" }) + } +} + +#[derive(AsnType, Encode, Decode, Debug)] +#[non_exhaustive] +pub struct SigningPayload { + pub nonce: Nonce, + pub body: TransactionBody, +} + +#[derive(AsnType, Encode, Decode, Debug)] +#[rasn(choice)] +#[non_exhaustive] +pub enum TransactionBody { + #[rasn(tag(0))] + Deposit(Deposit), + #[rasn(tag(1))] + Transfer(Transfer), + #[rasn(tag(2))] + Withdrawal(Withdrawal), +} + +#[derive(AsnType, Encode, Decode, Debug)] +#[non_exhaustive] +pub struct Deposit { + pub amount: Amount, +} + +#[derive(AsnType, Encode, Decode, Debug)] +#[non_exhaustive] +pub struct Transfer { + pub recipient: PublicKey, + pub amount: Amount, +} + +#[derive(AsnType, Encode, Decode, Debug)] +#[non_exhaustive] +pub struct Withdrawal { + pub amount: Amount, +} + +impl TryFrom<&[u8]> for SigningPayload { + type Error = TxError; + + fn try_from(value: &[u8]) -> Result { + rasn::der::decode(value).map_err(TxError::DecodeError) + } +} + +impl TryFrom for Vec { + type Error = TxError; + + fn try_from(value: SigningPayload) -> Result { + rasn::der::encode(&value).map_err(TxError::EncodeError) + } +} + +#[cfg(test)] +mod tests { + use crate::helpers::{make_deposit, make_transfer, make_withdrawal}; + + #[test] + fn test_encode_deposit() { + const NONCE: u64 = 1; + const AMOUNT: u64 = 1000; + let encoded = make_deposit(NONCE, AMOUNT).unwrap(); + + assert_eq!( + encoded, + vec![ + 0b00110000, // T: 0b00 <- universal, 0b1 <- constructed, 0b10000 (16) <- SEQUENCE tag + 0b00001001, // L: 0b0 <- short form, 0b0001001 (9) <- length + 0b00000010, // T: 0b00 <- universal, 0b0 <- primitive, 0b00010 (2) <- INTEGER tag + 0b00000001, // L: 0b0 <- short form, 0b0000001 (1) <- length + 0b00000001, // V: 0b00000001 (1) <- value + 0b10100000, // T: 0b10 <- context-specific, 0b1 <- constructed, 0b00000 (0) <- CHOICE index + 0b00000100, // L: 0b0 <- short form, 0b0000100 (4) <- length + 0b00000010, // T: 0b00 <- universal, 0b0 <- primitive, 0b00010 (2) <- INTEGER tag + 0b00000010, // L: 0b0 <- short form, 0b0000010 (2) <- length + 0b00000011, // V: 512 + 256 + + 0b11101000, // 128 + 64 + 32 + 8 = 1000 <- value + ] + ); + } + + #[test] + fn test_encode_transfer() { + const NONCE: u64 = 1; + const RECIPIENT: [u8; 32] = [11; 32]; + const AMOUNT: u64 = 1000; + let encoded = make_transfer(NONCE, &RECIPIENT, AMOUNT).unwrap(); + + assert_eq!( + encoded, + vec![ + 0x30, 0x2B, // SEQUENCE (43 bytes) + 0x02, 0x01, 0x01, // INTEGER (1 byte), value = 1 + 0xA1, 0x26, // CHOICE (38 bytes), index = 1 (transfer body) + 0x04, 0x20, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, // OCTET STRING (32 bytes), value = [11; 32] + 0x02, 0x02, 0x03, 0xE8 // INTEGER (2 bytes), value = 1000 + ] + ); + } + + #[test] + fn test_encode_withdrawal() { + const NONCE: u64 = 1; + const AMOUNT: u64 = 1000; + let encoded = make_withdrawal(NONCE, AMOUNT).unwrap(); + + assert_eq!(encoded, vec![48, 9, 2, 1, 1, 162, 4, 2, 2, 3, 232]); + } +} diff --git a/kairos-tx/src/error.rs b/kairos-tx/src/error.rs new file mode 100644 index 00000000..bc5e98a5 --- /dev/null +++ b/kairos-tx/src/error.rs @@ -0,0 +1,21 @@ +use rasn::error::{DecodeError, EncodeError}; +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum TxError { + /// Errors related to encoding. + #[error("encode error: {0}")] + EncodeError(EncodeError), + + /// Errors related to decoding. + #[error("decode error: {0}")] + DecodeError(DecodeError), + + /// Constraint violation for a specific field. + #[error("constraint violated for '{field}'")] + ConstraintViolation { field: &'static str }, + + /// Signature verification failure. + #[error("signature verification failed")] + InvalidSignature, +} diff --git a/kairos-tx/src/helpers.rs b/kairos-tx/src/helpers.rs new file mode 100644 index 00000000..4107b382 --- /dev/null +++ b/kairos-tx/src/helpers.rs @@ -0,0 +1,43 @@ +use crate::asn::{ + Amount, Deposit, Nonce, PublicKey, SigningPayload, TransactionBody, Transfer, Withdrawal, +}; +use crate::asn::{Integer, OctetString}; +use crate::error::TxError; + +pub fn make_deposit(nonce: u64, amount: u64) -> Result, TxError> { + create_payload( + nonce, + TransactionBody::Deposit(Deposit { + amount: Amount(Integer::from(amount)), + }), + ) +} + +pub fn make_transfer(nonce: u64, recipient: &[u8], amount: u64) -> Result, TxError> { + create_payload( + nonce, + TransactionBody::Transfer(Transfer { + recipient: PublicKey(OctetString::copy_from_slice(recipient)), + amount: Amount(Integer::from(amount)), + }), + ) +} + +pub fn make_withdrawal(nonce: u64, amount: u64) -> Result, TxError> { + create_payload( + nonce, + TransactionBody::Withdrawal(Withdrawal { + amount: Amount(Integer::from(amount)), + }), + ) +} + +// Generic function to create and serialize a payload. +fn create_payload(nonce: u64, body: TransactionBody) -> Result, TxError> { + let payload = SigningPayload { + nonce: Nonce(Integer::from(nonce)), + body, + }; + + payload.try_into() +} diff --git a/kairos-tx/src/lib.rs b/kairos-tx/src/lib.rs new file mode 100644 index 00000000..930a804f --- /dev/null +++ b/kairos-tx/src/lib.rs @@ -0,0 +1,3 @@ +pub mod asn; +pub mod error; +pub mod helpers; diff --git a/nixos/default.nix b/nixos/default.nix index 02890ffb..1757047e 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -30,6 +30,7 @@ in ./tests/end-to-end.nix { inherit mkKairosHostConfig; + inherit (self.packages."x86_64-linux") kairos; }; }; nixosModules = { diff --git a/nixos/tests/end-to-end.nix b/nixos/tests/end-to-end.nix index 3611cb55..335fa8b4 100644 --- a/nixos/tests/end-to-end.nix +++ b/nixos/tests/end-to-end.nix @@ -1,5 +1,7 @@ { nixosTest , mkKairosHostConfig +, kairos +, testResources ? ../../kairos-cli/tests/fixtures }: nixosTest { name = "kairos e2e test"; @@ -18,7 +20,7 @@ nixosTest { }; client = { config, pkgs, nodes, ... }: { - environment.systemPackages = [ pkgs.curl ]; + environment.systemPackages = [ pkgs.curl kairos ]; }; }; @@ -34,6 +36,7 @@ nixosTest { client.wait_for_unit ("multi-user.target") deposit_request = { "public_key": "publickey", "amount": 10 } + # REST API client.succeed("curl -X POST http://kairos/api/v1/deposit -H 'Content-Type: application/json' -d '{}'".format(json.dumps(deposit_request))) transfer_request = { "from": "publickey", "signature": "signature", "to": "publickey", "amount": 10 } @@ -41,5 +44,26 @@ nixosTest { withdraw_request = { "public_key": "publickey", "signature": "signature", "amount": 10 } client.succeed("curl -X POST http://kairos/api/v1/withdraw -H 'Content-Type: application/json' -d '{}'".format(json.dumps(withdraw_request))) + + # CLI with ed25519 + cli_output = client.succeed("kairos-cli deposit --amount 1000 --private-key ${testResources}/ed25519/secret_key.pem") + assert "ok\n" in cli_output + + cli_output = client.succeed("kairos-cli transfer --recipient '01a26419a7d82b2263deaedea32d35eee8ae1c850bd477f62a82939f06e80df356' --amount 1000 --private-key ${testResources}/ed25519/secret_key.pem") + assert "ok\n" in cli_output + + cli_output = client.succeed("kairos-cli withdraw --amount 1000 --private-key ${testResources}/ed25519/secret_key.pem") + assert "ok\n" in cli_output + + # CLI with secp256k1 + cli_output = client.succeed("kairos-cli deposit --amount 1000 --private-key ${testResources}/secp256k1/secret_key.pem") + assert "ok\n" in cli_output + + cli_output = client.succeed("kairos-cli transfer --recipient '01a26419a7d82b2263deaedea32d35eee8ae1c850bd477f62a82939f06e80df356' --amount 1000 --private-key ${testResources}/secp256k1/secret_key.pem") + assert "ok\n" in cli_output + + cli_output = client.succeed("kairos-cli withdraw --amount 1000 --private-key ${testResources}/secp256k1/secret_key.pem") + assert "ok\n" in cli_output ''; } +