// SPDX-License-Identifier: LGPL-2.1-or-later

///|
/// Options for the standard RK+BLAKE2 signature profile. Zero never means auto.
pub(all) struct SignatureOptions {
  block_len : Int64
  strong_sum_len : Int64
}

///|
/// Default signature block size 2048; prefix of BLAKE2b-256 of length 32.
pub fn SignatureOptions::default() -> SignatureOptions {
  { block_len: 2048L, strong_sum_len: 32L, }
}

///|
/// Generate standard 0x72730147 signature bytes, not a delta or file recovery.
/// Validates limits, options, basis and output budgets before hashing/allocation.
/// Empty basis emits only the 12-byte header; the final short block is unpadded.
/// Full-buffer API: input is already allocated; final Bytes conversion may copy
/// the output buffer. These limits are not a process-wide peak-memory bound.
pub fn signature(
  basis : Bytes,
  options : SignatureOptions,
  limits : Limits,
) -> Bytes raise SyncError {
  let (block, strong, count, size) = signature_plan(
    basis.length().to_uint64(),
    options,
    limits,
  )
  let output = signature_header(block, strong, size)
  let mut pos = 0
  let mut cursor = 12L
  for _ in 0.. Bytes raise SyncError {
  apply_patch_bytes(basis, delta_bytes, limits)
}

///|
/// Generate a standard delta using only the remote signature and new bytes.
/// Validates the signature even for empty new input. One work budget covers
/// indexing, rolling scan, candidate confirmation and instruction accumulation.
/// COPY uses confirmed checksum prefixes, not basis identity authentication;
/// callers must check final content outside the standard format.
/// Command capacity allocation and live-slot relocation are precharged before
/// reserve/push. Parsed digest copies, index arrays, views and final conversion
/// storage coexist; see docs/resources.md, not a constant-memory promise.
pub fn delta(
  signature_bytes : Bytes,
  new_bytes : Bytes,
  limits : Limits,
) -> Bytes raise SyncError {
  generate_remote_delta(signature_bytes, new_bytes, limits)
}