UDIF: Universal Digital Identification Framework 1.0.0.0a (A1)
A quantum-secure cryptographic identification
treaty.h File Reference

UDIF treaty operations. More...

#include "udif.h"

Go to the source code of this file.

Data Structures

struct  udif_treaty
 Cross-domain treaty. More...

Macros

#define UDIF_TREATY_SCOPE_ANALYTICS   1U
 The treaty scope analytic.
#define UDIF_TREATY_SCOPE_INTRA_DOMAIN   2U
 Intra-domain treaty scope.
#define UDIF_TREATY_SCOPE_LOCAL   4U
 Local only treaty scope.
#define UDIF_TREATY_SCOPE_QUERY   8U
 The intra-domain query scope.
#define UDIF_TREATY_SCOPE_TRANSFER   16U
 The cross domain scope transfer.
#define UDIF_TREATY_SCOPE_TREATY   32U
 Cross-domain treaty scope.
#define UDIF_TREATY_SCOPE_RESERVED1   64U
 The reserved-1 scope setting.
#define UDIF_TREATY_SCOPE_RESERVED2   128U
 The reserved-2 scope setting.
#define UDIF_TREATY_SCOPE_RESERVED3   256U
 The reserved-3 scope setting.
#define UDIF_TREATY_SCOPE_MAX   256U
 The maximum scope setting.
#define UDIF_TREATY_POLICY_VERSION_SIZE   4U
 The policy version size.
#define UDIF_TREATY_SCOPE_QUERY_SIZE   4U
 The query scope integer size.
#define UDIF_TREATY_DEFAULT_DURATION   (365U * 24U * 3600U)
 Default treaty duration (1 year).
#define UDIF_TREATY_MAX_DURATION   (5U * 365U * 24U * 3600U)
 Maximum treaty duration (5 years).
#define UDIF_TREATY_STRUCTURE_SIZE
 The treaty structure byte size.

Typedefs

typedef UDIF_EXPORT_API struct udif_treaty udif_treaty

Functions

UDIF_EXPORT_API udif_errors udif_treaty_accept (udif_treaty *treaty, const uint8_t *domsigkeyb, bool(*rng_generate)(uint8_t *, size_t))
 Accept a treaty proposal.
UDIF_EXPORT_API bool udif_treaty_allows_scope (const udif_treaty *treaty, uint32_t scope)
 Check if treaty allows scope.
UDIF_EXPORT_API void udif_treaty_clear (udif_treaty *treaty)
 Clear a treaty.
UDIF_EXPORT_API bool udif_treaty_compare (const udif_treaty *a, const udif_treaty *b)
 Compare two treaties.
UDIF_EXPORT_API udif_errors udif_treaty_compute_digest (uint8_t *digest, const udif_treaty *treaty)
 Compute treaty digest.
UDIF_EXPORT_API udif_errors udif_treaty_create_proposal (udif_treaty *treaty, const uint8_t *treatyid, const uint8_t *domsera, const uint8_t *domserb, uint32_t scopebitmap, uint64_t validfrom, uint64_t validto, uint32_t policy, const uint8_t *domsigkeya, bool(*rng_generate)(uint8_t *, size_t))
 Create a treaty proposal.
UDIF_EXPORT_API udif_errors udif_treaty_deserialize (udif_treaty *treaty, const uint8_t *input, size_t inplen)
 Deserialize a treaty.
UDIF_EXPORT_API size_t udif_treaty_encoded_size (const udif_treaty *treaty)
 Get treaty encoded size.
UDIF_EXPORT_API uint64_t udif_treaty_get_duration (const udif_treaty *treaty)
 Get treaty duration.
UDIF_EXPORT_API bool udif_treaty_is_active (const udif_treaty *treaty, uint64_t ctime)
 Check if treaty is active.
UDIF_EXPORT_API bool udif_treaty_is_expired (const udif_treaty *treaty, uint64_t ctime)
 Check if treaty is expired.
UDIF_EXPORT_API bool udif_treaty_is_participant (const udif_treaty *treaty, const uint8_t *entityser)
 Check if entity is treaty participant.
UDIF_EXPORT_API bool udif_treaty_is_pending (const udif_treaty *treaty)
 Check if treaty is pending.
UDIF_EXPORT_API udif_errors udif_treaty_serialize (uint8_t *output, size_t outlen, const udif_treaty *treaty)
 Serialize a treaty.
UDIF_EXPORT_API udif_errors udif_treaty_validate (const udif_treaty *treaty)
 Validate treaty parameters.
UDIF_EXPORT_API bool udif_treaty_verify (const udif_treaty *treaty, const uint8_t *domverkeya, const uint8_t *domverkeyb)
 Verify a treaty.

Detailed Description

UDIF treaty operations.

This module implements bilateral treaties between UDIF domains. Treaties establish formal agreements for cross-domain operations, defining what information can be shared and under what conditions.

Treaty Features:

  • Bilateral agreements between two domains
  • Scope negotiation (what operations are allowed)
  • Duration limits (start and end times)
  • Policy epoch tracking for updates
  • Dual signatures (both parties must agree)

Treaty Lifecycle:

  1. Propose: Domain A creates treaty proposal
  2. Accept: Domain B signs to accept
  3. Active: Treaty is in effect
  4. Expire: Treaty reaches end time
  5. Revoke: Either party can revoke early

Treaties enable:

  • Cross-domain queries
  • Object transfers between domains
  • Federated identity verification
  • Collaborative analytics

Macro Definition Documentation

◆ UDIF_TREATY_STRUCTURE_SIZE

#define UDIF_TREATY_STRUCTURE_SIZE
Value:
UDIF_VALID_TIME_SIZE + \
UDIF_VALID_TIME_SIZE + \
#define UDIF_TREATY_SCOPE_QUERY_SIZE
The query scope integer size.
Definition treaty.h:156
#define UDIF_TREATY_POLICY_VERSION_SIZE
The policy version size.
Definition treaty.h:150
#define UDIF_SERIAL_NUMBER_SIZE
The serial number field length.
Definition udif.h:519
#define UDIF_SIGNED_HASH_SIZE
The combined size of a signature and hash.
Definition udif.h:525

The treaty structure byte size.

Function Documentation

◆ udif_treaty_accept()

UDIF_EXPORT_API udif_errors udif_treaty_accept ( udif_treaty * treaty,
const uint8_t * domsigkeyb,
bool(* rng_generate )(uint8_t *, size_t) )

Accept a treaty proposal.

Signs a treaty proposal to accept and activate it.

Parameters
treatyThe treaty structure (will be updated)
domsigkeyb[const] Domain B's private key
rng_generateRandom number generator function
Returns
Returns udif_error_none on success

◆ udif_treaty_allows_scope()

UDIF_EXPORT_API bool udif_treaty_allows_scope ( const udif_treaty * treaty,
uint32_t scope )

Check if treaty allows scope.

Tests if a specific operation scope is permitted.

Parameters
treaty[const] The treaty
scopeThe scope to check
Returns
Returns true if allowed

◆ udif_treaty_clear()

UDIF_EXPORT_API void udif_treaty_clear ( udif_treaty * treaty)

Clear a treaty.

Zeros out a treaty structure.

Parameters
treatyThe treaty to clear

◆ udif_treaty_compare()

UDIF_EXPORT_API bool udif_treaty_compare ( const udif_treaty * a,
const udif_treaty * b )

Compare two treaties.

Checks if two treaties are identical.

Parameters
a[const] The first treaty
b[const] The second treaty
Returns
Returns true if identical

◆ udif_treaty_compute_digest()

UDIF_EXPORT_API udif_errors udif_treaty_compute_digest ( uint8_t * digest,
const udif_treaty * treaty )

Compute treaty digest.

Calculates the canonical digest of a treaty for signing.

Parameters
digestThe output digest (32 bytes)
treaty[const] The treaty
Returns
Returns udif_error_none on success

◆ udif_treaty_create_proposal()

UDIF_EXPORT_API udif_errors udif_treaty_create_proposal ( udif_treaty * treaty,
const uint8_t * treatyid,
const uint8_t * domsera,
const uint8_t * domserb,
uint32_t scopebitmap,
uint64_t validfrom,
uint64_t validto,
uint32_t policy,
const uint8_t * domsigkeya,
bool(* rng_generate )(uint8_t *, size_t) )

Create a treaty proposal.

Creates a treaty proposal for bilateral agreement.

Parameters
treatyThe output treaty structure
treatyid[const] The treaty identifier (32 bytes)
domsera[const] The first domain serial (16 bytes)
domserb[const] The second domain serial (16 bytes)
scopebitmapThe allowed operation scopes
validfromThe treaty start time (UTC seconds)
validtoThe treaty end time (UTC seconds)
policyThe policy version number
domsigkeya[const] Domain A's private key
rng_generateRandom number generator function
Returns
Returns udif_error_none on success

◆ udif_treaty_deserialize()

UDIF_EXPORT_API udif_errors udif_treaty_deserialize ( udif_treaty * treaty,
const uint8_t * input,
size_t inplen )

Deserialize a treaty.

Decodes a treaty from canonical format.

Parameters
treatyThe output treaty structure
input[const] The input buffer
inplenThe input buffer length
Returns
Returns udif_error_none on success

◆ udif_treaty_encoded_size()

UDIF_EXPORT_API size_t udif_treaty_encoded_size ( const udif_treaty * treaty)

Get treaty encoded size.

Calculates the serialized size of a treaty.

Parameters
treaty[const] The treaty
Returns
The encoded size in bytes

◆ udif_treaty_get_duration()

UDIF_EXPORT_API uint64_t udif_treaty_get_duration ( const udif_treaty * treaty)

Get treaty duration.

Calculates the treaty duration in seconds.

Parameters
treaty[const] The treaty
Returns
The duration in seconds

◆ udif_treaty_is_active()

UDIF_EXPORT_API bool udif_treaty_is_active ( const udif_treaty * treaty,
uint64_t ctime )

Check if treaty is active.

Verifies that a treaty is currently in effect.

Parameters
treaty[const] The treaty
ctimeThe current time (UTC seconds)
Returns
Returns true if active

◆ udif_treaty_is_expired()

UDIF_EXPORT_API bool udif_treaty_is_expired ( const udif_treaty * treaty,
uint64_t ctime )

Check if treaty is expired.

Tests if a treaty has reached its end time.

Parameters
treaty[const] The treaty
ctimeThe current time (UTC seconds)
Returns
Returns true if expired

◆ udif_treaty_is_participant()

UDIF_EXPORT_API bool udif_treaty_is_participant ( const udif_treaty * treaty,
const uint8_t * entityser )

Check if entity is treaty participant.

Tests if an entity is one of the treaty parties.

Parameters
treaty[const] The treaty
entityser[const] The entity serial (16 bytes)
Returns
Returns true if participant

◆ udif_treaty_is_pending()

UDIF_EXPORT_API bool udif_treaty_is_pending ( const udif_treaty * treaty)

Check if treaty is pending.

Tests if a treaty is proposed but not yet accepted.

Parameters
treaty[const] The treaty
Returns
Returns true if pending (only has one signature)

◆ udif_treaty_serialize()

UDIF_EXPORT_API udif_errors udif_treaty_serialize ( uint8_t * output,
size_t outlen,
const udif_treaty * treaty )

Serialize a treaty.

Encodes a treaty to canonical format.

Parameters
outputThe output buffer
outlenThe output buffer length
treaty[const] The treaty to serialize
Returns
Returns udif_error_none on success

◆ udif_treaty_validate()

UDIF_EXPORT_API udif_errors udif_treaty_validate ( const udif_treaty * treaty)

Validate treaty parameters.

Checks that treaty parameters are valid.

Parameters
treaty[const] The treaty
Returns
Returns udif_error_none if valid

◆ udif_treaty_verify()

UDIF_EXPORT_API bool udif_treaty_verify ( const udif_treaty * treaty,
const uint8_t * domverkeya,
const uint8_t * domverkeyb )

Verify a treaty.

Verifies both signatures on a treaty.

Parameters
treaty[const] The treaty to verify
domverkeya[const] Domain A's public key
domverkeyb[const] Domain B's public key
Returns
Returns true if both signatures are valid