lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README

commit c36c993cf8b9eefefbf13c57dac0bf58975ff4cd
parent 2a42f64be23017c16b80f30ef1e02982c281f03b
Author: triesap <tyson@radroots.org>
Date:   Mon, 26 Oct 2026 08:36:06 +0000

signing: share scoped commerce plan verification

- Move complete original plan crypto qualification out of Nostr.
- Verify through attached identity and bounded scoped provider calls.
- Remove the predecessor export and update native T1 callers.
- Verify real cryptography, lifecycle, T1, portable features and APIs.

Diffstat:
Mcontracts/api_baselines/radroots_execution.txt | 2++
Mcontracts/api_baselines/radroots_nostr.txt | 8--------
Mcontracts/api_baselines/radroots_signing.txt | 9+++++++++
Mcontracts/api_baselines/radroots_storage_sqlite.txt | 2+-
Mcontracts/architecture/decisions/shared_sdk_refactor.v1.json | 4++++
Mcrates/execution/Cargo.toml | 3++-
Mcrates/execution/README.md | 10++++++++++
Mcrates/execution/src/session/signer.rs | 3+++
Acrates/execution/src/session/signer_commerce.rs | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acrates/execution/tests/fixtures/commerce_verification/README.md | 12++++++++++++
Acrates/execution/tests/fixtures/commerce_verification/command_wire.json | 2++
Acrates/execution/tests/fixtures/commerce_verification/plan_wire.bin | 0
Acrates/execution/tests/fixtures/commerce_verification/record_wire.json | 2++
Mcrates/execution/tests/signer_session.rs | 17++++++++++++++++-
Acrates/execution/tests/support/signer_commerce.rs | 165+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcrates/nostr/README.md | 2+-
Mcrates/nostr/src/commerce.rs | 2--
Dcrates/nostr/src/commerce/signing_plan.rs | 114-------------------------------------------------------------------------------
Mcrates/nostr/tests/commerce_signing.rs | 3++-
Acrates/radroots/tests/fixtures/commerce_verification/README.md | 9+++++++++
Acrates/radroots/tests/fixtures/commerce_verification/command_wire.json | 2++
Acrates/radroots/tests/fixtures/commerce_verification/plan_wire.bin | 0
Acrates/radroots/tests/fixtures/commerce_verification/record_wire.json | 2++
Mcrates/radroots/tests/native_client.rs | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcrates/signing/README.md | 11++++++++++-
Acrates/signing/src/commerce.rs | 117+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcrates/signing/src/lib.rs | 2++
Mcrates/signing/tests/package_boundary.rs | 2++
Mcrates/storage_sqlite/src/workspace/stock/public_source/signing_tests.rs | 2+-
Mcrates/storage_sqlite/src/workspace/stock/signing_plan.rs | 2+-
Mtools/xtask/src/architecture/decision_package.rs | 18++++++++++++++++++
31 files changed, 547 insertions(+), 132 deletions(-)

diff --git a/contracts/api_baselines/radroots_execution.txt b/contracts/api_baselines/radroots_execution.txt @@ -87,6 +87,8 @@ pub async fn radroots_execution::session::SignerSession::quiesce(&self) -> radro pub async fn radroots_execution::session::SignerSession::recover_exact(&self, radroots_signing::issuance::exact_recovery::ExactRecoveryRequest) -> radroots_signing::issuance::exact_recovery::ExactRecoveryOutcome pub async fn radroots_execution::session::SignerSession::sign_exact(&self, radroots_signing::issuance::SigningIntent) -> radroots_signing::issuance::SigningOutcome pub fn radroots_execution::session::SignerSession::state(&self) -> radroots_execution::session::SessionState +impl radroots_execution::session::SignerSession +pub async fn radroots_execution::session::SignerSession::verify_commerce_plan(&self, radroots_signing::provider::ProviderCall, &radroots_protocol::commerce::rumor::EncodedCommerceRumor, radroots_protocol::commerce::signing_plan::CommerceSigningPlan) -> core::result::Result<radroots_signing::commerce::VerifiedCommerceSigningPlan, radroots_signing::provider::ProviderError> impl core::clone::Clone for radroots_execution::session::SignerSession pub fn radroots_execution::session::SignerSession::clone(&self) -> Self pub struct radroots_execution::session::WorkPermit<H: radroots_execution::session::SessionHost> diff --git a/contracts/api_baselines/radroots_nostr.txt b/contracts/api_baselines/radroots_nostr.txt @@ -73,14 +73,6 @@ pub struct radroots_nostr::commerce::NonActionable<R> impl<R: core::marker::Copy> radroots_nostr::commerce::NonActionable<R> pub const fn radroots_nostr::commerce::NonActionable<R>::carrier(&self) -> &radroots_nostr::private_ingress::AuthenticatedCarrier pub const fn radroots_nostr::commerce::NonActionable<R>::reason(&self) -> R -pub struct radroots_nostr::commerce::VerifiedCommerceSigningPlan -impl radroots_nostr::commerce::VerifiedCommerceSigningPlan -pub const fn radroots_nostr::commerce::VerifiedCommerceSigningPlan::deadline_unix_ms(&self) -> u64 -pub fn radroots_nostr::commerce::VerifiedCommerceSigningPlan::into_plan(self) -> radroots_protocol::commerce::signing_plan::CommerceSigningPlan -pub const fn radroots_nostr::commerce::VerifiedCommerceSigningPlan::plan(&self) -> &radroots_protocol::commerce::signing_plan::CommerceSigningPlan -pub async fn radroots_nostr::commerce::VerifiedCommerceSigningPlan::verify(&dyn radroots_signing::provider::ParticipantProvider, radroots_signing::provider::ProviderCall, &radroots_protocol::commerce::rumor::EncodedCommerceRumor, radroots_protocol::commerce::signing_plan::CommerceSigningPlan) -> core::result::Result<Self, radroots_signing::provider::ProviderError> -impl core::fmt::Debug for radroots_nostr::commerce::VerifiedCommerceSigningPlan -pub fn radroots_nostr::commerce::VerifiedCommerceSigningPlan::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub fn radroots_nostr::commerce::admit(radroots_nostr::private_ingress::AuthenticatedCarrier) -> radroots_nostr::commerce::RecordOpening pub async fn radroots_nostr::commerce::open(&dyn radroots_signing::provider::ParticipantProvider, radroots_signing::provider::ProviderCall, &str) -> core::result::Result<radroots_nostr::commerce::RecordOpening, radroots_nostr::private_ingress::OpeningError> pub mod radroots_nostr::event diff --git a/contracts/api_baselines/radroots_signing.txt b/contracts/api_baselines/radroots_signing.txt @@ -68,6 +68,15 @@ pub const fn radroots_signing::capability::SignerCapability::may_require_authent pub const fn radroots_signing::capability::SignerCapability::new(radroots_signing::capability::SignerKind, radroots_signing::recovery::ReplayCapability, radroots_signing::capability::CancellationSupport, bool, bool) -> Self pub const fn radroots_signing::capability::SignerCapability::replay(self) -> radroots_signing::recovery::ReplayCapability pub const fn radroots_signing::capability::SignerCapability::reports_progress(self) -> bool +pub mod radroots_signing::commerce +pub struct radroots_signing::commerce::VerifiedCommerceSigningPlan +impl radroots_signing::commerce::VerifiedCommerceSigningPlan +pub const fn radroots_signing::commerce::VerifiedCommerceSigningPlan::deadline_unix_ms(&self) -> u64 +pub fn radroots_signing::commerce::VerifiedCommerceSigningPlan::into_plan(self) -> radroots_protocol::commerce::signing_plan::CommerceSigningPlan +pub const fn radroots_signing::commerce::VerifiedCommerceSigningPlan::plan(&self) -> &radroots_protocol::commerce::signing_plan::CommerceSigningPlan +pub async fn radroots_signing::commerce::VerifiedCommerceSigningPlan::verify(&dyn radroots_signing::provider::ParticipantProvider, radroots_signing::provider::ProviderCall, &radroots_protocol::commerce::rumor::EncodedCommerceRumor, radroots_protocol::commerce::signing_plan::CommerceSigningPlan) -> core::result::Result<Self, radroots_signing::provider::ProviderError> +impl core::fmt::Debug for radroots_signing::commerce::VerifiedCommerceSigningPlan +pub fn radroots_signing::commerce::VerifiedCommerceSigningPlan::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub mod radroots_signing::error #[non_exhaustive] pub enum radroots_signing::error::Kind pub radroots_signing::error::Kind::AuthorizationDenied diff --git a/contracts/api_baselines/radroots_storage_sqlite.txt b/contracts/api_baselines/radroots_storage_sqlite.txt @@ -698,7 +698,7 @@ impl core::fmt::Debug for radroots_storage_sqlite::workspace::StockSigningAttemp pub fn radroots_storage_sqlite::workspace::StockSigningAttempt::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub struct radroots_storage_sqlite::workspace::StockSigningPlanRequest impl radroots_storage_sqlite::workspace::StockSigningPlanRequest -pub fn radroots_storage_sqlite::workspace::StockSigningPlanRequest::new(radroots_storage::workspace::WorkspaceBinding, radroots_storage::inventory::InventoryCheckpointRef, radroots_nostr::commerce::signing_plan::VerifiedCommerceSigningPlan) -> core::result::Result<Self, radroots_storage::command::OperationError> +pub fn radroots_storage_sqlite::workspace::StockSigningPlanRequest::new(radroots_storage::workspace::WorkspaceBinding, radroots_storage::inventory::InventoryCheckpointRef, radroots_signing::commerce::VerifiedCommerceSigningPlan) -> core::result::Result<Self, radroots_storage::command::OperationError> impl core::fmt::Debug for radroots_storage_sqlite::workspace::StockSigningPlanRequest pub fn radroots_storage_sqlite::workspace::StockSigningPlanRequest::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result pub struct radroots_storage_sqlite::workspace::StockSnapshotRequest diff --git a/contracts/architecture/decisions/shared_sdk_refactor.v1.json b/contracts/architecture/decisions/shared_sdk_refactor.v1.json @@ -241,6 +241,10 @@ "source_carrier_max_bytes": 65536, "source_chunk_max_bytes": 16384, "signing_plan_binding": { + "crypto_verifier_owner": "radroots_signing.commerce", + "scoped_crypto_verification": "SignerSession.verify_commerce_plan", + "predecessor_nostr_verifier_alias": false, + "crypto_verification_grants_dispatch_authority": false, "payload_version": 1, "journal_family": 3, "worker_charge_bytes": 1048576, diff --git a/crates/execution/Cargo.toml b/crates/execution/Cargo.toml @@ -17,7 +17,8 @@ default = [] session = ["dep:futures"] signer_session = ["session", "dep:radroots_signing"] client_session = ["signer_session"] -workspace_session = ["client_session", "receipts", "radroots_protocol/commands", "radroots_protocol/listing", "radroots_signing/artifacts", "dep:radroots_transport", "radroots_storage/protected_outbox"] +commerce = ["signer_session", "radroots_signing/commerce", "radroots_protocol/commerce"] +workspace_session = ["client_session", "commerce", "receipts", "radroots_protocol/commands", "radroots_protocol/listing", "radroots_signing/artifacts", "dep:radroots_transport", "radroots_storage/protected_outbox"] receipts = ["dep:radroots_storage", "radroots_storage/command_journal"] [dependencies] diff --git a/crates/execution/README.md b/crates/execution/README.md @@ -196,3 +196,13 @@ append retry cannot resolve a concrete host's uncertain connection. The qualifie native host retains writer ownership while authenticating and reopening that same namespace. Core keeps the original material and leases until a matching confirmed result, including through a refused preflight or lost observer. + +With `commerce`, `SignerSession::verify_commerce_plan` qualifies the complete +original plan through the attached provider's frozen observed identity and +existing per-call admission. Changed identity latches a refusal, and missing +capabilities or a closing scope cannot confirm a plan. Active decryption retains +provider/callback roots until settlement; each observation and decryption uses +the existing single-call capacity. No legacy or first-signing method is invoked. +The shared Signing proof preserves original bytes and deadline without granting +T1 or stock authority. The composing executor still owns the complete task and +subsequent durable boundaries after caller cancellation. diff --git a/crates/execution/src/session/signer.rs b/crates/execution/src/session/signer.rs @@ -9,6 +9,9 @@ use std::{ }; use super::{HostFuture, Session, SessionHost, SessionState, host::Shared}; +#[cfg(feature = "commerce")] +#[path = "signer_commerce.rs"] +mod commerce; struct Binding { provider: Shared<dyn ParticipantProvider>, diff --git a/crates/execution/src/session/signer_commerce.rs b/crates/execution/src/session/signer_commerce.rs @@ -0,0 +1,77 @@ +//! Portable crypto qualification through the existing observed signer scope. +use super::*; +use radroots_protocol::commerce::{CommerceSigningPlan, EncodedCommerceRumor}; +use radroots_signing::{ + SignReceipt, SignRequest, Signer, SignerStatus, commerce::VerifiedCommerceSigningPlan, + signer::BoxFuture, +}; + +// Each observation/decryption uses the scope's existing single-call admission. +// A second surrounding permit would consume that capacity before IO can start. +struct ScopedProvider<'a>(&'a SignerSession); +impl Signer for ScopedProvider<'_> { + fn status(&self) -> BoxFuture<'_, Result<SignerStatus, radroots_signing::Error>> { + Box::pin(async { Ok(SignerStatus::unavailable()) }) + } + fn sign( + &self, + _request: SignRequest, + ) -> BoxFuture<'_, Result<SignReceipt, radroots_signing::Error>> { + Box::pin(async { + Err(radroots_signing::Error::new( + radroots_signing::error::Kind::SignerUnavailable, + )) + }) + } +} +impl ParticipantProvider for ScopedProvider<'_> { + fn provider_state(&self) -> BoxFuture<'_, Result<ProviderState, ProviderError>> { + Box::pin(async move { + if self.0.state() != SessionState::Running { + return Err(ProviderError::CapabilityUnavailable); + } + self.0.observe().await + }) + } + fn encrypt_private( + &self, + call: ProviderCall, + recipient: radroots_domain::PublicKey, + plaintext: PrivateText, + ) -> BoxFuture<'_, Result<PrivateCiphertext, ProviderError>> { + Box::pin(self.0.encrypt_private(call, recipient, plaintext)) + } + fn decrypt_private( + &self, + call: ProviderCall, + sender: radroots_domain::PublicKey, + ciphertext: PrivateCiphertext, + ) -> BoxFuture<'_, Result<PrivateText, ProviderError>> { + Box::pin(self.0.decrypt_private(call, sender, ciphertext)) + } +} +impl SignerSession { + /// Checks the exact original peer/self ciphertexts and signed routes through + /// this attached scope. It signs nothing and grants no T1, dispatch, stock + /// or network authority. The composing executor owns the complete task. + pub async fn verify_commerce_plan( + &self, + call: ProviderCall, + rumor: &EncodedCommerceRumor, + plan: CommerceSigningPlan, + ) -> Result<VerifiedCommerceSigningPlan, ProviderError> { + if self.state() != SessionState::Running { + return Err(ProviderError::CapabilityUnavailable); + } + if self.identity_changed() { + return Err(ProviderError::IdentityChanged); + } + let observed = self + .observed() + .ok_or(ProviderError::CapabilityUnavailable)?; + if observed.identity() != rumor.author() || call.identity() != observed.identity() { + return Err(ProviderError::IdentityChanged); + } + VerifiedCommerceSigningPlan::verify(&ScopedProvider(self), call, rumor, plan).await + } +} diff --git a/crates/execution/tests/fixtures/commerce_verification/README.md b/crates/execution/tests/fixtures/commerce_verification/README.md @@ -0,0 +1,12 @@ +# Commerce scope verification input + +These are literal extractions from the retained independent Nostr commerce signing vector. +They support controlled Core scope tests; they supply no new cryptographic or transaction qualification. + +Source: `crates/nostr/tests/fixtures/commerce_signing.v1.json`, SHA-256 `1d0a2e846ed9308fb35f2b3046d6fa52f0cf95fe25b05b51fa5f06b41eb4e122`. + +The actual Nostr LocalSigner tests retain the complete original vector and qualify the shared verifier cryptographically. + +- `command_wire.json`: SHA-256 `885ad89e2ece65a4bf670a7df6d5c25b9ca3018d0bff60634f5489b7610f058d`. +- `record_wire.json`: SHA-256 `c6cae54b2d00d8675bd8694fa2eb46df8e9133220c08d1ebf71da91baaca2beb`. +- `plan_wire.bin`: SHA-256 `458840ff907b5d478ce4be792b2a5e0cfb76e15a699b329624ed352894c66ee2`. diff --git a/crates/execution/tests/fixtures/commerce_verification/command_wire.json b/crates/execution/tests/fixtures/commerce_verification/command_wire.json @@ -0,0 +1 @@ +{"context":{"actor":{"grant_id":"8282828282828282828282828282828282828282828282828282828282828282","organization":null,"participant":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","role":"seller"},"approval":null,"authority":{"executor_id":"1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e","generation":"1"},"correlation_id":null,"expected":{"agreement":null,"buyer_head":"08e8f87c0741efae469e140a5cf4468a9b87830492cb716202a8f826ebea89d4","checkpoint":{"coverage":"scope_satisfied","digest":"8585858585858585858585858585858585858585858585858585858585858585","missing":[],"sequence":"2"},"order_id":"1515151515151515151515151515151515151515151515151515151515151515","seller_sequence":"0"},"not_after":"600","operation_id":"8181818181818181818181818181818181818181818181818181818181818181","route_digest":"8484848484848484848484848484848484848484848484848484848484848484","workspace_id":"8383838383838383838383838383838383838383838383838383838383838383"},"input":{"allocation":{"type":"automatic"},"request":"08e8f87c0741efae469e140a5cf4468a9b87830492cb716202a8f826ebea89d4","terms_digest":"2fa1cfe8dbfd48c632469e9cd52c20c2f84ea388e4fb5867bdd3c77447c07690"},"type":"orders.accept"} +\ No newline at end of file diff --git a/crates/execution/tests/fixtures/commerce_verification/plan_wire.bin b/crates/execution/tests/fixtures/commerce_verification/plan_wire.bin Binary files differ. diff --git a/crates/execution/tests/fixtures/commerce_verification/record_wire.json b/crates/execution/tests/fixtures/commerce_verification/record_wire.json @@ -0,0 +1 @@ +{"author":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","author_previous":null,"author_sequence":"1","buyer":"c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5","created_at":"451","order_id":"1515151515151515151515151515151515151515151515151515151515151515","parents":["08e8f87c0741efae469e140a5cf4468a9b87830492cb716202a8f826ebea89d4"],"payload":{"authority":{"executor_id":"1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e","generation":"1"},"authorization":"08e8f87c0741efae469e140a5cf4468a9b87830492cb716202a8f826ebea89d4","base_agreement":null,"seller_sequence":"1","terms_digest":"2fa1cfe8dbfd48c632469e9cd52c20c2f84ea388e4fb5867bdd3c77447c07690"},"profile":"radroots.commerce","record_id":"1cc411f51afb3b4b7eaabca8c3577f337521e034a795a51f691e69338df3e96c","seller":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","thread_id":"1414141414141414141414141414141414141414141414141414141414141414","type":"agreement_committed","version":1} +\ No newline at end of file diff --git a/crates/execution/tests/signer_session.rs b/crates/execution/tests/signer_session.rs @@ -22,6 +22,9 @@ use std::sync::{ Mutex, atomic::{AtomicBool, AtomicUsize, Ordering}, }; +#[cfg(all(feature = "commerce", not(target_arch = "wasm32")))] +#[path = "support/signer_commerce.rs"] +mod commerce; #[cfg(not(target_arch = "wasm32"))] #[path = "support/signer_recovery.rs"] mod recovery; @@ -49,6 +52,7 @@ fn state(second: bool, encrypt: bool) -> ProviderState { } struct Control { + commerce_plaintext: Mutex<Option<String>>, recovery_calls: AtomicUsize, recovery_response: Mutex<Option<oneshot::Receiver<radroots_signing::issuance::ExactRecoveryOutcome>>>, @@ -172,7 +176,17 @@ impl ParticipantProvider for Provider { ) -> BoxFuture<'_, Result<PrivateText, ProviderError>> { Box::pin(async move { self.0.crypto_calls.fetch_add(1, Ordering::SeqCst); - Err(ProviderError::ProviderFailure) + let response = self.0.crypto_response.lock().unwrap().take(); + if let Some(response) = response { + response.await.map_err(|_| ProviderError::Cancelled)?; + } + self.0 + .commerce_plaintext + .lock() + .unwrap() + .as_deref() + .map(PrivateText::new) + .unwrap_or(Err(ProviderError::ProviderFailure)) }) } } @@ -232,6 +246,7 @@ fn scope() -> Fixture { fn control() -> Shared<Control> { Shared::new(Control { + commerce_plaintext: Mutex::new(None), recovery_calls: AtomicUsize::new(0), recovery_response: Mutex::new(None), recovery_binding: Mutex::new(None), diff --git a/crates/execution/tests/support/signer_commerce.rs b/crates/execution/tests/support/signer_commerce.rs @@ -0,0 +1,165 @@ +//! Controlled scope behavior; real cryptography remains in Nostr's retained tests. +use super::*; +use radroots_protocol::{ + command::CapturedOrderAcceptance, + commerce::{self, CommerceSigningPlan, EncodedCommerceRumor}, +}; +use radroots_signing::request::CancellationSignal; + +fn data() -> (EncodedCommerceRumor, CommerceSigningPlan) { + let command = CapturedOrderAcceptance::parse(include_bytes!( + "../fixtures/commerce_verification/command_wire.json" + )) + .unwrap(); + let record = commerce::decode(include_bytes!( + "../fixtures/commerce_verification/record_wire.json" + )) + .unwrap(); + let rumor = EncodedCommerceRumor::capture(record.content()).unwrap(); + let plan = CommerceSigningPlan::parse( + command.context().operation_id(), + command.digest(), + &rumor, + include_bytes!("../fixtures/commerce_verification/plan_wire.bin"), + ) + .unwrap(); + (rumor, plan) +} +fn supported() -> ProviderState { + state(false, true).with_exact_issuance(Some(ReplayCapability::NonReplayable)) +} +fn call(second: bool) -> ProviderCall { + ProviderCall::new( + key(second), + core::num::NonZeroU64::new(600000).unwrap(), + CancellationSignal::new(), + ) +} +fn configure(control: &Control) { + *control.current.lock().unwrap() = supported(); + *control.commerce_plaintext.lock().unwrap() = Some(data().0.protected_wire().to_owned()); +} +#[test] +fn scope_verifies_complete_original_plan_and_refuses_unobserved_foreign_changed_and_closed_calls() { + let Fixture { + session, + control, + provider, + callbacks, + } = scope(); + configure(&control); + let (rumor, plan) = data(); + assert!(matches!( + block_on(session.verify_commerce_plan(call(false), &rumor, plan)), + Err(ProviderError::CapabilityUnavailable) + )); + assert_eq!(control.crypto_calls.load(Ordering::SeqCst), 0); + block_on(session.observe()).unwrap(); + let (rumor, plan) = data(); + assert!(matches!( + block_on(session.verify_commerce_plan(call(true), &rumor, plan)), + Err(ProviderError::IdentityChanged) + )); + assert!(!session.identity_changed()); + let (rumor, plan) = data(); + let verified = block_on(session.verify_commerce_plan(call(false), &rumor, plan)).unwrap(); + assert_eq!( + verified.plan().protected_wire(), + include_bytes!("../fixtures/commerce_verification/plan_wire.bin") + ); + assert_eq!(verified.deadline_unix_ms(), 600000); + assert_eq!(control.crypto_calls.load(Ordering::SeqCst), 2); + for unavailable in [ + state(false, false).with_exact_issuance(Some(ReplayCapability::NonReplayable)), + state(false, true), + ] { + *control.current.lock().unwrap() = unavailable; + let (rumor, plan) = data(); + assert!(matches!( + block_on(session.verify_commerce_plan(call(false), &rumor, plan)), + Err(ProviderError::CapabilityUnavailable) + )); + assert_eq!(control.crypto_calls.load(Ordering::SeqCst), 2); + } + *control.current.lock().unwrap() = + state(true, true).with_exact_issuance(Some(ReplayCapability::NonReplayable)); + let (rumor, plan) = data(); + assert!(matches!( + block_on(session.verify_commerce_plan(call(false), &rumor, plan)), + Err(ProviderError::IdentityChanged) + )); + assert!(session.identity_changed()); + assert_eq!(control.crypto_calls.load(Ordering::SeqCst), 2); + assert_eq!(control.sign_calls.load(Ordering::SeqCst), 0); + block_on(session.close()).unwrap(); + assert!(provider.upgrade().is_none() && callbacks.upgrade().is_none()); + let (rumor, plan) = data(); + assert!(matches!( + block_on(session.verify_commerce_plan(call(false), &rumor, plan)), + Err(ProviderError::CapabilityUnavailable) + )); +} + +#[test] +fn pending_actual_decryption_keeps_callback_roots_until_settlement_and_close_refuses_completion() { + let Fixture { + session, + control, + provider, + callbacks, + } = scope(); + configure(&control); + block_on(session.observe()).unwrap(); + let (send, receive) = oneshot::channel(); + *control.crypto_response.lock().unwrap() = Some(receive); + let (rumor, plan) = data(); + let mut verify = Box::pin(session.verify_commerce_plan(call(false), &rumor, plan)); + let mut cx = Context::from_waker(noop_waker_ref()); + assert!(verify.as_mut().poll(&mut cx).is_pending()); + assert_eq!(control.crypto_calls.load(Ordering::SeqCst), 1); + let mut close = Box::pin(session.close()); + assert!(close.as_mut().poll(&mut cx).is_pending()); + assert_eq!(control.close_attempts.load(Ordering::SeqCst), 0); + assert!(provider.upgrade().is_some() && callbacks.upgrade().is_some()); + send.send(()).unwrap(); + assert!(matches!( + verify.as_mut().poll(&mut cx), + Poll::Ready(Err(ProviderError::CapabilityUnavailable)) + )); + assert!(matches!(close.as_mut().poll(&mut cx), Poll::Ready(Ok(())))); + assert_eq!(control.crypto_calls.load(Ordering::SeqCst), 1); + assert_eq!(control.sign_calls.load(Ordering::SeqCst), 0); + assert!(provider.upgrade().is_none() && callbacks.upgrade().is_none()); +} + +#[test] +fn identity_change_during_decryption_latches_and_never_confirms_a_plan_or_calls_signing() { + let Fixture { + session, control, .. + } = scope(); + configure(&control); + block_on(session.observe()).unwrap(); + let (send, receive) = oneshot::channel(); + *control.crypto_response.lock().unwrap() = Some(receive); + let (rumor, plan) = data(); + let mut verify = Box::pin(session.verify_commerce_plan(call(false), &rumor, plan)); + let mut cx = Context::from_waker(noop_waker_ref()); + assert!(verify.as_mut().poll(&mut cx).is_pending()); + *control.current.lock().unwrap() = + state(true, true).with_exact_issuance(Some(ReplayCapability::NonReplayable)); + send.send(()).unwrap(); + assert!(matches!( + block_on(verify), + Err(ProviderError::IdentityChanged) + )); + assert!(session.identity_changed()); + configure(&control); + let (rumor, plan) = data(); + assert!(matches!( + block_on(session.verify_commerce_plan(call(false), &rumor, plan)), + Err(ProviderError::IdentityChanged) + )); + assert_eq!(control.crypto_calls.load(Ordering::SeqCst), 1); + assert_eq!(control.sign_calls.load(Ordering::SeqCst), 0); + block_on(session.close()).unwrap(); +} diff --git a/crates/nostr/README.md b/crates/nostr/README.md @@ -191,7 +191,7 @@ clock failure cannot discard obtained bytes. This path performs no encryption, route replacement, network call or legacy fallback. After-expiry durable signer retrieval is unavailable. Legacy replay and first-dispatch behavior are unchanged. -`commerce::VerifiedCommerceSigningPlan::verify` checks both exact recipient +`radroots_signing::commerce::VerifiedCommerceSigningPlan::verify` checks both exact recipient ciphertexts against the original rumor through the selected participant provider, verifies original signed DM advertisements and their selected subsets, and checks the provider's actual replay declaration. It performs no signing or diff --git a/crates/nostr/src/commerce.rs b/crates/nostr/src/commerce.rs @@ -107,5 +107,3 @@ pub async fn open( private_ingress::open(provider, call, raw_outer).await?, )) } -mod signing_plan; -pub use signing_plan::VerifiedCommerceSigningPlan; diff --git a/crates/nostr/src/commerce/signing_plan.rs b/crates/nostr/src/commerce/signing_plan.rs @@ -1,114 +0,0 @@ -//! Crypto qualification for exact structured-commerce T1 data. No signing. -use alloc::string::String; -use core::fmt; -use radroots_protocol::{ - commerce::{CommerceSigningPlan, EncodedCommerceRumor}, - intent::SigningReplay, -}; -use radroots_signing::{ - issuance::VerifiedDmRelayAdvertisement, - provider::{ - ParticipantProvider, PrivateCiphertext, PrivateCryptoCapability, ProviderCall, - ProviderError, - }, - recovery::ReplayCapability, -}; - -/// Exact preimages whose encryption and original signed route advertisements -/// were checked through the selected participant provider. This proves no -/// current store consent, target network policy, dispatch or T1 commit. -pub struct VerifiedCommerceSigningPlan { - plan: CommerceSigningPlan, - deadline_ms: u64, -} -impl VerifiedCommerceSigningPlan { - /// Verifies all peer/self ciphertexts against the unchanged original rumor - /// before any business signing. Identity/capability changes fail closed. - /// The caller owns any encryption prompting/attempt lifecycle separately. - pub async fn verify( - provider: &dyn ParticipantProvider, - call: ProviderCall, - rumor: &EncodedCommerceRumor, - plan: CommerceSigningPlan, - ) -> Result<Self, ProviderError> { - let original = CommerceSigningPlan::parse( - plan.operation_id(), - plan.command_digest(), - rumor, - plan.protected_wire(), - ) - .map_err(|_| ProviderError::InvalidInput)?; - for (seal, route) in original.seals().iter().zip(original.routes()) { - let verified = - VerifiedDmRelayAdvertisement::verify(route.raw_json(), seal.recipient())?; - let targets: alloc::vec::Vec<String> = route - .selected_relays() - .iter() - .map(|value| String::from(value.as_ref())) - .collect(); - let checked = verified.capture_route(&targets)?; - if checked.source_id() != route.source_id() { - return Err(ProviderError::AuthenticationFailed); - } - } - for seal in original.seals() { - state(provider, &call, rumor, original.replay()).await?; - let ciphertext = PrivateCiphertext::parse(seal.fields().content)?; - let clear = provider - .decrypt_private(call.clone(), seal.recipient(), ciphertext) - .await?; - state(provider, &call, rumor, original.replay()).await?; - if clear.expose() != rumor.protected_wire() { - return Err(ProviderError::AuthenticationFailed); - } - } - Ok(Self { - plan: original, - deadline_ms: call.deadline_unix_ms().get(), - }) - } - pub const fn plan(&self) -> &CommerceSigningPlan { - &self.plan - } - pub const fn deadline_unix_ms(&self) -> u64 { - self.deadline_ms - } - pub fn into_plan(self) -> CommerceSigningPlan { - self.plan - } -} -async fn state( - provider: &dyn ParticipantProvider, - call: &ProviderCall, - rumor: &EncodedCommerceRumor, - replay: SigningReplay, -) -> Result<(), ProviderError> { - let state = provider.provider_state().await?; - let supported = match replay { - SigningReplay::NonReplayable => { - state.exact_issuance() == Some(ReplayCapability::NonReplayable) - } - SigningReplay::LocalReplaySafe => { - state.exact_issuance().is_some() - && state.exact_recovery() - == radroots_signing::issuance::ExactRecoveryCapability::LocalExactReplay - } - SigningReplay::ExactReplayByRequestId => { - state.exact_issuance() == Some(ReplayCapability::ExactReplayByRequestId) - } - }; - if call.identity() != rumor.author() - || state.identity() != rumor.author() - || state.encryption() != PrivateCryptoCapability::Nip44V2 - || state.decryption() != PrivateCryptoCapability::Nip44V2 - || !supported - { - return Err(ProviderError::CapabilityUnavailable); - } - Ok(()) -} -impl fmt::Debug for VerifiedCommerceSigningPlan { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.write_str("VerifiedCommerceSigningPlan(<redacted>)") - } -} diff --git a/crates/nostr/tests/commerce_signing.rs b/crates/nostr/tests/commerce_signing.rs @@ -1,11 +1,12 @@ #![cfg(feature = "commerce")] -use radroots_nostr::{commerce::VerifiedCommerceSigningPlan, key::SecretKey, signing::LocalSigner}; +use radroots_nostr::{key::SecretKey, signing::LocalSigner}; use radroots_protocol::{ command::CapturedOrderAcceptance, commerce::{self, CommerceSeal, CommerceSigningPlan}, intent::SigningReplay, nip59::CapturedDmRoute, }; +use radroots_signing::commerce::VerifiedCommerceSigningPlan; use radroots_signing::{ issuance::{OutcomeKind, SigningIntent}, provider::{NonceSource, ParticipantProvider, PrivateText, ProviderCall, ProviderError}, diff --git a/crates/radroots/tests/fixtures/commerce_verification/README.md b/crates/radroots/tests/fixtures/commerce_verification/README.md @@ -0,0 +1,9 @@ +# Native commerce scope verification input + +Literal extraction from the retained independent commerce signing vector for the actual ordinary Client/LocalSigner case. + +Source: `crates/nostr/tests/fixtures/commerce_signing.v1.json`, SHA-256 `1d0a2e846ed9308fb35f2b3046d6fa52f0cf95fe25b05b51fa5f06b41eb4e122`. + +- `command_wire.json`: SHA-256 `885ad89e2ece65a4bf670a7df6d5c25b9ca3018d0bff60634f5489b7610f058d`. +- `record_wire.json`: SHA-256 `c6cae54b2d00d8675bd8694fa2eb46df8e9133220c08d1ebf71da91baaca2beb`. +- `plan_wire.bin`: SHA-256 `458840ff907b5d478ce4be792b2a5e0cfb76e15a699b329624ed352894c66ee2`. diff --git a/crates/radroots/tests/fixtures/commerce_verification/command_wire.json b/crates/radroots/tests/fixtures/commerce_verification/command_wire.json @@ -0,0 +1 @@ +{"context":{"actor":{"grant_id":"8282828282828282828282828282828282828282828282828282828282828282","organization":null,"participant":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","role":"seller"},"approval":null,"authority":{"executor_id":"1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e","generation":"1"},"correlation_id":null,"expected":{"agreement":null,"buyer_head":"08e8f87c0741efae469e140a5cf4468a9b87830492cb716202a8f826ebea89d4","checkpoint":{"coverage":"scope_satisfied","digest":"8585858585858585858585858585858585858585858585858585858585858585","missing":[],"sequence":"2"},"order_id":"1515151515151515151515151515151515151515151515151515151515151515","seller_sequence":"0"},"not_after":"600","operation_id":"8181818181818181818181818181818181818181818181818181818181818181","route_digest":"8484848484848484848484848484848484848484848484848484848484848484","workspace_id":"8383838383838383838383838383838383838383838383838383838383838383"},"input":{"allocation":{"type":"automatic"},"request":"08e8f87c0741efae469e140a5cf4468a9b87830492cb716202a8f826ebea89d4","terms_digest":"2fa1cfe8dbfd48c632469e9cd52c20c2f84ea388e4fb5867bdd3c77447c07690"},"type":"orders.accept"} +\ No newline at end of file diff --git a/crates/radroots/tests/fixtures/commerce_verification/plan_wire.bin b/crates/radroots/tests/fixtures/commerce_verification/plan_wire.bin Binary files differ. diff --git a/crates/radroots/tests/fixtures/commerce_verification/record_wire.json b/crates/radroots/tests/fixtures/commerce_verification/record_wire.json @@ -0,0 +1 @@ +{"author":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","author_previous":null,"author_sequence":"1","buyer":"c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5","created_at":"451","order_id":"1515151515151515151515151515151515151515151515151515151515151515","parents":["08e8f87c0741efae469e140a5cf4468a9b87830492cb716202a8f826ebea89d4"],"payload":{"authority":{"executor_id":"1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e","generation":"1"},"authorization":"08e8f87c0741efae469e140a5cf4468a9b87830492cb716202a8f826ebea89d4","base_agreement":null,"seller_sequence":"1","terms_digest":"2fa1cfe8dbfd48c632469e9cd52c20c2f84ea388e4fb5867bdd3c77447c07690"},"profile":"radroots.commerce","record_id":"1cc411f51afb3b4b7eaabca8c3577f337521e034a795a51f691e69338df3e96c","seller":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","thread_id":"1414141414141414141414141414141414141414141414141414141414141414","type":"agreement_committed","version":1} +\ No newline at end of file diff --git a/crates/radroots/tests/native_client.rs b/crates/radroots/tests/native_client.rs @@ -115,6 +115,81 @@ fn local() -> Arc<LocalSigner> { } #[tokio::test] +async fn ordinary_native_scoped_commerce_verification_keeps_the_exact_independent_plan_and_releases_roots() + { + use radroots_protocol::{ + command::CapturedOrderAcceptance, + commerce::{self, CommerceSigningPlan, EncodedCommerceRumor}, + }; + use radroots_signing::{ + provider::{NonceSource, ProviderCall}, + request::CancellationSignal, + }; + struct Nonce; + impl NonceSource for Nonce { + fn next_nonce(&self) -> Result<[u8; 32], ProviderError> { + Ok([42; 32]) + } + } + let command = CapturedOrderAcceptance::parse(include_bytes!( + "fixtures/commerce_verification/command_wire.json" + )) + .unwrap(); + let record = commerce::decode(include_bytes!( + "fixtures/commerce_verification/record_wire.json" + )) + .unwrap(); + let rumor = EncodedCommerceRumor::capture(record.content()).unwrap(); + let wire = include_bytes!("fixtures/commerce_verification/plan_wire.bin"); + let plan = CommerceSigningPlan::parse( + command.context().operation_id(), + command.digest(), + &rumor, + wire, + ) + .unwrap(); + let root = tempfile::tempdir().unwrap(); + let selected = options(root.path()); + let client = Client::open(NativeConfig::public_read(selected.clone())) + .await + .unwrap(); + let provider = Arc::new( + LocalSigner::with_clock( + parse_secret_key("0000000000000000000000000000000000000000000000000000000000000001") + .unwrap(), + || Ok(451000), + ) + .unwrap() + .with_nonce_source(Arc::new(Nonce)), + ); + let author = provider.public_key(); + let weak = Arc::downgrade(&provider); + let scope = client + .attach_signer(SignerHandle::new(provider, callbacks(selected, true))) + .await + .unwrap(); + let call = ProviderCall::new( + author, + std::num::NonZeroU64::new(600000).unwrap(), + CancellationSignal::new(), + ); + let verified = scope + .verify_commerce_plan(call, &rumor, plan) + .await + .unwrap(); + assert_eq!(verified.plan().protected_wire(), wire); + assert_eq!(verified.deadline_unix_ms(), 600000); + client.close().await.unwrap(); + assert!(weak.upgrade().is_none()); + assert_eq!( + verified.plan().operation_id(), + command.context().operation_id() + ); + // This crypto proof outlives key cleanup; it proves no workspace grant, T1, + // first signature, installed order or configured network target. +} + +#[tokio::test] async fn ordinary_native_scoped_recovery_keeps_original_fields_and_refuses_expired_original() { use radroots::signing::{ ArtifactRole, ExactRecoveryKind, ExactRecoveryRequest, OutcomeKind, SigningIntent, diff --git a/crates/signing/README.md b/crates/signing/README.md @@ -222,7 +222,7 @@ secret material in it. | `std` | yes | Uses `std` collections and permits preserved native error sources; no runtime, I/O, or global initialization is added. | | `serde` | yes | Adds serialization for explicitly passive public values and deserialization only where validated reconstruction is safe. | | `chat` | no | Adds bounded chat-seal conversion and authenticated DM advertisements. | -| `commerce` | no | Adds exact structured-commerce seal conversion and authenticated DM advertisements. | +| `commerce` | no | Adds exact structured-commerce seal conversion, authenticated DM advertisements and complete original plan verification. | | `artifacts` | no | Adds captured chat/public-listing artifact conversion. | Features are additive. `--no-default-features` provides the `no_std + alloc` @@ -285,3 +285,12 @@ Recovery outcomes enforce the original callback binding with the same bounded rejection/fingerprint policy as issuance outcomes. A mismatched callback cannot be promoted to the expected operation; a correctly bound obtained artifact is retained unchanged. Callback rejection remains distinct from nonissuance. + +With `commerce`, `commerce::VerifiedCommerceSigningPlan::verify` qualifies both +original peer/self ciphertexts against their captured rumor and verifies signed +DM advertisements, selected route subsets and the actual provider's replay and +private-crypto capabilities. It observes identity and capabilities around each +decryption, signs nothing and retains the original call deadline. The proof +grants no workspace consent, T1 commit, dispatch, stock or network authority. +This portable verifier is shared by scoped execution and concrete native T1; +the predecessor Nostr export is removed without an alias. diff --git a/crates/signing/src/commerce.rs b/crates/signing/src/commerce.rs @@ -0,0 +1,117 @@ +//! Crypto qualification for exact structured-commerce T1 data. No signing. +use crate::{ + issuance::VerifiedDmRelayAdvertisement, + provider::{ + ParticipantProvider, PrivateCiphertext, PrivateCryptoCapability, ProviderCall, + ProviderError, + }, + recovery::ReplayCapability, +}; +#[cfg(not(feature = "std"))] +use alloc::{string::String, vec::Vec}; +use core::fmt; +use radroots_protocol::{ + commerce::{CommerceSigningPlan, EncodedCommerceRumor}, + intent::SigningReplay, +}; +#[cfg(feature = "std")] +use std::{string::String, vec::Vec}; + +/// Exact preimages whose encryption and original signed route advertisements +/// were checked through the selected participant provider. This proves no +/// current store consent, target network policy, dispatch or T1 commit. +pub struct VerifiedCommerceSigningPlan { + plan: CommerceSigningPlan, + deadline_ms: u64, +} +impl VerifiedCommerceSigningPlan { + /// Verifies all peer/self ciphertexts against the unchanged original rumor + /// before any business signing. Identity/capability changes fail closed. + /// The caller owns any encryption prompting/attempt lifecycle separately. + pub async fn verify( + provider: &dyn ParticipantProvider, + call: ProviderCall, + rumor: &EncodedCommerceRumor, + plan: CommerceSigningPlan, + ) -> Result<Self, ProviderError> { + let original = CommerceSigningPlan::parse( + plan.operation_id(), + plan.command_digest(), + rumor, + plan.protected_wire(), + ) + .map_err(|_| ProviderError::InvalidInput)?; + for (seal, route) in original.seals().iter().zip(original.routes()) { + let verified = + VerifiedDmRelayAdvertisement::verify(route.raw_json(), seal.recipient())?; + let targets: Vec<String> = route + .selected_relays() + .iter() + .map(|value| String::from(value.as_ref())) + .collect(); + let checked = verified.capture_route(&targets)?; + if checked.source_id() != route.source_id() { + return Err(ProviderError::AuthenticationFailed); + } + } + for seal in original.seals() { + state(provider, &call, rumor, original.replay()).await?; + let ciphertext = PrivateCiphertext::parse(seal.fields().content)?; + let clear = provider + .decrypt_private(call.clone(), seal.recipient(), ciphertext) + .await?; + state(provider, &call, rumor, original.replay()).await?; + if clear.expose() != rumor.protected_wire() { + return Err(ProviderError::AuthenticationFailed); + } + } + Ok(Self { + plan: original, + deadline_ms: call.deadline_unix_ms().get(), + }) + } + pub const fn plan(&self) -> &CommerceSigningPlan { + &self.plan + } + pub const fn deadline_unix_ms(&self) -> u64 { + self.deadline_ms + } + pub fn into_plan(self) -> CommerceSigningPlan { + self.plan + } +} +async fn state( + provider: &dyn ParticipantProvider, + call: &ProviderCall, + rumor: &EncodedCommerceRumor, + replay: SigningReplay, +) -> Result<(), ProviderError> { + let state = provider.provider_state().await?; + let supported = match replay { + SigningReplay::NonReplayable => { + state.exact_issuance() == Some(ReplayCapability::NonReplayable) + } + SigningReplay::LocalReplaySafe => { + state.exact_issuance().is_some() + && state.exact_recovery() + == crate::issuance::ExactRecoveryCapability::LocalExactReplay + } + SigningReplay::ExactReplayByRequestId => { + state.exact_issuance() == Some(ReplayCapability::ExactReplayByRequestId) + } + }; + if call.identity() != rumor.author() + || state.identity() != rumor.author() + || state.encryption() != PrivateCryptoCapability::Nip44V2 + || state.decryption() != PrivateCryptoCapability::Nip44V2 + || !supported + { + return Err(ProviderError::CapabilityUnavailable); + } + Ok(()) +} +impl fmt::Debug for VerifiedCommerceSigningPlan { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("VerifiedCommerceSigningPlan(<redacted>)") + } +} diff --git a/crates/signing/src/lib.rs b/crates/signing/src/lib.rs @@ -8,6 +8,8 @@ extern crate alloc; pub mod actor; pub mod authorization; pub mod capability; +#[cfg(feature = "commerce")] +pub mod commerce; pub mod error; pub mod host; pub mod identity; diff --git a/crates/signing/tests/package_boundary.rs b/crates/signing/tests/package_boundary.rs @@ -77,6 +77,7 @@ fn crate_root_declares_the_approved_module_skeleton() { "actor", "authorization", "capability", + "commerce", "error", "host", "identity", @@ -100,6 +101,7 @@ fn crate_root_declares_the_approved_module_skeleton() { "actor", "authorization", "capability", + "commerce", "error", "host", "identity", diff --git a/crates/storage_sqlite/src/workspace/stock/public_source/signing_tests.rs b/crates/storage_sqlite/src/workspace/stock/public_source/signing_tests.rs @@ -4,12 +4,12 @@ use super::*; #[path = "claim_tests.rs"] mod claims; use crate::workspace::{StockBoundSigningPlan, StockSigningPlanOutcome, StockSigningPlanRequest}; -use radroots_nostr::commerce::VerifiedCommerceSigningPlan; use radroots_protocol::{ commerce::{CommerceSeal, CommerceSigningPlan}, intent::SigningReplay, nip59::CapturedDmRoute, }; +use radroots_signing::commerce::VerifiedCommerceSigningPlan; use radroots_signing::provider::{NonceSource, ParticipantProvider, PrivateText, ProviderError}; struct TestNonce(u8); impl NonceSource for TestNonce { diff --git a/crates/storage_sqlite/src/workspace/stock/signing_plan.rs b/crates/storage_sqlite/src/workspace/stock/signing_plan.rs @@ -5,8 +5,8 @@ use inventory::{ checkpoint::{self, EntryIdentity, IdentityTarget, MinimumProof}, }; use radroots_domain::{CheckpointDigest, CommandDigest, OperationId, UnixSeconds}; -use radroots_nostr::commerce::VerifiedCommerceSigningPlan; use radroots_protocol::commerce::CommerceSigningPlan; +use radroots_signing::commerce::VerifiedCommerceSigningPlan; use radroots_storage::{ command::{CommitAttempt, OperationError}, inventory::InventoryCheckpointRef, diff --git a/tools/xtask/src/architecture/decision_package.rs b/tools/xtask/src/architecture/decision_package.rs @@ -324,6 +324,10 @@ struct SigningIssuance { #[derive(Deserialize)] #[serde(deny_unknown_fields)] struct SigningPlanBinding { + crypto_verifier_owner: String, + scoped_crypto_verification: String, + predecessor_nostr_verifier_alias: bool, + crypto_verification_grants_dispatch_authority: bool, payload_version: u16, journal_family: u16, worker_charge_bytes: u32, @@ -597,6 +601,13 @@ fn validate_bytes(raw: &[u8]) -> Result<(), String> { .final_source_counts_and_witnesses_required && !stock.acceptance_preparation.signer_invoked && !stock.acceptance_preparation.agreement_installed + && stock.signing_plan_binding.crypto_verifier_owner == "radroots_signing.commerce" + && stock.signing_plan_binding.scoped_crypto_verification + == "SignerSession.verify_commerce_plan" + && !stock.signing_plan_binding.predecessor_nostr_verifier_alias + && !stock + .signing_plan_binding + .crypto_verification_grants_dispatch_authority && stock.signing_plan_binding.payload_version == 1 && stock.signing_plan_binding.journal_family == 3 && stock.signing_plan_binding.worker_charge_bytes == 1048576 @@ -1682,6 +1693,13 @@ mod tests { #[test] fn signing_plans_require_complete_original_qualified_intents_before_any_signing() { for (field, bad) in [ + ("crypto_verifier_owner", json!("radroots_nostr.commerce")), + ( + "scoped_crypto_verification", + json!("ParticipantProvider.sign_exact"), + ), + ("predecessor_nostr_verifier_alias", json!(true)), + ("crypto_verification_grants_dispatch_authority", json!(true)), ("payload_version", json!(2)), ("journal_family", json!(2)), ("worker_charge_bytes", json!(524288)),