lib

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

commit 9d0574aee11389a5038d61f0bf769884b73e9ddd
parent 4301e21d780d637b5ce16bb9e270da92e1f5848d
Author: triesap <tyson@radroots.org>
Date:   Sat, 17 Oct 2026 19:12:40 +0000

signing: retain exact obtained signature facts

- Bind full operation identities to captured signing intents and event budgets.
- Preserve authenticated output across missing or late completion observations.
- Reject ambiguous signer output and keep callback resources scoped.
- Verify actual native signatures, portable callers, APIs and coverage gates.

Diffstat:
MCargo.lock | 4++++
Mcontracts/api_baselines/radroots.txt | 6++++++
Mcontracts/api_baselines/radroots_execution.txt | 1+
Mcontracts/api_baselines/radroots_nostr.txt | 1+
Mcontracts/api_baselines/radroots_signing.txt | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcontracts/architecture/decisions/shared_sdk_compiler_preparation.v1.json | 2+-
Acontracts/architecture/decisions/shared_sdk_issuance.v1.json | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Mcontracts/architecture/decisions/shared_sdk_refactor.v1.json | 1+
Mcontracts/architecture/deviations.toml | 30++++++++++++++++++++++++++++++
Mcrates/event/src/wire/v1.rs | 98+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcrates/event/src/wire/v1/tests.rs | 122+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcrates/execution/Cargo.toml | 2++
Mcrates/execution/src/session/signer.rs | 34++++++++++++++++++++++++++++++++++
Mcrates/execution/tests/signer_session.rs | 185+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcrates/nostr/src/signing.rs | 1+
Acrates/nostr/src/signing/issuance.rs | 220+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcrates/nostr/src/signing/private.rs | 12+++++++++++-
Mcrates/radroots/Cargo.toml | 1+
Mcrates/radroots/src/signing.rs | 3+++
Mcrates/radroots/tests/native_client.rs | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcrates/signing/Cargo.toml | 2++
Mcrates/signing/README.md | 27+++++++++++++++++++++++++++
Acrates/signing/src/issuance.rs | 471+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcrates/signing/src/lib.rs | 1+
Mcrates/signing/src/provider.rs | 40+++++++++++++++++++++++++++++++++++++++-
Acrates/signing/tests/issuance.rs | 609+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcrates/signing/tests/package_boundary.rs | 5+++++
Mtools/xtask/src/architecture/decision_package.rs | 2+-
Mtools/xtask/src/compiler_preparation.rs | 2+-
29 files changed, 2061 insertions(+), 5 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -3044,6 +3044,7 @@ dependencies = [ "radroots_core", "radroots_domain", "radroots_event", + "radroots_event_codec", "radroots_execution", "radroots_identity", "radroots_nostr", @@ -3165,6 +3166,8 @@ version = "0.1.0-alpha" dependencies = [ "futures", "radroots_domain", + "radroots_event", + "radroots_event_codec", "radroots_identity", "radroots_signing", ] @@ -3521,6 +3524,7 @@ dependencies = [ "hex", "nostr 0.44.7", "radroots_blossom", + "radroots_domain", "radroots_event", "radroots_event_codec", "radroots_identity", diff --git a/contracts/api_baselines/radroots.txt b/contracts/api_baselines/radroots.txt @@ -95,12 +95,18 @@ pub use radroots::listing::PrepareErrorKind pub use radroots::listing::PrepareRequest pub use radroots::listing::prepare pub mod radroots::signing +pub use radroots::signing::ArtifactRole pub use radroots::signing::AuthorizationHeader pub use radroots::signing::BlossomAuthorizationPlan pub use radroots::signing::BlossomSigningError +pub use radroots::signing::IntentBinding pub use radroots::signing::Mode pub use radroots::signing::Operations +pub use radroots::signing::OutcomeKind pub use radroots::signing::Provider +pub use radroots::signing::SignedArtifact +pub use radroots::signing::SigningIntent +pub use radroots::signing::SigningOutcome pub use radroots::signing::blossom_upload_request pub mod radroots::storage pub use radroots::storage::IntegrityStatus diff --git a/contracts/api_baselines/radroots_execution.txt b/contracts/api_baselines/radroots_execution.txt @@ -34,6 +34,7 @@ pub fn radroots_execution::session::SignerSession::new(radroots_signing::provide pub async fn radroots_execution::session::SignerSession::observe(&self) -> core::result::Result<radroots_signing::provider::ProviderState, radroots_signing::provider::ProviderError> pub fn radroots_execution::session::SignerSession::observed(&self) -> core::option::Option<radroots_signing::provider::ProviderState> pub async fn radroots_execution::session::SignerSession::quiesce(&self) -> radroots_execution::Result<()> +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 core::clone::Clone for radroots_execution::session::SignerSession pub fn radroots_execution::session::SignerSession::clone(&self) -> Self diff --git a/contracts/api_baselines/radroots_nostr.txt b/contracts/api_baselines/radroots_nostr.txt @@ -277,6 +277,7 @@ impl radroots_signing::provider::ParticipantProvider for radroots_nostr::signing pub fn radroots_nostr::signing::LocalSigner::decrypt_private(&self, radroots_signing::provider::ProviderCall, radroots_identity::key::PublicKey, radroots_signing::provider::PrivateCiphertext) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<radroots_signing::provider::PrivateText, radroots_signing::provider::ProviderError>> pub fn radroots_nostr::signing::LocalSigner::encrypt_private(&self, radroots_signing::provider::ProviderCall, radroots_identity::key::PublicKey, radroots_signing::provider::PrivateText) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<radroots_signing::provider::PrivateCiphertext, radroots_signing::provider::ProviderError>> pub fn radroots_nostr::signing::LocalSigner::provider_state(&self) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<radroots_signing::provider::ProviderState, radroots_signing::provider::ProviderError>> +pub fn radroots_nostr::signing::LocalSigner::sign_exact(&self, radroots_signing::issuance::SigningIntent) -> radroots_signing::signer::BoxFuture<'_, radroots_signing::issuance::SigningOutcome> impl radroots_signing::signer::Signer for radroots_nostr::signing::LocalSigner pub fn radroots_nostr::signing::LocalSigner::sign(&self, radroots_signing::request::SignRequest) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<radroots_signing::receipt::SignReceipt, radroots_signing::error::Error>> pub fn radroots_nostr::signing::LocalSigner::status(&self) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<radroots_signing::status::SignerStatus, radroots_signing::error::Error>> diff --git a/contracts/api_baselines/radroots_signing.txt b/contracts/api_baselines/radroots_signing.txt @@ -145,6 +145,65 @@ pub fn radroots_signing::identity::SigningOperationId::new([u8; 16]) -> core::re pub fn radroots_signing::identity::SigningOperationId::to_hex(self) -> alloc::string::String impl core::fmt::Debug for radroots_signing::identity::SigningOperationId pub fn radroots_signing::identity::SigningOperationId::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result +pub mod radroots_signing::issuance +#[non_exhaustive] pub enum radroots_signing::issuance::ArtifactRole +pub radroots_signing::issuance::ArtifactRole::BusinessSeal +pub radroots_signing::issuance::ArtifactRole::GiftWrap +pub radroots_signing::issuance::ArtifactRole::PublicEvent +#[non_exhaustive] pub enum radroots_signing::issuance::OutcomeKind +pub radroots_signing::issuance::OutcomeKind::NotDispatched(radroots_signing::provider::ProviderError) +pub radroots_signing::issuance::OutcomeKind::Obtained(radroots_signing::issuance::SignedArtifact) +pub radroots_signing::issuance::OutcomeKind::Rejected(radroots_signing::issuance::RejectedArtifact) +pub radroots_signing::issuance::OutcomeKind::Unknown(radroots_signing::provider::ProviderError) +#[non_exhaustive] pub enum radroots_signing::issuance::RejectionReason +pub radroots_signing::issuance::RejectionReason::BindingMismatch +pub radroots_signing::issuance::RejectionReason::InvalidArtifact +pub radroots_signing::issuance::RejectionReason::InvalidSignature +pub radroots_signing::issuance::RejectionReason::TooLarge +pub struct radroots_signing::issuance::ArtifactFingerprint +impl radroots_signing::issuance::ArtifactFingerprint +pub const fn radroots_signing::issuance::ArtifactFingerprint::covered_bytes(self) -> usize +pub const fn radroots_signing::issuance::ArtifactFingerprint::sha256(&self) -> &[u8; 32] +pub const fn radroots_signing::issuance::ArtifactFingerprint::total_bytes(self) -> usize +pub struct radroots_signing::issuance::IntentBinding +impl radroots_signing::issuance::IntentBinding +pub const fn radroots_signing::issuance::IntentBinding::command_digest(&self) -> &[u8; 32] +pub const fn radroots_signing::issuance::IntentBinding::digest(&self) -> &[u8; 32] +pub const fn radroots_signing::issuance::IntentBinding::operation_id(self) -> radroots_domain::identifier::OperationId +pub struct radroots_signing::issuance::RejectedArtifact +impl radroots_signing::issuance::RejectedArtifact +pub const fn radroots_signing::issuance::RejectedArtifact::fingerprint(self) -> core::option::Option<radroots_signing::issuance::ArtifactFingerprint> +pub const fn radroots_signing::issuance::RejectedArtifact::reason(self) -> radroots_signing::issuance::RejectionReason +pub struct radroots_signing::issuance::SignedArtifact +impl radroots_signing::issuance::SignedArtifact +pub const fn radroots_signing::issuance::SignedArtifact::event_id(&self) -> radroots_event::id::EventId +pub const fn radroots_signing::issuance::SignedArtifact::observed_at_unix_ms(&self) -> core::option::Option<core::num::nonzero::NonZeroU64> +pub fn radroots_signing::issuance::SignedArtifact::with_json<T>(&self, impl core::ops::function::FnOnce(&str) -> T) -> T +impl core::fmt::Debug for radroots_signing::issuance::SignedArtifact +pub fn radroots_signing::issuance::SignedArtifact::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result +pub struct radroots_signing::issuance::SigningIntent +impl radroots_signing::issuance::SigningIntent +pub const fn radroots_signing::issuance::SigningIntent::author(&self) -> radroots_identity::key::PublicKey +pub const fn radroots_signing::issuance::SigningIntent::binding(&self) -> radroots_signing::issuance::IntentBinding +pub fn radroots_signing::issuance::SigningIntent::check_before_effect(&self, radroots_identity::key::PublicKey, u64) -> core::result::Result<(), radroots_signing::provider::ProviderError> +pub fn radroots_signing::issuance::SigningIntent::new(radroots_domain::identifier::OperationId, [u8; 32], radroots_event_codec::authoring::AuthoredEventPlan, radroots_signing::issuance::ArtifactRole, core::option::Option<radroots_identity::key::PublicKey>, radroots_signing::provider::ProviderCall) -> core::result::Result<Self, radroots_signing::provider::ProviderError> +pub const fn radroots_signing::issuance::SigningIntent::recipient(&self) -> core::option::Option<radroots_identity::key::PublicKey> +pub const fn radroots_signing::issuance::SigningIntent::role(&self) -> radroots_signing::issuance::ArtifactRole +pub const fn radroots_signing::issuance::SigningIntent::signed_json_bytes(&self) -> usize +pub fn radroots_signing::issuance::SigningIntent::with_plan<T>(&self, impl core::ops::function::FnOnce(&radroots_event_codec::authoring::AuthoredEventPlan) -> T) -> T +impl core::fmt::Debug for radroots_signing::issuance::SigningIntent +pub fn radroots_signing::issuance::SigningIntent::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result +pub struct radroots_signing::issuance::SigningOutcome +impl radroots_signing::issuance::SigningOutcome +pub const fn radroots_signing::issuance::SigningOutcome::binding(&self) -> radroots_signing::issuance::IntentBinding +pub fn radroots_signing::issuance::SigningOutcome::capture(&radroots_signing::issuance::SigningIntent, alloc::string::String, core::option::Option<core::num::nonzero::NonZeroU64>) -> Self +pub fn radroots_signing::issuance::SigningOutcome::enforce_binding(self, radroots_signing::issuance::IntentBinding) -> Self +pub fn radroots_signing::issuance::SigningOutcome::into_parts(self) -> (radroots_signing::issuance::IntentBinding, radroots_signing::issuance::OutcomeKind) +pub const fn radroots_signing::issuance::SigningOutcome::kind(&self) -> &radroots_signing::issuance::OutcomeKind +pub const fn radroots_signing::issuance::SigningOutcome::not_dispatched(radroots_signing::issuance::IntentBinding, radroots_signing::provider::ProviderError) -> Self +pub const fn radroots_signing::issuance::SigningOutcome::unknown(radroots_signing::issuance::IntentBinding, radroots_signing::provider::ProviderError) -> Self +pub const radroots_signing::issuance::MAX_EVENT_UNIX_SECONDS: u64 +pub const radroots_signing::issuance::SIGNED_EVENT_MAX_BYTES: usize pub mod radroots_signing::provider pub enum radroots_signing::provider::PrivateCryptoCapability pub radroots_signing::provider::PrivateCryptoCapability::Nip44V2 @@ -180,15 +239,18 @@ pub fn radroots_signing::provider::PrivateText::fmt(&self, &mut core::fmt::Forma pub struct radroots_signing::provider::ProviderCall impl radroots_signing::provider::ProviderCall pub fn radroots_signing::provider::ProviderCall::check_before_effect(&self, radroots_identity::key::PublicKey, u64) -> core::result::Result<(), radroots_signing::provider::ProviderError> +pub const fn radroots_signing::provider::ProviderCall::deadline_unix_ms(&self) -> core::num::nonzero::NonZeroU64 pub const fn radroots_signing::provider::ProviderCall::identity(&self) -> radroots_identity::key::PublicKey pub const fn radroots_signing::provider::ProviderCall::new(radroots_identity::key::PublicKey, core::num::nonzero::NonZeroU64, radroots_signing::request::CancellationSignal) -> Self pub struct radroots_signing::provider::ProviderState impl radroots_signing::provider::ProviderState pub const fn radroots_signing::provider::ProviderState::decryption(self) -> radroots_signing::provider::PrivateCryptoCapability pub const fn radroots_signing::provider::ProviderState::encryption(self) -> radroots_signing::provider::PrivateCryptoCapability +pub const fn radroots_signing::provider::ProviderState::exact_issuance(self) -> core::option::Option<radroots_signing::recovery::ReplayCapability> pub const fn radroots_signing::provider::ProviderState::identity(self) -> radroots_identity::key::PublicKey pub const fn radroots_signing::provider::ProviderState::new(radroots_identity::key::PublicKey, radroots_signing::provider::PrivateCryptoCapability, radroots_signing::provider::PrivateCryptoCapability, radroots_signing::recovery::ReplayCapability) -> Self pub const fn radroots_signing::provider::ProviderState::signing_replay(self) -> radroots_signing::recovery::ReplayCapability +pub const fn radroots_signing::provider::ProviderState::with_exact_issuance(self, core::option::Option<radroots_signing::recovery::ReplayCapability>) -> Self pub struct radroots_signing::provider::SignerHandle impl radroots_signing::provider::SignerHandle pub fn radroots_signing::provider::SignerHandle::into_parts(self) -> (radroots_signing::host::Shared<dyn radroots_signing::provider::ParticipantProvider>, radroots_signing::host::Shared<dyn radroots_signing::provider::SignerCallbacks>) @@ -200,6 +262,7 @@ pub trait radroots_signing::provider::ParticipantProvider: radroots_signing::sig pub fn radroots_signing::provider::ParticipantProvider::decrypt_private(&self, radroots_signing::provider::ProviderCall, radroots_identity::key::PublicKey, radroots_signing::provider::PrivateCiphertext) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<radroots_signing::provider::PrivateText, radroots_signing::provider::ProviderError>> pub fn radroots_signing::provider::ParticipantProvider::encrypt_private(&self, radroots_signing::provider::ProviderCall, radroots_identity::key::PublicKey, radroots_signing::provider::PrivateText) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<radroots_signing::provider::PrivateCiphertext, radroots_signing::provider::ProviderError>> pub fn radroots_signing::provider::ParticipantProvider::provider_state(&self) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<radroots_signing::provider::ProviderState, radroots_signing::provider::ProviderError>> +pub fn radroots_signing::provider::ParticipantProvider::sign_exact(&self, radroots_signing::issuance::SigningIntent) -> radroots_signing::signer::BoxFuture<'_, radroots_signing::issuance::SigningOutcome> pub trait radroots_signing::provider::SignerCallbacks: radroots_signing::host::HostBound pub fn radroots_signing::provider::SignerCallbacks::close(&self) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<(), radroots_signing::provider::ProviderError>> pub fn radroots_signing::provider::SignerCallbacks::quiesce(&self) -> radroots_signing::signer::BoxFuture<'_, core::result::Result<(), radroots_signing::provider::ProviderError>> diff --git a/contracts/architecture/decisions/shared_sdk_compiler_preparation.v1.json b/contracts/architecture/decisions/shared_sdk_compiler_preparation.v1.json @@ -8,7 +8,7 @@ "source_inputs": [ { "path": "contracts/architecture/decisions/shared_sdk_refactor.v1.json", - "sha256": "b4568699c2010c0574e4e32c68aca9f3ee16cb5e2f4a7e6553dc21d636e6cb58" + "sha256": "7937dc9ee4aca42f015d3bba5b23e2b5e7cffe461589518bd6eef6305892931e" }, { "path": "contracts/architecture/decisions/services_hardening_source_lock.v4.json", diff --git a/contracts/architecture/decisions/shared_sdk_issuance.v1.json b/contracts/architecture/decisions/shared_sdk_issuance.v1.json @@ -0,0 +1,49 @@ +{ + "schema_version": 1, + "contract_id": "radroots.shared_sdk.issuance.v1", + "state": "approved_target_implementation_pending", + "owning_package": "radroots_signing", + "concrete_native_provider": "radroots_nostr", + "operation_identity": "Use radroots_domain::OperationId directly; never truncate or fabricate a legacy sixteen-byte identity", + "direct_domain_edge": "Signing ports consume canonical domain values as allowed by the approved specification; no new package owner or semantic engine", + "intent": [ + "operation_id", + "command_digest", + "exact authored preimage and event_id", + "purpose", + "recipient", + "original first-issue deadline", + "frozen signer identity" + ], + "construction_authority": "Validated intent values are neither an authenticated command context nor durable admission", + "event_max_bytes": 65536, + "profile_limits": "Executor applies tighter chat, record and rumor limits before constructing this generic event boundary", + "before_effect": "Check actual signer identity, bounded exact fields, capabilities, captured deadline and cancellation before invoking cryptography", + "after_effect": "Verify and preserve obtained authenticated bytes regardless of later clock failure, expiry or cancellation; missing observation is explicit null", + "malformed_output": "Bounded tampering classification and scoped forensic digest; never authenticated business status", + "unsupported_provider": "Explicitly unavailable with no legacy signing fallback", + "replay": "Provider observation never overrides retained uncertainty; successor execution uses the qualified exact captured-intent contract", + "durability": "Only actual T0/T1/S/T2/D store execution and owned workers establish durable behavior", + "remaining": [ + "Protected authenticated workspace and complete command context", + "Complete operation receipts", + "Actual durable native listing/chat and fault recovery", + "Remote/platform/browser provider qualification", + "All retained caller migration, bindings and final acceptance" + ], + "exact_result_profile": { + "fields": [ + "id", + "pubkey", + "created_at", + "kind", + "tags", + "content", + "sig" + ], + "root_keys": "exactly once, including escaped spellings", + "unknown_fields": "unsupported", + "json_depth": 16, + "semantic_validation": "existing bounded NIP-01 decoder and cryptographic verification" + } +} diff --git a/contracts/architecture/decisions/shared_sdk_refactor.v1.json b/contracts/architecture/decisions/shared_sdk_refactor.v1.json @@ -131,6 +131,7 @@ "package": "radroots_signing", "directory": "crates/signing", "dependencies": [ + "domain", "identity", "protocol" ], diff --git a/contracts/architecture/deviations.toml b/contracts/architecture/deviations.toml @@ -2,6 +2,36 @@ schema_version = 1 architecture_id = "radroots.crates.release.v1" [[deviation]] +id = "RCRV1-DEV-052" +date = "2026-10-17" +status = "closed" +approval = "The user authorizes the complete approved shared SDK refactor, necessary breaking changes, verified source commits and ordinary master publication." +affected_steps = ["040", "050", "060", "070", "110", "120", "130"] +spec_anchors = ["contracts/crates/release_v1/radroots_crates_release_v1.toml#package.radroots_signing", "contracts/crates/release_v1/radroots_crates_release_v1.toml#package.radroots_nostr"] +source_evidence = [ + "The local adapter signs before reading a fallible completion clock and rechecking expiry/cancellation. The authored default delegates to that path, so already obtained valid signatures can be discarded.", + "Legacy signing operation/artifact identities are sixteen bytes and authored evidence requires a positive observation time. Neither can represent the approved new operation identity and nullable observation contract by truncation or an invented timestamp.", + "The approved domain owns the implemented thirty-two-byte OperationId. The specification assigns signing ports downward domain/protocol dependencies; the prospective signing edge list omitted the direct domain edge needed to use that canonical type.", +] +replacement_action = "Before the new durable native command consumes a signer, implement an exact-intent issuance boundary using the canonical domain operation identity, immutable command/plan/purpose/recipient/deadline binding, bounded complete-event inputs and authenticated obtained bytes with optional observation time. Qualify the concrete local adapter with real signatures, failed completion clocks, late/cancelled results and malformed output. Unsupported providers explicitly report unavailable without delegating to the lossy legacy method. Update the prospective direct domain edge and owning guards. Preserve existing source/history while requiring every successor worker/provider to adopt the new contract; do not claim the retained legacy consumers corrected by this primitive alone." +verification = [ + "Validate this prospective deviation and machine decision before implementation. Prove exact unsigned fields, operation/digest/recipient binding, complete-event byte limits before effects, explicit unsupported behavior and redacted diagnostics.", + "Execute actual local signing and independent signature verification when the completion clock fails, expires or observes cancellation. Preserve genuine unknown/tampered outcomes without successful business or durable-admission claims.", + "Run affected native source checks/tests/docs/strict lint, native/WASM callers, generated API freshness, unchanged actual coverage gates and owning architecture/dependency/contracts. Preserve existing concrete-provider test purposes and all final native/browser/binding/durable requirements.", +] +unresolved_risk = "A qualified signing primitive does not authenticate a workspace, commit T0/T1/S/T2/D, retain work across process exit, qualify remote/platform providers or migrate retained legacy callers. Those remain required before complete known-kind and downstream acceptance." +normative_architecture_change = true +adr_required = true +closure_evidence = [ + "The canonical full-width operation and captured command/preimage/role/recipient/deadline binding execute with exact event-size preflight and real Schnorr verification. Original authenticated bytes survive missing, late, zero or cancelled completion observation; unsupported providers never invoke the legacy signer.", + "Exact seven-field ingress rejects duplicate and escaped duplicate keys, unsupported fields, malformed structure and excessive nesting before semantic decoding. Existing general wire behavior and retained caller migration obligations are preserved.", + "Standalone execution, actual native SQLite/LocalSigner callers, native source/tests/docs/strict lint, Rc-local WASM and no_std checks pass. The original unused-import lint and standalone missing alloc::Box failures remain preserved with their narrow repairs.", + "The original Signing branch gate failure remains preserved. Every one of the same six pure exact-field/ID comparisons is retained in a reordered rejection; actual changed authenticated fields, frozen identity/time, preflight and byte budgets execute. Affected native/portable callers and strict lint are requalified; the unchanged upstream Event measurement is reused only for its unchanged owner scope.", + "Owning generated APIs, architecture/catalog/contracts/API/dependency boundaries and actual unchanged ninety-percent coverage gates pass. This closes the obtained-signing primitive only; authenticated workspace/context, complete receipts, durable T0/T1/S/T2/D, owned workers, browser/platform providers, bindings, retained legacy callers and final consumer acceptance remain required.", +] + + +[[deviation]] id = "RCRV1-DEV-051" date = "2026-10-17" status = "closed" diff --git a/crates/event/src/wire/v1.rs b/crates/event/src/wire/v1.rs @@ -266,6 +266,27 @@ impl Nip01EventWire { Ok(wire) } + /// Parses the exact seven-field NIP-01 event profile. Root keys, including + /// escaped spellings, must occur exactly once; nesting is bounded to 16 + /// before the semantic JSON decoder allocates values. Unknown fields are + /// unsupported by this exact signing-result profile. Historical/general + /// decoding retains its separately governed behavior. + pub fn parse_json_exact_with_limits( + raw_json: &str, + limits: EventWireLimits, + ) -> Result<Self, EventWireError> { + if raw_json.len() > limits.max_raw_json_bytes { + return Err(EventWireError::RawJsonTooLarge { + max: limits.max_raw_json_bytes, + actual: raw_json.len(), + }); + } + if !exact_event_json_shape(raw_json) { + return Err(EventWireError::InvalidField("exact_event_profile")); + } + Self::parse_json_with_limits(raw_json, limits) + } + /// Parses and structurally validates an event under explicit limits /// without verifying its ID. pub fn parse_json_unverified_with_limits( @@ -655,6 +676,83 @@ fn push_unicode_escape(target: &mut String, character: char) { target.push(HEX[(value & 0x0f) as usize] as char); } +// This policy guard does not interpret event values. The existing JSON and +// event validators remain authoritative for syntax, types, budgets and ID. +fn exact_event_json_shape(raw: &str) -> bool { + let (mut depth, mut seen) = (0usize, 0u8); + let (mut in_string, mut escaped, mut expect_key, mut root_key) = (false, false, false, false); + let mut start = 0usize; + for (index, byte) in raw.bytes().enumerate() { + if in_string { + if escaped { + escaped = false; + continue; + } + match byte { + b'\\' => escaped = true, + b'"' => { + in_string = false; + if root_key { + // Every supported ASCII key has at most ten characters; + // even its fully escaped spelling fits this bound. + if index - start + 1 > 64 { + return false; + } + let Ok(key) = serde_json::from_str::<String>(&raw[start..=index]) else { + return false; + }; + let bit = match key.as_str() { + "id" => 1, + "pubkey" => 2, + "created_at" => 4, + "kind" => 8, + "tags" => 16, + "content" => 32, + "sig" => 64, + _ => return false, + }; + if seen & bit != 0 { + return false; + } + seen |= bit; + } + } + _ => {} + } + continue; + } + match byte { + b'"' => { + in_string = true; + start = index; + root_key = depth == 1 && expect_key; + } + b'{' | b'[' => { + if depth == 0 { + if byte != b'{' || seen != 0 { + return false; + } + expect_key = true; + } + depth += 1; + if depth > 16 { + return false; + } + } + b'}' | b']' => { + let Some(next) = depth.checked_sub(1) else { + return false; + }; + depth = next; + } + b':' if depth == 1 => expect_key = false, + b',' if depth == 1 => expect_key = true, + _ => {} + } + } + !in_string && depth == 0 && seen == 127 +} + #[cfg(test)] #[cfg_attr(coverage_nightly, coverage(off))] mod tests; diff --git a/crates/event/src/wire/v1/tests.rs b/crates/event/src/wire/v1/tests.rs @@ -561,3 +561,125 @@ fn checked_in_conformance_vectors_match_wire_behavior() { } } } + +#[test] +fn exact_result_profile_accepts_escaped_keys_without_interpreting_string_delimiters() { + let value = valid_event_value("soil 🌱: { [ \" \\ \n", default_tags()); + let fields = value + .as_object() + .unwrap() + .iter() + .map(|(key, value)| { + let escaped = key + .chars() + .map(|c| format!("\\u{:04x}", c as u32)) + .collect::<String>(); + format!("\"{escaped}\" : {value}") + }) + .collect::<Vec<_>>() + .join(",\n"); + let raw = format!(" \n{{ {fields} }} \t"); + let parsed = + Nip01EventWire::parse_json_exact_with_limits(&raw, EventWireLimits::default()).unwrap(); + assert_eq!(parsed.content, value["content"].as_str().unwrap()); + assert_eq!(parsed.tags, default_tags()); + assert!(parsed.extra.is_empty()); + let limits = EventWireLimits { + max_raw_json_bytes: raw.len() - 1, + ..EventWireLimits::default() + }; + assert!(matches!( + Nip01EventWire::parse_json_exact_with_limits(&raw, limits), + Err(EventWireError::RawJsonTooLarge { .. }) + )); + let mut changed = value.clone(); + changed["content"] = json!("different preimage"); + assert!( + Nip01EventWire::parse_json_exact_with_limits( + &raw_json(&changed), + EventWireLimits::default() + ) + .is_err() + ); +} + +#[test] +fn exact_result_profile_refuses_all_duplicate_missing_and_unknown_root_fields() { + let value = valid_event_value("soil", default_tags()); + let raw = raw_json(&value); + for key in [ + "id", + "pubkey", + "created_at", + "kind", + "tags", + "content", + "sig", + ] { + for spelling in [ + key.to_owned(), + key.chars() + .map(|c| format!("\\u{:04x}", c as u32)) + .collect(), + ] { + let duplicate = format!("{{\"{spelling}\":{},{}", value[key], &raw[1..]); + assert!( + Nip01EventWire::parse_json_exact_with_limits( + &duplicate, + EventWireLimits::default() + ) + .is_err(), + "duplicate {key}" + ); + } + let mut missing = value.clone(); + missing.as_object_mut().unwrap().remove(key); + assert!( + Nip01EventWire::parse_json_exact_with_limits( + &raw_json(&missing), + EventWireLimits::default() + ) + .is_err(), + "missing {key}" + ); + } + for key in ["extra".to_owned(), "unknown".repeat(20)] { + let extra = format!("{{\"{key}\":0,{}", &raw[1..]); + assert!( + Nip01EventWire::parse_json_exact_with_limits(&extra, EventWireLimits::default()) + .is_err() + ); + } +} + +#[test] +fn exact_result_profile_refuses_malformed_roots_and_nesting_before_semantic_decoding() { + let raw = valid_event_json("soil", default_tags()); + for malformed in [ + String::new(), + "[]".into(), + "}".into(), + "[{}]".into(), + format!("{raw}{raw}"), + format!("{raw}]"), + format!("{{\"\\q\":0,{}", &raw[1..]), + "{\"id".into(), + format!( + "{{\"content\":{}0{},{}", + "[".repeat(17), + "]".repeat(17), + &raw[1..] + ), + ] { + assert!( + Nip01EventWire::parse_json_exact_with_limits(&malformed, EventWireLimits::default()) + .is_err() + ); + } + let mut typed = valid_event_value("soil", default_tags()); + typed["kind"] = json!({"nested": 1}); + assert!( + Nip01EventWire::parse_json_exact_with_limits(&raw_json(&typed), EventWireLimits::default()) + .is_err() + ); +} diff --git a/crates/execution/Cargo.toml b/crates/execution/Cargo.toml @@ -25,6 +25,8 @@ radroots_signing = { workspace = true, default-features = false, optional = true [dev-dependencies] futures = { workspace = true } +radroots_event = { workspace = true, default-features = false } +radroots_event_codec = { workspace = true, default-features = false } radroots_identity = { workspace = true, default-features = false } [lints] diff --git a/crates/execution/src/session/signer.rs b/crates/execution/src/session/signer.rs @@ -122,6 +122,40 @@ impl Clone for SignerSession { } impl SignerSession { + /// Issues only through an already observed, live exact-intent provider. + /// The executor must retain its own work permit through durable capture; + /// this scoped future owns resources but supplies no admission receipt. + pub async fn sign_exact( + &self, + intent: radroots_signing::issuance::SigningIntent, + ) -> radroots_signing::issuance::SigningOutcome { + use radroots_signing::issuance::SigningOutcome; + let binding = intent.binding(); + let Ok(_permit) = self.session.admit() else { + return SigningOutcome::not_dispatched(binding, ProviderError::CapabilityUnavailable); + }; + if self.identity_changed() { + return SigningOutcome::not_dispatched(binding, ProviderError::IdentityChanged); + } + let Some(observed) = self.observed() else { + return SigningOutcome::not_dispatched(binding, ProviderError::CapabilityUnavailable); + }; + if observed.identity() != intent.author() { + return SigningOutcome::not_dispatched(binding, ProviderError::IdentityChanged); + } + if observed.exact_issuance().is_none() { + return SigningOutcome::not_dispatched(binding, ProviderError::CapabilityUnavailable); + } + let Some(provider) = self.resources.retain_binding() else { + return SigningOutcome::not_dispatched(binding, ProviderError::CapabilityUnavailable); + }; + provider + .provider + .sign_exact(intent) + .await + .enforce_binding(binding) + } + /// Owns the handle without invoking it. Observations serialize through a /// single admitted resource permit; excess concurrent observations refuse. pub fn new(handle: SignerHandle) -> Self { diff --git a/crates/execution/tests/signer_session.rs b/crates/execution/tests/signer_session.rs @@ -48,6 +48,9 @@ fn state(second: bool, encrypt: bool) -> ProviderState { struct Control { current: Mutex<ProviderState>, calls: AtomicUsize, + sign_calls: AtomicUsize, + sign_response: Mutex<Option<oneshot::Receiver<radroots_signing::issuance::SigningOutcome>>>, + sign_binding: Mutex<Option<radroots_signing::issuance::IntentBinding>>, response: Mutex<Option<oneshot::Receiver<()>>>, quiesces: AtomicUsize, quiesced: AtomicBool, @@ -77,6 +80,30 @@ impl Signer for Provider { } impl ParticipantProvider for Provider { + fn sign_exact( + &self, + intent: radroots_signing::issuance::SigningIntent, + ) -> BoxFuture<'_, radroots_signing::issuance::SigningOutcome> { + use radroots_signing::issuance::SigningOutcome; + Box::pin(async move { + self.0.sign_calls.fetch_add(1, Ordering::SeqCst); + let binding = self + .0 + .sign_binding + .lock() + .unwrap() + .unwrap_or(intent.binding()); + let response = self.0.sign_response.lock().unwrap().take(); + if let Some(response) = response { + response.await.unwrap_or_else(|_| { + SigningOutcome::unknown(binding, ProviderError::ProviderFailure) + }) + } else { + SigningOutcome::unknown(binding, ProviderError::ProviderFailure) + } + }) + } + fn provider_state(&self) -> BoxFuture<'_, Result<ProviderState, ProviderError>> { Box::pin(async move { self.0.calls.fetch_add(1, Ordering::SeqCst); @@ -165,6 +192,9 @@ fn control() -> Shared<Control> { Shared::new(Control { current: Mutex::new(state(false, false)), calls: AtomicUsize::new(0), + sign_calls: AtomicUsize::new(0), + sign_response: Mutex::new(None), + sign_binding: Mutex::new(None), response: Mutex::new(None), quiesces: AtomicUsize::new(0), quiesced: AtomicBool::new(false), @@ -371,6 +401,12 @@ fn browser_scope_accepts_rc_local_provider_and_callbacks() { Shared::new(Callbacks(control)), )); assert_eq!(block_on(session.observe()).unwrap().identity(), key(false)); + assert!(matches!( + block_on(session.sign_exact(exact_intent(false, 1))).kind(), + radroots_signing::issuance::OutcomeKind::NotDispatched( + ProviderError::CapabilityUnavailable + ) + )); block_on(session.close()).unwrap(); assert_eq!(session.state(), SessionState::Closed); } @@ -418,3 +454,152 @@ fn browser_client_composes_local_host_and_retained_callback_scope() { block_on(client.close()).unwrap(); assert_eq!(observations.get(), 5); } + +fn exact_intent(second: bool, operation: u8) -> radroots_signing::issuance::SigningIntent { + use radroots_signing::issuance::{ArtifactRole, SigningIntent}; + let plan = radroots_event_codec::authoring::AuthoredEventPlan::from_generic( + radroots_event::GenericEventDraft::new( + "radroots.social.geochat.v1", + 20_000, + 1_700_000_000, + vec![], + "synthetic captured scope", + key(second).to_hex(), + ) + .unwrap(), + ) + .unwrap(); + SigningIntent::new( + radroots_domain::OperationId::from_bytes([operation; 32]), + [9; 32], + plan, + ArtifactRole::PublicEvent, + None, + ProviderCall::new( + key(second), + core::num::NonZeroU64::new(1_700_000_010_000).unwrap(), + radroots_signing::request::CancellationSignal::new(), + ), + ) + .unwrap() +} + +#[cfg(not(target_arch = "wasm32"))] +#[test] +fn exact_issuance_requires_successful_observation_actual_support_and_the_frozen_key() { + use radroots_signing::issuance::OutcomeKind; + let Fixture { + session, control, .. + } = scope(); + assert!(matches!( + block_on(session.sign_exact(exact_intent(false, 1))).kind(), + OutcomeKind::NotDispatched(ProviderError::CapabilityUnavailable) + )); + block_on(session.observe()).unwrap(); + assert!(matches!( + block_on(session.sign_exact(exact_intent(false, 1))).kind(), + OutcomeKind::NotDispatched(ProviderError::CapabilityUnavailable) + )); + assert_eq!(control.sign_calls.load(Ordering::SeqCst), 0); + *control.current.lock().unwrap() = + state(false, false).with_exact_issuance(Some(ReplayCapability::NonReplayable)); + block_on(session.observe()).unwrap(); + assert!(matches!( + block_on(session.sign_exact(exact_intent(true, 1))).kind(), + OutcomeKind::NotDispatched(ProviderError::IdentityChanged) + )); + assert!(!session.identity_changed()); + assert!(matches!( + block_on(session.sign_exact(exact_intent(false, 1))).kind(), + OutcomeKind::Unknown(_) + )); + assert_eq!(control.sign_calls.load(Ordering::SeqCst), 1); + *control.current.lock().unwrap() = + state(true, false).with_exact_issuance(Some(ReplayCapability::NonReplayable)); + assert_eq!( + block_on(session.observe()), + Err(ProviderError::IdentityChanged) + ); + assert!(matches!( + block_on(session.sign_exact(exact_intent(false, 1))).kind(), + OutcomeKind::NotDispatched(ProviderError::IdentityChanged) + )); + assert_eq!(control.sign_calls.load(Ordering::SeqCst), 1); + block_on(session.close()).unwrap(); + + let Fixture { + session, control, .. + } = scope(); + let (send, receive) = oneshot::channel(); + drop(send); + *control.response.lock().unwrap() = Some(receive); + assert!(block_on(session.observe()).is_err()); + assert!(matches!( + block_on(session.sign_exact(exact_intent(false, 1))).kind(), + OutcomeKind::NotDispatched(ProviderError::CapabilityUnavailable) + )); + assert_eq!(control.sign_calls.load(Ordering::SeqCst), 0); + block_on(session.close()).unwrap(); +} + +#[cfg(not(target_arch = "wasm32"))] +#[test] +fn pending_exact_issuance_retains_callbacks_until_its_bound_outcome_is_observed() { + use radroots_signing::issuance::{OutcomeKind, SigningOutcome}; + let Fixture { + session, + control, + provider, + callbacks, + } = scope(); + *control.current.lock().unwrap() = + state(false, false).with_exact_issuance(Some(ReplayCapability::NonReplayable)); + block_on(session.observe()).unwrap(); + let input = exact_intent(false, 1); + let binding = input.binding(); + let (send, receive) = oneshot::channel(); + *control.sign_response.lock().unwrap() = Some(receive); + let mut issue = Box::pin(session.sign_exact(input)); + let mut cx = Context::from_waker(noop_waker_ref()); + assert!(issue.as_mut().poll(&mut cx).is_pending()); + let mut close = Box::pin(session.close()); + assert!(close.as_mut().poll(&mut cx).is_pending()); + assert_eq!(session.state(), SessionState::Closing); + assert_eq!(control.close_attempts.load(Ordering::SeqCst), 0); + assert!(provider.upgrade().is_some() && callbacks.upgrade().is_some()); + send.send(SigningOutcome::unknown( + binding, + ProviderError::ProviderFailure, + )) + .unwrap(); + let Poll::Ready(outcome) = issue.as_mut().poll(&mut cx) else { + panic!("outcome not received"); + }; + assert_eq!(outcome.binding(), binding); + assert!(matches!(outcome.kind(), OutcomeKind::Unknown(_))); + assert!(matches!(close.as_mut().poll(&mut cx), Poll::Ready(Ok(())))); + assert!(provider.upgrade().is_none() && callbacks.upgrade().is_none()); +} + +#[cfg(not(target_arch = "wasm32"))] +#[test] +fn exact_callback_binding_cannot_claim_another_operations_result() { + use radroots_signing::issuance::{OutcomeKind, RejectionReason}; + let Fixture { + session, control, .. + } = scope(); + *control.current.lock().unwrap() = + state(false, false).with_exact_issuance(Some(ReplayCapability::NonReplayable)); + block_on(session.observe()).unwrap(); + *control.sign_binding.lock().unwrap() = Some(exact_intent(false, 2).binding()); + let input = exact_intent(false, 1); + let expected = input.binding(); + let outcome = block_on(session.sign_exact(input)); + assert_eq!(outcome.binding(), expected); + let OutcomeKind::Rejected(rejected) = outcome.kind() else { + panic!("wrong binding promoted"); + }; + assert_eq!(rejected.reason(), RejectionReason::BindingMismatch); + assert!(rejected.fingerprint().is_none()); + block_on(session.close()).unwrap(); +} diff --git a/crates/nostr/src/signing.rs b/crates/nostr/src/signing.rs @@ -21,6 +21,7 @@ use radroots_signing::{ use crate::{Error as NostrError, key::SecretKey}; +mod issuance; mod private; pub use private::OsNonceSource; diff --git a/crates/nostr/src/signing/issuance.rs b/crates/nostr/src/signing/issuance.rs @@ -0,0 +1,220 @@ +use core::num::NonZeroU64; +use nostr::JsonUtil; +use radroots_signing::{ + issuance::{SigningIntent, SigningOutcome}, + provider::ProviderError, + signer::BoxFuture, +}; + +use super::LocalSigner; + +impl LocalSigner { + pub(super) fn issue_exact(&self, intent: SigningIntent) -> BoxFuture<'_, SigningOutcome> { + Box::pin(async move { + let binding = intent.binding(); + if intent.author() != self.public_key { + return SigningOutcome::not_dispatched(binding, ProviderError::IdentityChanged); + } + // Conversion/representation errors occur before cryptography. + let unsigned = match intent.with_plan(crate::plan_signing::unsigned_event_from_plan) { + Ok(unsigned) => unsigned, + Err(_) => { + return SigningOutcome::not_dispatched(binding, ProviderError::InvalidInput); + } + }; + let now = match (self.clock)() { + Ok(now) => now, + Err(_) => { + return SigningOutcome::not_dispatched(binding, ProviderError::ProviderFailure); + } + }; + if let Err(reason) = intent.check_before_effect(self.public_key, now) { + return SigningOutcome::not_dispatched(binding, reason); + } + // After invoking cryptography, an error is uncertain. Never claim + // proven non-issuance or fall through to a new captured preimage. + let event = match unsigned.sign_with_keys(&self.keys) { + Ok(event) => event, + Err(_) => return SigningOutcome::unknown(binding, ProviderError::ProviderFailure), + }; + let observed = (self.clock)().ok().and_then(NonZeroU64::new); + // No deadline/cancellation check or fallible clock can discard the + // obtained event. Capture verifies its exact fields and signature. + SigningOutcome::capture(&intent, event.as_json(), observed) + }) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::key::parse_secret_key; + use radroots_event::GenericEventDraft; + use radroots_event_codec::authoring::AuthoredEventPlan; + use radroots_signing::{ + Error as SigningError, + error::Kind, + issuance::{ArtifactRole, OutcomeKind}, + provider::{ParticipantProvider, ProviderCall}, + recovery::ReplayCapability, + request::CancellationSignal, + }; + use std::cell::RefCell; + const AUTHOR: &str = "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"; + const CREATED: u64 = 1_700_000_000; + const DEADLINE: u64 = CREATED * 1000 + 10_000; + #[derive(Default)] + struct ClockState { + calls: usize, + mode: u8, + cancellation: Option<CancellationSignal>, + } + thread_local! { static CLOCK: RefCell<ClockState> = RefCell::default(); } + fn clock() -> Result<u64, SigningError> { + CLOCK.with(|state| { + let mut state = state.borrow_mut(); + state.calls += 1; + match (state.mode, state.calls) { + (1, 2) | (3, 1) => Err(SigningError::new(Kind::InternalError)), + (2, 2) => Ok(DEADLINE + 1), + (4, 1) | (7, 2) => Ok(0), + (5, 1) => Ok(DEADLINE), + (6, 2) => { + state.cancellation.as_ref().unwrap().cancel(); + Ok(CREATED * 1000 + 2) + } + _ => Ok(CREATED * 1000 + 1), + } + }) + } + fn setup(mode: u8) -> (LocalSigner, SigningIntent) { + // Published synthetic interoperability identity, never custody material. + let signer = LocalSigner::with_clock( + parse_secret_key("0000000000000000000000000000000000000000000000000000000000000001") + .unwrap(), + clock, + ) + .unwrap(); + let cancellation = CancellationSignal::new(); + CLOCK.with(|state| { + *state.borrow_mut() = ClockState { + calls: 0, + mode, + cancellation: Some(cancellation.clone()), + } + }); + let plan = AuthoredEventPlan::from_generic( + GenericEventDraft::new( + "radroots.social.geochat.v1", + 20_000, + CREATED, + vec![], + "synthetic unchanged exact preimage", + AUTHOR, + ) + .unwrap(), + ) + .unwrap(); + let intent = SigningIntent::new( + "ab".repeat(32).parse().unwrap(), + [9; 32], + plan, + ArtifactRole::PublicEvent, + None, + ProviderCall::new( + signer.public_key(), + NonZeroU64::new(DEADLINE).unwrap(), + cancellation, + ), + ) + .unwrap(); + (signer, intent) + } + #[tokio::test] + async fn exact_native_signatures_survive_missing_late_and_cancelled_completion_observation() { + for mode in [0, 1, 2, 6, 7] { + let (signer, intent) = setup(mode); + let expected = intent.binding(); + let length = intent.signed_json_bytes(); + let state = signer.provider_state().await.unwrap(); + assert_eq!( + state.exact_issuance(), + Some(ReplayCapability::NonReplayable) + ); + let outcome = signer.sign_exact(intent).await; + assert_eq!(outcome.binding(), expected); + let OutcomeKind::Obtained(artifact) = outcome.kind() else { + panic!("obtained native signature lost: {outcome:?}"); + }; + artifact.with_json(|raw| { + assert_eq!(raw.len(), length); + let event = nostr::Event::from_json(raw).unwrap(); + event.verify().unwrap(); + assert_eq!(event.pubkey.to_hex(), AUTHOR); + assert_eq!(event.content, "synthetic unchanged exact preimage"); + }); + assert_eq!( + artifact.observed_at_unix_ms().is_none(), + matches!(mode, 1 | 7) + ); + if mode == 2 { + assert!(artifact.observed_at_unix_ms().unwrap().get() > DEADLINE); + } + CLOCK.with(|state| assert_eq!(state.borrow().calls, 2)); + } + } + #[tokio::test] + async fn failed_zero_and_expired_admission_clocks_do_not_dispatch_a_signature() { + for mode in [3, 4, 5] { + let (signer, intent) = setup(mode); + let outcome = signer.sign_exact(intent).await; + assert!(matches!( + outcome.kind(), + OutcomeKind::NotDispatched( + ProviderError::ProviderFailure | ProviderError::DeadlineExceeded + ) + )); + CLOCK.with(|state| assert_eq!(state.borrow().calls, 1)); + } + } + #[tokio::test] + async fn wrong_actual_key_and_preexisting_cancellation_refuse_before_crypto() { + let (_, intent) = setup(3); + let other = LocalSigner::with_clock( + parse_secret_key("0000000000000000000000000000000000000000000000000000000000000002") + .unwrap(), + clock, + ) + .unwrap(); + // An untrusted caller cannot even construct a different captured key. + assert!(matches!( + SigningIntent::new( + intent.binding().operation_id(), + [9; 32], + intent.with_plan(Clone::clone), + ArtifactRole::PublicEvent, + None, + ProviderCall::new( + other.public_key(), + NonZeroU64::new(DEADLINE).unwrap(), + CancellationSignal::new() + ), + ), + Err(ProviderError::InvalidInput) + )); + let outcome = other.sign_exact(intent).await; + assert!(matches!( + outcome.kind(), + OutcomeKind::NotDispatched(ProviderError::IdentityChanged) + )); + CLOCK.with(|state| assert_eq!(state.borrow().calls, 0)); + let (signer, intent) = setup(0); + CLOCK.with(|state| state.borrow().cancellation.as_ref().unwrap().cancel()); + let outcome = signer.sign_exact(intent).await; + assert!(matches!( + outcome.kind(), + OutcomeKind::NotDispatched(ProviderError::Cancelled) + )); + CLOCK.with(|state| assert_eq!(state.borrow().calls, 1)); + } +} diff --git a/crates/nostr/src/signing/private.rs b/crates/nostr/src/signing/private.rs @@ -52,10 +52,20 @@ impl ParticipantProvider for LocalSigner { encryption, decryption, radroots_signing::recovery::ReplayCapability::LocalReplaySafe, - )) + ) + .with_exact_issuance(Some( + radroots_signing::recovery::ReplayCapability::NonReplayable, + ))) }) } + fn sign_exact( + &self, + intent: radroots_signing::issuance::SigningIntent, + ) -> BoxFuture<'_, radroots_signing::issuance::SigningOutcome> { + self.issue_exact(intent) + } + fn encrypt_private( &self, call: ProviderCall, diff --git a/crates/radroots/Cargo.toml b/crates/radroots/Cargo.toml @@ -62,6 +62,7 @@ full = ["native", "radroots_sdk/full"] [dev-dependencies] futures = { workspace = true } +radroots_event_codec = { workspace = true, default-features = false } radroots_nostr = { workspace = true, features = ["signing"] } serde_json = { workspace = true, features = ["std"] } tempfile = { workspace = true } diff --git a/crates/radroots/src/signing.rs b/crates/radroots/src/signing.rs @@ -3,6 +3,9 @@ pub use radroots_sdk::signing::{ BlossomAuthorizationPlan, Mode, Operations, Provider, blossom_upload_request, }; +pub use radroots_signing::issuance::{ + ArtifactRole, IntentBinding, OutcomeKind, SignedArtifact, SigningIntent, SigningOutcome, +}; #[cfg(any(feature = "blossom", feature = "nostr", feature = "full"))] pub use radroots_sdk::signing::{AuthorizationHeader, BlossomSigningError}; diff --git a/crates/radroots/tests/native_client.rs b/crates/radroots/tests/native_client.rs @@ -183,3 +183,75 @@ async fn cancelled_client_close_retains_actual_provider_and_writer_until_callbac let reopened = SqliteStorage::open(options).await.unwrap(); reopened.close().await.unwrap(); } + +#[tokio::test] +async fn ordinary_native_signer_scope_returns_real_full_identity_signature_facts() { + use radroots::signing::{ArtifactRole, OutcomeKind, SigningIntent}; + use radroots_event_codec::authoring::AuthoredEventPlan; + use radroots_signing::{provider::ProviderCall, request::CancellationSignal}; + fn checked_clock() -> Result<u64, radroots_signing::Error> { + Ok(1_700_000_000_001) + } + let root = tempfile::tempdir().unwrap(); + let options = options(root.path()); + let client = Client::open(NativeConfig::public_read(options.clone())) + .await + .unwrap(); + let provider = Arc::new( + LocalSigner::with_clock( + parse_secret_key("0000000000000000000000000000000000000000000000000000000000000001") + .unwrap(), + checked_clock, + ) + .unwrap(), + ); + let author = provider.public_key(); + let weak = Arc::downgrade(&provider); + let callbacks = callbacks(options, true); + let scope = client + .attach_signer(SignerHandle::new(provider, callbacks)) + .await + .unwrap(); + let plan = AuthoredEventPlan::from_generic( + radroots::event::GenericEventDraft::new( + "radroots.social.geochat.v1", + 20_000, + 1_700_000_000, + vec![], + "synthetic native retained preimage", + author.to_hex(), + ) + .unwrap(), + ) + .unwrap(); + let operation = radroots::OperationId::from_bytes([31; 32]); + let intent = SigningIntent::new( + operation, + [32; 32], + plan, + ArtifactRole::PublicEvent, + None, + ProviderCall::new( + author, + std::num::NonZeroU64::new(1_700_000_010_000).unwrap(), + CancellationSignal::new(), + ), + ) + .unwrap(); + let outcome = scope.sign_exact(intent).await; + assert_eq!(outcome.binding().operation_id(), operation); + let OutcomeKind::Obtained(artifact) = outcome.kind() else { + panic!("native signature unavailable: {outcome:?}"); + }; + artifact.with_json(|raw| { + let value = radroots_event::wire::Nip01EventWire::parse_json(raw).unwrap(); + assert_eq!(value.pubkey, author.to_hex()); + assert_eq!(value.content, "synthetic native retained preimage"); + }); + assert!(artifact.observed_at_unix_ms().is_some()); + client.close().await.unwrap(); + assert!(weak.upgrade().is_none()); + // Owning authenticated bytes outlive released key/callback roots. This + // primitive fact alone does not claim a durable command or publication. + artifact.with_json(|raw| assert!(!raw.is_empty())); +} diff --git a/crates/signing/Cargo.toml b/crates/signing/Cargo.toml @@ -33,6 +33,7 @@ name = "radroots_signing" [features] default = ["std", "serde"] std = [ + "radroots_domain/std", "radroots_event/std", "radroots_event_codec/std", "radroots_identity/std", @@ -47,6 +48,7 @@ serde = [ ] [dependencies] +radroots_domain = { workspace = true, default-features = false } radroots_event = { workspace = true, default-features = false } radroots_event_codec = { workspace = true, default-features = false } radroots_identity = { workspace = true, default-features = false } diff --git a/crates/signing/README.md b/crates/signing/README.md @@ -228,3 +228,30 @@ core, and `serde` is supported independently of `std`. Applications that only need ordinary Radroots operations should normally use `radroots` or `radroots_sdk`; implement this package directly when providing a new signer adapter or advanced host composition. + +## Exact issuance and obtained results + +`issuance::SigningIntent` binds the canonical 256-bit domain operation ID, +command digest, exact authored preimage, role/recipient and captured deadline. +Its generic complete-event limit is 64 KiB, including escaped content, tags, +keys and signature. Executor chat/record/rumor limits remain tighter. Values and +bindings are neither authenticated command contexts nor durable admission. + +`ParticipantProvider::sign_exact` has no fallback to the legacy signer method. +An unsupported provider reports unavailable. `ProviderState::exact_issuance` +is observed separately from legacy replay metadata. The concrete local adapter +reports non-replayable exact issuance; no durable retrieval or safe uncertain +reissue is inferred from custody of the key or a stable event ID. + +`SigningOutcome` binds every classification to the original intent. Obtained +bytes are verified against every signed field and signature, own their original +representation, and carry optional observation time. A failed, expired or +cancelled completion observation cannot discard valid bytes. Rejected output +has fixed forensic metadata; prefix digests report their actual coverage. No +classification claims that T0/T1/S/T2/D ran, and rejection is not proof that +issuance never happened. The executor owns polling and durable capture through +its safe journal boundary; dropping an observer cannot erase that responsibility. + +The legacy request/evidence API retains its existing callers while the +successor workers and providers migrate. Its sixteen-byte identities and +mandatory observation clock do not qualify the new execution contract. diff --git a/crates/signing/src/issuance.rs b/crates/signing/src/issuance.rs @@ -0,0 +1,471 @@ +//! Exact-intent signature facts with nullable observation and no durable claim. + +use crate::provider::{ProviderCall, ProviderError}; +#[cfg(not(feature = "std"))] +use alloc::string::String; +use core::{fmt, num::NonZeroU64}; +use radroots_domain::OperationId; +use radroots_event::{ + SignedEvent, + id::EventId, + wire::{EventWireLimits, Nip01EventWire}, +}; +use radroots_event_codec::{ + authoring::AuthoredEventPlan, + verify::{self, Nip01SignatureVerifier, RawEvent}, +}; +use radroots_identity::PublicKey; +use sha2::{Digest, Sha256}; +#[cfg(feature = "std")] +use std::string::String; +use zeroize::Zeroizing; + +/// Maximum complete serialized event, including keys, tags and signature. +pub const SIGNED_EVENT_MAX_BYTES: usize = 65_536; +/// Maximum supported authored timestamp in seconds (year 9999). +pub const MAX_EVENT_UNIX_SECONDS: u64 = 253_402_300_799; +const MAX_OBSERVATION_UNIX_MS: u64 = MAX_EVENT_UNIX_SECONDS * 1000 + 999; +const INTENT_DOMAIN: &[u8] = b"radroots.exact_signing_intent.v1\0"; + +/// Transport artifact role, separate from a participant's command permission. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[non_exhaustive] +pub enum ArtifactRole { + /// A public authored event, without private-carrier or rumor kinds. + PublicEvent, + /// An encrypted NIP-59 seal (kind 13) for one exact recipient. + BusinessSeal, + /// An outer NIP-59 gift wrap (kind 1059) for one exact recipient. + GiftWrap, +} + +/// Fixed provenance of one captured signing intent. This value grants nothing. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct IntentBinding { + operation_id: OperationId, + command_digest: [u8; 32], + digest: [u8; 32], +} +impl IntentBinding { + /// Returns the full canonical operation identity, never a truncated alias. + pub const fn operation_id(self) -> OperationId { + self.operation_id + } + /// Returns the captured command digest. + pub const fn command_digest(&self) -> &[u8; 32] { + &self.command_digest + } + /// Returns the domain-separated exact intent commitment. + pub const fn digest(&self) -> &[u8; 32] { + &self.digest + } +} + +/// Bounded exact preimage and immutable provenance. It is neither an +/// authenticated command context nor evidence of T0/T1 admission. +/// It has no automatic input-bearing diagnostics or serialization. +pub struct SigningIntent { + binding: IntentBinding, + plan: AuthoredEventPlan, + role: ArtifactRole, + recipient: Option<PublicKey>, + call: ProviderCall, + signed_json_bytes: usize, +} +impl fmt::Debug for SigningIntent { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("SigningIntent(<redacted>)") + } +} +impl SigningIntent { + /// Freezes an already validated authored preimage and its captured context. + /// Complete-event and parser budgets are checked without serializing or + /// cloning the plan. A tighter business profile remains executor-owned. + pub fn new( + operation_id: OperationId, + command_digest: [u8; 32], + plan: AuthoredEventPlan, + role: ArtifactRole, + recipient: Option<PublicKey>, + call: ProviderCall, + ) -> Result<Self, ProviderError> { + if plan.author() != &call.identity() + || plan.created_at() > MAX_EVENT_UNIX_SECONDS + || call.deadline_unix_ms().get() > MAX_OBSERVATION_UNIX_MS + { + return Err(ProviderError::InvalidInput); + } + let kind = plan.body().kind(); + let role_valid = match role { + ArtifactRole::PublicEvent => recipient.is_none() && !matches!(kind, 13 | 14 | 1059), + ArtifactRole::BusinessSeal => { + kind == 13 && recipient.is_some() && plan.body().tags().is_empty() + } + ArtifactRole::GiftWrap => { + kind == 1059 + && recipient.is_some_and(|peer| { + let tags = plan.body().tags(); + let mut recipients = tags + .iter() + .filter(|tag| tag.first().is_some_and(|field| field == "p")); + recipients + .next() + .is_some_and(|tag| tag.len() == 2 && tag[1] == peer.to_hex()) + && recipients.next().is_none() + }) + } + }; + if !role_valid { + return Err(ProviderError::InvalidInput); + } + let signed_json_bytes = signed_json_len(&plan)?; + let mut digest = Sha256::new(); + digest.update(INTENT_DOMAIN); + digest.update(operation_id.as_bytes()); + digest.update(command_digest); + digest.update(plan.digest().as_bytes()); + digest.update([match role { + ArtifactRole::PublicEvent => 0, + ArtifactRole::BusinessSeal => 1, + ArtifactRole::GiftWrap => 2, + }]); + match recipient { + Some(peer) => { + digest.update([1]); + digest.update(peer.as_bytes()); + } + None => digest.update([0]), + } + digest.update(call.deadline_unix_ms().get().to_be_bytes()); + let binding = IntentBinding { + operation_id, + command_digest, + digest: digest.finalize().into(), + }; + Ok(Self { + binding, + plan, + role, + recipient, + call, + signed_json_bytes, + }) + } + /// Returns the original immutable binding. + pub const fn binding(&self) -> IntentBinding { + self.binding + } + /// Returns the exact authored-event byte count under the supported serializer. + pub const fn signed_json_bytes(&self) -> usize { + self.signed_json_bytes + } + /// Returns the expected author, independently of any business actor claim. + pub const fn author(&self) -> PublicKey { + *self.plan.author() + } + /// Returns the exact artifact role. + pub const fn role(&self) -> ArtifactRole { + self.role + } + /// Returns the exact recipient for a private carrier. + pub const fn recipient(&self) -> Option<PublicKey> { + self.recipient + } + /// Exposes the bounded preimage only within an explicit host conversion. + pub fn with_plan<T>(&self, use_plan: impl FnOnce(&AuthoredEventPlan) -> T) -> T { + use_plan(&self.plan) + } + /// Checks scheduling before effects. Never repeat this after obtaining bytes. + pub fn check_before_effect( + &self, + identity: PublicKey, + now_unix_ms: u64, + ) -> Result<(), ProviderError> { + self.call.check_before_effect(identity, now_unix_ms) + } +} + +struct Size(usize); +impl Size { + fn add(&mut self, n: usize) -> Result<(), ProviderError> { + self.0 = self + .0 + .checked_add(n) + .filter(|n| *n <= SIGNED_EVENT_MAX_BYTES) + .ok_or(ProviderError::LimitExceeded)?; + Ok(()) + } + fn string(&mut self, value: &str) -> Result<(), ProviderError> { + self.add(2)?; + if value.len() > SIGNED_EVENT_MAX_BYTES { + return Err(ProviderError::LimitExceeded); + } + for byte in value.bytes() { + self.add(match byte { + b'"' | b'\\' | b'\n' | b'\r' | b'\t' | 8 | 12 => 2, + 0..=31 => 6, + _ => 1, + })?; + } + Ok(()) + } +} +fn signed_json_len(plan: &AuthoredEventPlan) -> Result<usize, ProviderError> { + if plan.body().kind() > u32::from(u16::MAX) { + return Err(ProviderError::UnsupportedVersion); + } + let limits = EventWireLimits::default(); + let mut elements = 0usize; + let mut tag_bytes = 0usize; + if plan.body().tags().len() > limits.max_tag_count { + return Err(ProviderError::LimitExceeded); + } + let mut size = Size(0); + size.add(b"{\"id\":".len() + 66 + b",\"pubkey\":".len() + 66 + b",\"created_at\":".len())?; + size.add(plan.created_at().checked_ilog10().unwrap_or(0) as usize + 1)?; + size.add( + b",\"kind\":".len() + + plan.body().kind().checked_ilog10().unwrap_or(0) as usize + + 1 + + b",\"tags\":".len() + + 2, + )?; + for (index, tag) in plan.body().tags().iter().enumerate() { + if index != 0 { + size.add(1)?; + } + size.add(2)?; + elements = elements + .checked_add(tag.len()) + .filter(|n| *n <= limits.max_total_tag_elements) + .ok_or(ProviderError::LimitExceeded)?; + for (index, field) in tag.iter().enumerate() { + if field.len() > limits.max_tag_element_bytes { + return Err(ProviderError::LimitExceeded); + } + tag_bytes = tag_bytes + .checked_add(field.len()) + .filter(|n| *n <= limits.max_total_tag_bytes) + .ok_or(ProviderError::LimitExceeded)?; + if index != 0 { + size.add(1)?; + } + size.string(field)?; + } + } + size.add(b",\"content\":".len())?; + size.string(plan.body().content())?; + size.add(b",\"sig\":".len() + 130 + 1)?; + Ok(size.0) +} + +/// Scope of a forensic digest. A prefix digest never claims full coverage. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct ArtifactFingerprint { + sha256: [u8; 32], + covered_bytes: usize, + total_bytes: usize, +} +impl ArtifactFingerprint { + fn of(raw: &[u8]) -> Self { + let covered_bytes = raw.len().min(SIGNED_EVENT_MAX_BYTES); + Self { + sha256: Sha256::digest(&raw[..covered_bytes]).into(), + covered_bytes, + total_bytes: raw.len(), + } + } + /// Returns the SHA-256 of exactly the reported covered prefix. + pub const fn sha256(&self) -> &[u8; 32] { + &self.sha256 + } + /// Returns the number of bytes included in the digest. + pub const fn covered_bytes(self) -> usize { + self.covered_bytes + } + /// Returns the original response size, without retaining its payload. + pub const fn total_bytes(self) -> usize { + self.total_bytes + } +} +/// A fixed classification of untrusted signer output. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[non_exhaustive] +pub enum RejectionReason { + /// The response exceeds the complete-event budget. + TooLarge, + /// Structural decoding, exact fields or the supported profile do not match. + InvalidArtifact, + /// Cryptographic verification failed. + InvalidSignature, + /// The returned provenance belongs to another captured intent. + BindingMismatch, +} +/// Input-free forensic metadata. This supplies no authenticated business fact. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct RejectedArtifact { + reason: RejectionReason, + fingerprint: Option<ArtifactFingerprint>, +} +impl RejectedArtifact { + /// Returns the fixed classification. + pub const fn reason(self) -> RejectionReason { + self.reason + } + /// Returns exact digest scope when response bytes were available. + pub const fn fingerprint(self) -> Option<ArtifactFingerprint> { + self.fingerprint + } +} +/// Authenticated exact bytes, without a durable-admission or business claim. +/// No automatic serialization, cloning or payload-bearing diagnostics exists. +pub struct SignedArtifact { + raw_json: Zeroizing<String>, + event_id: EventId, + observed_at_unix_ms: Option<NonZeroU64>, +} +impl fmt::Debug for SignedArtifact { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("SignedArtifact(<redacted>)") + } +} +impl SignedArtifact { + /// Returns the exact authenticated event identity. + pub const fn event_id(&self) -> EventId { + self.event_id + } + /// Returns a checked positive observation, or explicit unknown time. + pub const fn observed_at_unix_ms(&self) -> Option<NonZeroU64> { + self.observed_at_unix_ms + } + /// Exposes original bytes only for explicit capture/transport work. + pub fn with_json<T>(&self, use_json: impl FnOnce(&str) -> T) -> T { + use_json(&self.raw_json) + } +} +/// What a qualified provider reports, separately from durable capture. +#[derive(Debug)] +#[non_exhaustive] +pub enum OutcomeKind { + /// This provider proves its invocation did not dispatch signing. + NotDispatched(ProviderError), + /// Exact authenticated bytes were obtained; scheduling may have stopped. + Obtained(SignedArtifact), + /// No conclusive issuance result is available; retain uncertainty. + Unknown(ProviderError), + /// Untrusted output is not a business success or proof of no issuance. + Rejected(RejectedArtifact), +} +/// One result bound to the original captured intent. It is not an operation receipt. +#[derive(Debug)] +pub struct SigningOutcome { + binding: IntentBinding, + kind: OutcomeKind, +} +impl SigningOutcome { + /// Reports a qualified pre-dispatch refusal, without effects or legacy fallback. + pub const fn not_dispatched(binding: IntentBinding, reason: ProviderError) -> Self { + Self { + binding, + kind: OutcomeKind::NotDispatched(reason), + } + } + /// Reports uncertainty, which never permits blind reissue or hold release. + pub const fn unknown(binding: IntentBinding, reason: ProviderError) -> Self { + Self { + binding, + kind: OutcomeKind::Unknown(reason), + } + } + /// Verifies an obtained response without consulting scheduling or clocks. + /// Malformed output retains only bounded forensic metadata. Valid bytes are + /// preserved even with unavailable, expired or cancelled observation state. + pub fn capture( + intent: &SigningIntent, + raw_json: String, + observed_at_unix_ms: Option<NonZeroU64>, + ) -> Self { + let raw = Zeroizing::new(raw_json); + let fingerprint = ArtifactFingerprint::of(raw.as_bytes()); + let reject = |reason| Self { + binding: intent.binding(), + kind: OutcomeKind::Rejected(RejectedArtifact { + reason, + fingerprint: Some(fingerprint), + }), + }; + if raw.len() > SIGNED_EVENT_MAX_BYTES { + return reject(RejectionReason::TooLarge); + } + let limits = EventWireLimits { + max_raw_json_bytes: SIGNED_EVENT_MAX_BYTES, + max_extra_fields: 0, + max_total_extra_json_bytes: 0, + ..EventWireLimits::default() + }; + let Ok(wire) = Nip01EventWire::parse_json_exact_with_limits(&raw, limits) else { + return reject(RejectionReason::InvalidArtifact); + }; + let plan = &intent.plan; + if wire.pubkey != plan.author().to_hex() + || wire.created_at != plan.created_at() + || wire.kind != plan.body().kind() + || wire.tags != plan.body().tags() + || wire.content != plan.body().content() + || wire.id != plan.expected_event_id().to_hex() + { + return reject(RejectionReason::InvalidArtifact); + } + let Ok(event) = SignedEvent::from_wire_verified_id(wire, raw.as_str()) else { + return reject(RejectionReason::InvalidArtifact); + }; + let Ok(verified_id) = verify::id(RawEvent::new(event.envelope().clone())) else { + return reject(RejectionReason::InvalidArtifact); + }; + if verify::signature(verified_id, &Nip01SignatureVerifier).is_err() { + return reject(RejectionReason::InvalidSignature); + } + Self { + binding: intent.binding(), + kind: OutcomeKind::Obtained(SignedArtifact { + raw_json: raw, + event_id: *plan.expected_event_id(), + observed_at_unix_ms: observed_at_unix_ms + .filter(|at| at.get() <= MAX_OBSERVATION_UNIX_MS), + }), + } + } + /// Returns the exact captured provenance. + pub const fn binding(&self) -> IntentBinding { + self.binding + } + /// Borrows the classified result without cloning private bytes. + pub const fn kind(&self) -> &OutcomeKind { + &self.kind + } + /// Transfers the original binding and classified owned result. + pub fn into_parts(self) -> (IntentBinding, OutcomeKind) { + (self.binding, self.kind) + } + /// Refuses cross-intent callback results without promoting them to success + /// or proof of no issuance. Any available bytes retain scoped forensics. + pub fn enforce_binding(self, expected: IntentBinding) -> Self { + if self.binding == expected { + return self; + } + let fingerprint = match &self.kind { + OutcomeKind::Obtained(artifact) => { + Some(artifact.with_json(|raw| ArtifactFingerprint::of(raw.as_bytes()))) + } + OutcomeKind::Rejected(rejected) => rejected.fingerprint, + _ => None, + }; + Self { + binding: expected, + kind: OutcomeKind::Rejected(RejectedArtifact { + reason: RejectionReason::BindingMismatch, + fingerprint, + }), + } + } +} diff --git a/crates/signing/src/lib.rs b/crates/signing/src/lib.rs @@ -11,6 +11,7 @@ pub mod capability; pub mod error; pub mod host; pub mod identity; +pub mod issuance; pub mod provider; pub mod receipt; pub mod recovery; diff --git a/crates/signing/src/provider.rs b/crates/signing/src/provider.rs @@ -6,7 +6,7 @@ //! record/rumor/event budgets. Obtained results remain owned by that executor. #[cfg(not(feature = "std"))] -use alloc::string::String; +use alloc::{boxed::Box, string::String}; use core::{fmt, num::NonZeroU64}; use radroots_identity::PublicKey; #[cfg(feature = "std")] @@ -164,6 +164,7 @@ pub struct ProviderState { encryption: PrivateCryptoCapability, decryption: PrivateCryptoCapability, signing_replay: crate::recovery::ReplayCapability, + exact_issuance: Option<crate::recovery::ReplayCapability>, } impl ProviderState { /// Reports capabilities actually implemented by the observing provider. @@ -178,6 +179,7 @@ impl ProviderState { encryption, decryption, signing_replay, + exact_issuance: None, } } /// Returns the observed participant key, independently of any hosted principal. @@ -197,6 +199,22 @@ impl ProviderState { pub const fn signing_replay(self) -> crate::recovery::ReplayCapability { self.signing_replay } + + /// Reports support for the exact-intent issuance contract separately from + /// the retained legacy signing API. Absence means unavailable. + pub const fn exact_issuance(self) -> Option<crate::recovery::ReplayCapability> { + self.exact_issuance + } + + /// Records the actual provider's qualified exact-intent support. This + /// observation alone never authorizes replay or business execution. + pub const fn with_exact_issuance( + mut self, + replay: Option<crate::recovery::ReplayCapability>, + ) -> Self { + self.exact_issuance = replay; + self + } } /// Explicit per-call identity, deadline and cooperative cancellation binding. @@ -224,6 +242,11 @@ impl ProviderCall { pub const fn identity(&self) -> PublicKey { self.identity } + + /// Returns the captured first-issue deadline without consulting a clock. + pub const fn deadline_unix_ms(&self) -> NonZeroU64 { + self.deadline_unix_ms + } /// Validates admission before an effect; never discard an obtained result /// by repeating this check after the effect. pub fn check_before_effect( @@ -259,6 +282,21 @@ pub trait NonceSource: HostBound { /// thread guarantees; browser implementations may retain local UI/key handles. /// No method exposes a private key or implicitly publishes a message. pub trait ParticipantProvider: Signer { + /// Issues one exact captured intent. Unsupported adapters do not delegate + /// to the legacy method, which may discard already obtained results. + /// A result is not durable until the executor confirms its capture. + fn sign_exact( + &self, + intent: crate::issuance::SigningIntent, + ) -> BoxFuture<'_, crate::issuance::SigningOutcome> { + Box::pin(async move { + crate::issuance::SigningOutcome::not_dispatched( + intent.binding(), + ProviderError::CapabilityUnavailable, + ) + }) + } + /// Observes the actual key and currently available methods without signing. fn provider_state(&self) -> BoxFuture<'_, Result<ProviderState, ProviderError>>; /// Encrypts private text using provider-owned custody and qualified entropy. diff --git a/crates/signing/tests/issuance.rs b/crates/signing/tests/issuance.rs @@ -0,0 +1,609 @@ +use nostr::JsonUtil; +use radroots_domain::OperationId; +use radroots_event::GenericEventDraft; +use radroots_event_codec::authoring::AuthoredEventPlan; +use radroots_identity::PublicKey; +use radroots_signing::{ + issuance::*, + provider::{ProviderCall, ProviderError}, + request::CancellationSignal, +}; +use std::{num::NonZeroU64, str::FromStr}; + +const AUTHOR: &str = "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"; +const CREATED: u64 = 1_700_000_000; +fn plan(content: &str, tags: Vec<Vec<String>>) -> AuthoredEventPlan { + AuthoredEventPlan::from_generic( + GenericEventDraft::new( + "radroots.social.geochat.v1", + 20_000, + CREATED, + tags, + content, + AUTHOR, + ) + .unwrap(), + ) + .unwrap() +} +fn intent(content: &str, tags: Vec<Vec<String>>, operation: u8, digest: u8) -> SigningIntent { + SigningIntent::new( + OperationId::from_bytes([operation; 32]), + [digest; 32], + plan(content, tags), + ArtifactRole::PublicEvent, + None, + ProviderCall::new( + PublicKey::from_str(AUTHOR).unwrap(), + NonZeroU64::new(CREATED * 1000 + 10_000).unwrap(), + CancellationSignal::new(), + ), + ) + .unwrap() +} +fn signed(intent: &SigningIntent) -> String { + let keys = nostr::Keys::new( + nostr::SecretKey::from_slice(&{ + let mut bytes = [0; 32]; + bytes[31] = 1; + bytes + }) + .unwrap(), + ); + intent.with_plan(|plan| { + nostr::UnsignedEvent { + id: Some(nostr::EventId::from_slice(plan.expected_event_id().as_bytes()).unwrap()), + pubkey: keys.public_key(), + created_at: nostr::Timestamp::from_secs(plan.created_at()), + kind: nostr::Kind::Custom(plan.body().kind() as u16), + tags: nostr::Tags::from_list( + plan.body() + .tags() + .iter() + .cloned() + .map(|tag| nostr::Tag::parse(tag).unwrap()) + .collect(), + ), + content: plan.body().content().into(), + } + .sign_with_keys(&keys) + .unwrap() + .as_json() + }) +} +#[test] +fn measured_complete_wire_budget_matches_the_actual_codec_for_unicode_and_escapes() { + for content in [ + "", + "simple", + "café — soil", + "quotes\" and \\ slash\n\r\t\u{0000}\u{0008}\u{000c}", + ] { + let intent = intent( + content, + vec![vec!["subject".into(), "local\" crop\t".into()]], + 7, + 8, + ); + assert_eq!(intent.signed_json_bytes(), signed(&intent).len()); + assert_eq!(intent.binding().operation_id().as_bytes(), &[7; 32]); + } + let empty = intent("", vec![], 1, 2); + let available = SIGNED_EVENT_MAX_BYTES - empty.signed_json_bytes(); + let maximum = intent(&"x".repeat(available), vec![], 1, 2); + assert_eq!(signed(&maximum).len(), SIGNED_EVENT_MAX_BYTES); + let too_big = SigningIntent::new( + OperationId::from_bytes([1; 32]), + [2; 32], + plan(&"x".repeat(available + 1), vec![]), + ArtifactRole::PublicEvent, + None, + ProviderCall::new( + PublicKey::from_str(AUTHOR).unwrap(), + NonZeroU64::new(CREATED * 1000 + 10000).unwrap(), + CancellationSignal::new(), + ), + ); + assert!(matches!(too_big, Err(ProviderError::LimitExceeded))); +} +#[test] +fn authenticated_bytes_survive_unknown_or_out_of_range_observation_and_never_serialize_implicitly() +{ + let intent = intent("synthetic bounded payload", vec![], 7, 8); + let raw = signed(&intent); + for observed in [None, NonZeroU64::new(1), NonZeroU64::new(u64::MAX)] { + let outcome = SigningOutcome::capture(&intent, raw.clone(), observed); + let OutcomeKind::Obtained(artifact) = outcome.kind() else { + panic!("valid artifact lost: {outcome:?}"); + }; + assert_eq!(artifact.with_json(str::to_owned), raw); + assert_eq!( + artifact.event_id(), + intent.with_plan(|plan| *plan.expected_event_id()) + ); + assert_eq!( + artifact.observed_at_unix_ms(), + observed.filter(|at| at.get() <= MAX_EVENT_UNIX_SECONDS * 1000 + 999) + ); + assert!(!format!("{outcome:?}").contains("synthetic bounded payload")); + assert_eq!(format!("{intent:?}"), "SigningIntent(<redacted>)"); + } +} +#[test] +fn callback_provenance_never_rebinds_another_operation_or_command_as_success() { + let original = intent("same body", vec![], 1, 2); + let raw = signed(&original); + for other in [ + intent("same body", vec![], 9, 2), + intent("same body", vec![], 1, 9), + ] { + assert_ne!(original.binding(), other.binding()); + let outcome = + SigningOutcome::capture(&original, raw.clone(), None).enforce_binding(other.binding()); + let OutcomeKind::Rejected(rejected) = outcome.kind() else { + panic!("cross-intent success"); + }; + assert_eq!(rejected.reason(), RejectionReason::BindingMismatch); + assert_eq!(rejected.fingerprint().unwrap().total_bytes(), raw.len()); + } + let expected = original.binding(); + assert!(matches!( + SigningOutcome::unknown(expected, ProviderError::ProviderFailure) + .enforce_binding(expected) + .kind(), + OutcomeKind::Unknown(_) + )); +} +#[test] +fn malformed_wrong_field_signature_and_oversized_output_are_bounded_forensics() { + let intent = intent("expected", vec![], 1, 2); + let raw = signed(&intent); + let mut signature: serde_json::Value = serde_json::from_str(&raw).unwrap(); + signature["sig"] = "00".repeat(64).into(); + let different = signed(&self::intent("other", vec![], 1, 2)); + for (raw, reason) in [ + ( + String::from("malformed private response"), + RejectionReason::InvalidArtifact, + ), + (different, RejectionReason::InvalidArtifact), + (signature.to_string(), RejectionReason::InvalidSignature), + ( + "x".repeat(SIGNED_EVENT_MAX_BYTES + 1), + RejectionReason::TooLarge, + ), + ] { + let outcome = SigningOutcome::capture(&intent, raw.clone(), None); + let OutcomeKind::Rejected(rejected) = outcome.kind() else { + panic!("untrusted output promoted"); + }; + assert_eq!(rejected.reason(), reason); + let fingerprint = rejected.fingerprint().unwrap(); + assert_eq!( + fingerprint.covered_bytes(), + raw.len().min(SIGNED_EVENT_MAX_BYTES) + ); + assert_eq!(fingerprint.total_bytes(), raw.len()); + assert!(!format!("{outcome:?}").contains("malformed private response")); + } +} +#[test] +fn input_identity_recipient_role_and_time_are_validated_without_host_effects() { + let input = |role, recipient, call| { + SigningIntent::new( + OperationId::from_bytes([1; 32]), + [2; 32], + plan("bounded", vec![]), + role, + recipient, + call, + ) + }; + let call = || { + ProviderCall::new( + PublicKey::from_str(AUTHOR).unwrap(), + NonZeroU64::new(CREATED * 1000 + 10_000).unwrap(), + CancellationSignal::new(), + ) + }; + assert!(matches!( + input(ArtifactRole::BusinessSeal, None, call()), + Err(ProviderError::InvalidInput) + )); + assert!(matches!( + input( + ArtifactRole::GiftWrap, + Some(PublicKey::from_str(AUTHOR).unwrap()), + call() + ), + Err(ProviderError::InvalidInput) + )); + assert!(matches!( + input( + ArtifactRole::PublicEvent, + Some(PublicKey::from_str(AUTHOR).unwrap()), + call() + ), + Err(ProviderError::InvalidInput) + )); + assert!(matches!( + input( + ArtifactRole::PublicEvent, + None, + ProviderCall::new( + PublicKey::from_str(AUTHOR).unwrap(), + NonZeroU64::new(u64::MAX).unwrap(), + CancellationSignal::new() + ) + ), + Err(ProviderError::InvalidInput) + )); +} + +#[test] +fn unsupported_provider_explicitly_refuses_without_invoking_the_legacy_signer() { + use radroots_signing::{ + SignReceipt, SignRequest, Signer, SignerStatus, + provider::{ParticipantProvider, PrivateCiphertext, PrivateText, ProviderState}, + recovery::ReplayCapability, + signer::BoxFuture, + }; + use std::{ + sync::atomic::{AtomicUsize, Ordering}, + task::{Context, Poll, Waker}, + }; + struct Unsupported(AtomicUsize); + impl Signer for Unsupported { + fn status(&self) -> BoxFuture<'_, Result<SignerStatus, radroots_signing::Error>> { + Box::pin(async { Ok(SignerStatus::unavailable()) }) + } + fn sign( + &self, + _: SignRequest, + ) -> BoxFuture<'_, Result<SignReceipt, radroots_signing::Error>> { + self.0.fetch_add(1, Ordering::SeqCst); + Box::pin(async { + Err(radroots_signing::Error::new( + radroots_signing::error::Kind::SignerUnavailable, + )) + }) + } + } + impl ParticipantProvider for Unsupported { + fn provider_state(&self) -> BoxFuture<'_, Result<ProviderState, ProviderError>> { + Box::pin(async { + Ok(ProviderState::new( + PublicKey::from_str(AUTHOR).unwrap(), + radroots_signing::provider::PrivateCryptoCapability::Unavailable, + radroots_signing::provider::PrivateCryptoCapability::Unavailable, + ReplayCapability::NonReplayable, + )) + }) + } + fn encrypt_private( + &self, + _: ProviderCall, + _: PublicKey, + _: PrivateText, + ) -> BoxFuture<'_, Result<PrivateCiphertext, ProviderError>> { + Box::pin(async { Err(ProviderError::CapabilityUnavailable) }) + } + fn decrypt_private( + &self, + _: ProviderCall, + _: PublicKey, + _: PrivateCiphertext, + ) -> BoxFuture<'_, Result<PrivateText, ProviderError>> { + Box::pin(async { Err(ProviderError::CapabilityUnavailable) }) + } + } + let provider = Unsupported(AtomicUsize::new(0)); + let input = intent("bounded", vec![], 1, 2); + let expected = input.binding(); + let mut issue = provider.sign_exact(input); + let Poll::Ready(outcome) = issue.as_mut().poll(&mut Context::from_waker(Waker::noop())) else { + panic!("unsupported call pending"); + }; + assert_eq!(outcome.binding(), expected); + assert!(matches!( + outcome.kind(), + OutcomeKind::NotDispatched(ProviderError::CapabilityUnavailable) + )); + assert_eq!(provider.0.load(Ordering::SeqCst), 0); +} + +#[test] +fn intent_binding_preserves_low_operation_bytes_deadline_role_and_recipient() { + let original = intent("bounded", vec![], 1, 2); + let mut full_id = [1; 32]; + full_id[31] = 2; + let different = SigningIntent::new( + OperationId::from_bytes(full_id), + [2; 32], + plan("bounded", vec![]), + ArtifactRole::PublicEvent, + None, + ProviderCall::new( + PublicKey::from_str(AUTHOR).unwrap(), + NonZeroU64::new(CREATED * 1000 + 10_000).unwrap(), + CancellationSignal::new(), + ), + ) + .unwrap(); + assert_ne!(original.binding().digest(), different.binding().digest()); + assert_eq!(different.binding().operation_id().into_bytes(), full_id); + assert_eq!(original.binding().command_digest(), &[2; 32]); + assert_eq!(original.role(), ArtifactRole::PublicEvent); + assert_eq!(original.recipient(), None); + let later = SigningIntent::new( + OperationId::from_bytes([1; 32]), + [2; 32], + plan("bounded", vec![]), + ArtifactRole::PublicEvent, + None, + ProviderCall::new( + PublicKey::from_str(AUTHOR).unwrap(), + NonZeroU64::new(CREATED * 1000 + 10_001).unwrap(), + CancellationSignal::new(), + ), + ) + .unwrap(); + assert_ne!(later.binding(), original.binding()); + let peer = + PublicKey::from_str("c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5") + .unwrap(); + for (role, contract, kind, tags) in [ + ( + ArtifactRole::BusinessSeal, + "radroots.message.seal.v1", + 13, + vec![], + ), + ( + ArtifactRole::GiftWrap, + "radroots.message.gift_wrap.v1", + 1059, + vec![vec!["p".into(), peer.to_hex()]], + ), + ] { + // Ciphertext is opaque at this signing boundary; NIP-44 effects have + // their separate concrete provider/interoperability qualification. + let opaque = AuthoredEventPlan::from_generic( + GenericEventDraft::new( + contract, + kind, + CREATED, + tags, + "synthetic ciphertext preimage", + AUTHOR, + ) + .unwrap(), + ) + .unwrap(); + let input = SigningIntent::new( + OperationId::from_bytes([1; 32]), + [2; 32], + opaque, + role, + Some(peer), + ProviderCall::new( + PublicKey::from_str(AUTHOR).unwrap(), + NonZeroU64::new(CREATED * 1000 + 10_000).unwrap(), + CancellationSignal::new(), + ), + ) + .unwrap(); + assert_eq!(input.role(), role); + assert_eq!(input.recipient(), Some(peer)); + let raw = signed(&input); + assert_eq!(input.signed_json_bytes(), raw.len()); + let output = SigningOutcome::capture(&input, raw.clone(), None); + assert!(matches!(output.kind(), OutcomeKind::Obtained(_))); + let mut malformed: serde_json::Value = serde_json::from_str(&raw).unwrap(); + malformed["extra"] = "unsupported".into(); + assert!(matches!( + SigningOutcome::capture(&input, malformed.to_string(), None).kind(), + OutcomeKind::Rejected(_) + )); + } +} + +#[test] +fn duplicate_escaped_duplicate_unknown_and_deep_root_fields_never_become_signature_facts() { + let input = intent("quoted \\\" key: { [ is content", vec![], 1, 2); + let raw = signed(&input); + assert!(matches!( + SigningOutcome::capture(&input, raw.clone(), None).kind(), + OutcomeKind::Obtained(_) + )); + for key in ["id", "\\u0069d", "content", "sig", "unknown"] { + let duplicate = format!("{{\"{key}\":\"untrusted first field\",{}", &raw[1..]); + assert!(matches!( + SigningOutcome::capture(&input, duplicate, None).kind(), + OutcomeKind::Rejected(_) + )); + } + let deep = format!( + "{{\"id\":{}0{},{}", + "[".repeat(17), + "]".repeat(17), + &raw[1..] + ); + assert!(matches!( + SigningOutcome::capture(&input, deep, None).kind(), + OutcomeKind::Rejected(_) + )); +} + +#[test] +fn frozen_identity_time_and_preflight_refuse_changes_without_effects() { + let author = PublicKey::from_str(AUTHOR).unwrap(); + let peer = + PublicKey::from_str("c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5") + .unwrap(); + let call = |identity| { + ProviderCall::new( + identity, + NonZeroU64::new(CREATED * 1000 + 10_000).unwrap(), + CancellationSignal::new(), + ) + }; + assert!(matches!( + SigningIntent::new( + OperationId::from_bytes([1; 32]), + [2; 32], + plan("bounded", vec![]), + ArtifactRole::PublicEvent, + None, + call(peer) + ), + Err(ProviderError::InvalidInput) + )); + let future = AuthoredEventPlan::from_generic( + GenericEventDraft::new( + "radroots.social.geochat.v1", + 20_000, + MAX_EVENT_UNIX_SECONDS + 1, + vec![], + "bounded", + AUTHOR, + ) + .unwrap(), + ) + .unwrap(); + assert!(matches!( + SigningIntent::new( + OperationId::from_bytes([1; 32]), + [2; 32], + future, + ArtifactRole::PublicEvent, + None, + call(author) + ), + Err(ProviderError::InvalidInput) + )); + let cancellation = CancellationSignal::new(); + let input = SigningIntent::new( + OperationId::from_bytes([1; 32]), + [2; 32], + plan("bounded", vec![]), + ArtifactRole::PublicEvent, + None, + ProviderCall::new( + author, + NonZeroU64::new(CREATED * 1000 + 10_000).unwrap(), + cancellation.clone(), + ), + ) + .unwrap(); + assert_eq!(input.author(), author); + assert_eq!( + input.check_before_effect(author, CREATED * 1000 + 1), + Ok(()) + ); + assert_eq!( + input.check_before_effect(peer, CREATED * 1000 + 1), + Err(ProviderError::IdentityChanged) + ); + assert_eq!( + input.check_before_effect(author, CREATED * 1000 + 10_000), + Err(ProviderError::DeadlineExceeded) + ); + cancellation.cancel(); + assert_eq!( + input.check_before_effect(author, CREATED * 1000 + 1), + Err(ProviderError::Cancelled) + ); +} + +#[test] +fn complete_budget_checks_raw_content_and_multiple_tag_encoding() { + let huge = plan(&"x".repeat(SIGNED_EVENT_MAX_BYTES + 1), vec![]); + let call = ProviderCall::new( + PublicKey::from_str(AUTHOR).unwrap(), + NonZeroU64::new(CREATED * 1000 + 10_000).unwrap(), + CancellationSignal::new(), + ); + assert!(matches!( + SigningIntent::new( + OperationId::from_bytes([1; 32]), + [2; 32], + huge, + ArtifactRole::PublicEvent, + None, + call + ), + Err(ProviderError::LimitExceeded) + )); + let input = intent( + "bounded", + vec![ + vec!["subject".into(), "first".into()], + vec!["local_note".into(), "second".into()], + ], + 1, + 2, + ); + assert_eq!(input.signed_json_bytes(), signed(&input).len()); +} + +#[test] +fn changed_authenticated_fields_are_refused_without_erasing_forensic_identity() { + use sha2::{Digest, Sha256}; + let input = intent("expected", vec![], 1, 2); + let original = nostr::Event::from_json(signed(&input)).unwrap(); + for changed in 0..5 { + // Fixed public interoperability identities; no custody material. + let mut scalar = [0; 32]; + scalar[31] = if changed == 0 { 2 } else { 1 }; + let keys = nostr::Keys::new(nostr::SecretKey::from_slice(&scalar).unwrap()); + let mut unsigned = nostr::UnsignedEvent { + id: None, + pubkey: keys.public_key(), + created_at: original.created_at, + kind: original.kind, + tags: original.tags.clone(), + content: original.content.clone(), + }; + match changed { + 0 => {} + 1 => unsigned.created_at = nostr::Timestamp::from_secs(CREATED + 1), + 2 => unsigned.kind = nostr::Kind::Custom(20_001), + 3 => { + unsigned.tags = nostr::Tags::from_list(vec![ + nostr::Tag::parse(vec!["subject", "different"]).unwrap(), + ]) + } + _ => unsigned.content = "different".into(), + } + let event = unsigned.sign_with_keys(&keys).unwrap(); + event.verify().unwrap(); + let raw = event.as_json(); + let hash: [u8; 32] = Sha256::digest(raw.as_bytes()).into(); + let (binding, kind) = SigningOutcome::capture(&input, raw.clone(), None).into_parts(); + assert_eq!(binding, input.binding()); + let OutcomeKind::Rejected(rejected) = kind else { + panic!("changed authenticated field accepted") + }; + assert_eq!(rejected.reason(), RejectionReason::InvalidArtifact); + let fingerprint = rejected.fingerprint().unwrap(); + assert_eq!(fingerprint.sha256(), &hash); + assert_eq!(fingerprint.covered_bytes(), raw.len()); + } + let other = intent("expected", vec![], 2, 2).binding(); + let rejected = SigningOutcome::capture(&input, "invalid response".into(), None); + let prior = match rejected.kind() { + OutcomeKind::Rejected(value) => value.fingerprint(), + _ => panic!("untrusted output accepted"), + }; + let rebound = rejected.enforce_binding(other); + let OutcomeKind::Rejected(value) = rebound.kind() else { + panic!("mismatch accepted") + }; + assert_eq!(value.reason(), RejectionReason::BindingMismatch); + assert_eq!(value.fingerprint(), prior); + let negative = + SigningOutcome::not_dispatched(input.binding(), ProviderError::CapabilityUnavailable) + .enforce_binding(other); + assert!(matches!(negative.kind(), OutcomeKind::Rejected(_))); +} diff --git a/crates/signing/tests/package_boundary.rs b/crates/signing/tests/package_boundary.rs @@ -20,6 +20,7 @@ fn manifest_has_final_identity_features_and_dependencies() { "version = \"0.1.0-alpha\"", "publish = [\"crates-io\"]", "default = [\"std\", \"serde\"]", + "radroots_domain = { workspace = true, default-features = false }", "radroots_event = { workspace = true, default-features = false }", "radroots_event_codec = { workspace = true, default-features = false }", "radroots_identity = { workspace = true, default-features = false }", @@ -38,6 +39,7 @@ fn manifest_has_final_identity_features_and_dependencies() { table_keys(MANIFEST, "[dependencies]"), BTreeSet::from([ "hex", + "radroots_domain", "radroots_event", "radroots_event_codec", "radroots_identity", @@ -77,6 +79,7 @@ fn crate_root_declares_the_approved_module_skeleton() { "error", "host", "identity", + "issuance", "provider", "recovery", "request", @@ -99,6 +102,7 @@ fn crate_root_declares_the_approved_module_skeleton() { "error", "host", "identity", + "issuance", "provider", "receipt", "recovery", @@ -198,6 +202,7 @@ fn every_public_module_has_crate_level_documentation() { "error", "host", "identity", + "issuance", "provider", "recovery", "request", diff --git a/tools/xtask/src/architecture/decision_package.rs b/tools/xtask/src/architecture/decision_package.rs @@ -415,7 +415,7 @@ fn validate_packages(packages: &[Package]) -> Result<(), String> { ("identity", &[][..]), ("domain", &["identity"][..]), ("protocol", &["domain", "identity"][..]), - ("signing", &["identity", "protocol"][..]), + ("signing", &["domain", "identity", "protocol"][..]), ("storage", &["domain", "protocol"][..]), ("transport", &["protocol", "identity"][..]), ( diff --git a/tools/xtask/src/compiler_preparation.rs b/tools/xtask/src/compiler_preparation.rs @@ -12,7 +12,7 @@ const MAX_CONTRACT_BYTES: usize = 65_536; const BOUND_INPUTS: [(&str, &str); 3] = [ ( "contracts/architecture/decisions/shared_sdk_refactor.v1.json", - "b4568699c2010c0574e4e32c68aca9f3ee16cb5e2f4a7e6553dc21d636e6cb58", + "7937dc9ee4aca42f015d3bba5b23e2b5e7cffe461589518bd6eef6305892931e", ), ( "contracts/architecture/decisions/services_hardening_source_lock.v4.json",