Public-input weighted batch prototype

The separate radix_certificate experiment lets an untrusted query or offchain producer attach compact column-point witnesses to the ordinary BIP340 batch equation. Its verifier independently reparses every record and checks both reconstruction and a transcript-bound SIMD MSM. It requires wasm-msm-simd, explicit borrowed scratch and caller-selected protocol parameters; it stores no query verdict or prepared key. See the design and trust boundary and the complete query/update benchmark. This additional proof protocol remains experimental and separate from ordinary batch acceptance.

radix_certificate::prove uses four independent SIMD column lanes. prove_reference_columns runs the same columns separately as an experiment control; both produce identical canonical bytes for verify. With N input records and m=params.columns(), both need 2*N+1 original terms and 2*N+1+m check terms. Verification and the reference prover need that many MSM encodings/affines and B=2^(window_bits-1) buckets. The default prover also requires at least 4*(2*N+1) encodings/affines and 4*B buckets. Scratch is borrowed and rebuilt per call. Protocol parameters support every integer b=8..32 and t=128/160; params.max_batch() reports the parameter-dependent record bound. There are ceil(256/b) columns; the last uses only its remaining live bits. The original byte-aligned widths retain their fixed extraction paths. See width bounds for exact coefficients and proof sizes.

The repeated-key round qualifies prove_grouped and verify_grouped: all original inputs are freshly checked, while repeated P contributions are combined only after their radix mapping. They preserve the ordinary certificate bytes and borrowed workspace. The optional checkpoints module appends exactly checked intermediate Horner points, then verifies those recurrences in SIMD. At b16 this grows the proof from 1,026B to 1,924B and trades extra producer work for cheaper replicated verification. checkpoints::proof_bytes(params) sizes the complete buffer; extend appends to an existing column proof, and verify checks the full packet. The folding notes describe exact bounds and producer policy.

The third round qualifies wasm-msm-xyzz for public MSM buckets and accumulators. It implies wasm-msm-simd; independent signature filtering and checkpoint reconstruction keep their Jacobian formulas. The extra cached coordinate exchanges some scratch space for fewer field squares. Bounded MSM schedules longer bucket chains first and preserves finished inactive lanes until refill. No public validation, coefficient entropy or secret-key arithmetic is removed. The benchmark's packed Wire route borrows descriptors from fixed 192-byte records; that transport choice is separate from this allocation-free library API.

The fourth round stores fitting bounded schedules as centered byte digits in the existing encoding scratch and updates ordinary finite XYZZ chain lanes in place. Coefficient accumulation defers carries where its exact integer bounds permit. Four fixed-message challenges share the SHA-256 SIMD compressor; ragged groups and tails retain their scalar path. checkpoints::prove_grouped produces the complete proof while retaining its freshly generated columns within the call. Public extend and verify still check externally supplied encodings.

This no_std, allocation-free crate provides exact independent BIP340 verification, weighted aggregate verification and an experimental explicit-R ECDSA* control. The aggregate coefficient/API security policy remains under review. Native vector correctness is separate from installed IC qualification. See the current measured choices for qualified workloads and their exact artifact and input boundaries.

use cdk_rsx_crypto_batch::{Item, Workspace, verify_bip340_batch};
use cdk_rsx_crypto_batch::msm::{self, Algorithm, ProjectivePoint, PublicMsmPoint, Term, Window};

fn verify(items: &[Item<'_>]) -> Result<bool, cdk_rsx_crypto_batch::Error> {
    if items.is_empty() || items.len() > cdk_rsx_crypto_batch::MAX_BATCH {
        return Err(cdk_rsx_crypto_batch::Error::BatchSize);
    }
    let algorithm = Algorithm::Pippenger(Window::new(5).unwrap());
    // The caller owns backing storage. Direct Vec allocation avoids placing
    // a large fixed workspace array on the stack before boxing it.
    let count = 2 * items.len() + 1;
    let mut terms = vec![Term::ZERO; count];
    let mut encodings = vec![[0; msm::ENCODING_BYTES]; algorithm.encodings(count)];
    let mut buckets = vec![ProjectivePoint::IDENTITY;
        if algorithm.uses_jacobian() { 0 } else { algorithm.buckets() }];
    let mut jacobian_buckets = vec![PublicMsmPoint::IDENTITY;
        if algorithm.uses_jacobian() { algorithm.buckets() } else { 0 }];
    let mut workspace = Workspace {
        terms: &mut terms,
        msm: msm::Workspace {
            encodings: &mut encodings, buckets: &mut buckets,
            jacobian_buckets: &mut jacobian_buckets,
        },
    };
    verify_bip340_batch(items, &mut workspace, algorithm)
}

Callers must enforce the documented batch bound before allocating based on untrusted input. Public arithmetic types are re-exported by msm solely for caller-owned buffers. Variable-time branches and bucket addresses reveal scalar digits: all messages, points and scalars processed here must be public. Signing, secret scalar multiplication and confidential verification inputs are out of scope. The library imports no IC API, allocator or ambient randomness.

BIP340 items contain exactly a 32-byte x-only key and 64-byte signature, with the raw message bytes. Public x and r must be below p and lift to even-Y curve points; s must be canonical below n, including zero. Messages are bounded to 1 MiB each and 16 MiB total. There are 1..=500 records. These message limits are local admission bounds, not BIP340 restrictions. Malformed encodings are errors; a well-formed incorrect equation returns Ok(false).

The schnorr_hints experiment keeps that standard signature and accepts a canonical even y(P), optionally with canonical even y(R). Every call checks each supplied coordinate's field range, even parity and curve equation against the original public or signature x. The direct checked-field path avoids square-root decompression; an equivalent checked uncompressed-SEC1 control is available. Hints never change the complete standard transcript, challenge or weights, and no validated points are saved between calls. HintedItem requires P-Y; nonce Y may be present or absent per row. Cohorts with no hints use the ordinary Item API.

schnorr_hints::verify_single checks an exact individual equation without batch coefficients. P-only retains the public joint multiplication, final parity and x check. P+R builds a fresh odd-multiple table with one shared denominator and uses public Jacobian arithmetic with a G10 generator prefix contained in one charged region. This avoids the table-normalization inversion as well as the final affine inversion. Both coordinates are compared against the checked nonce point; no signer table or result is retained from an earlier call. The challenge has an exact fixed32 SHA-256 midstate path; arbitrary message lengths retain standard tagged hashing. The hinted batch uses the existing caller-owned workspace and MSM selection. Error::PublicY(i) and NonceY(i) reject malformed hints; Input(error) retains the core error. Full fallback rechecks every record and every supplied hint. derive_even_y performs ordinary decompression for client/fixture construction; its work and the additional 32 or 64 bytes per record belong to the protocol cost. The hint API is public-input only and has no signing or secret-arithmetic path.

With wasm-msm-simd, exact independent bulk APIs are available:

  • verify_independent borrows IndependentSimdWorkspace for four-record groups.
  • verify_independent_chunk16 borrows IndependentChunkWorkspace for denser 16-record scheduling, useful for larger cohorts.

Each returns a Result<bool, Error> for every input, with all supplied hint checks and one exact equation per record. A field-normalization inverse can be shared within a group; no weighted aggregate replaces the individual verdicts. Malformed rows keep their errors while later rows continue. Partial groups and scalar tails remain exact. Scratch is caller-owned and rebuilt within the call; construct and drop it inside a complete-call benchmark. storage_bytes() reports the current target's owned scratch, excluding compiler frames and borrowed input/output. Native debug and Wasm64 sizes differ.

The R13 study compares scalar, four-record and dense schedules. For complete P+R-hinted cohorts, its canister uses separate frames: scalar below four records, quads for 4–15, dense chunks from 16. Other hint cohorts stay scalar. This keeps large bulk scratch out of the single-call path. The exact kernel helpers accept only public inputs; signing arithmetic is unchanged. The dense path retains transposed SIMD accumulators and normalizes each typed public key once before importing bounded private G/Q table limbs. These unit residues need not be canonical bytes; generic affine and final nonce conversion remain fully normalizing. Public radix32 GLV preparation is shared with the scalar helper. Quad/scalar tails retain exact independent checks.

The optional wasm-msm-simd feature exposes public simd_msm verification. Its radix-26 field retains carry intermediates in paired u64x2 vectors. Point-indexed gather/scatter packs four independent bucket updates directly from caller storage. Affine inputs are borrowed by checked indices instead of copied into temporary point arrays; finite-lane masks skip irrelevant normalization and selection work while preserving exceptional cases. Four bucket-sum streams retain the exact digit weights through the final sum.

SIMD GLV preparation uses public-only radix-32 integer arithmetic to compute the same signed 128-bit split from full-width rounded products. Standard challenges, full-field coefficients and weighted scalar products remain unchanged. This preparation never serves signing or secret multiplication. Caller-owned affine coordinates, GLV images, encodings and buckets are rebuilt within each call; there is no retained key, point or result cache.

Each window builds bounded bucket-local chains of signed affine indices. Four SIMD accumulators stay live across updates; a bucket is gathered when its lane starts and scattered when its chain finishes. Finished lanes become identity before refill. This removes repeated gather/scatter while retaining every term. The chains use 4,004 bytes of links and 256 bytes of heads on the stack; their capacity and sentinel separation are checked at compile time. Chain indices come from bounded input positions.

The public encoded-term density selects whether to group the first updates through the checked unit-Z leaf. Denser calls use generic mixed addition. Both routes preserve coordinate checks, exceptional cases and full fallback. Selected point helpers inline to avoid costly aggregate return copies. Actual page costs and nested stack usage remain separate from a function's frame size. See the current optimization report, carry and affine-pair notes. The R4 experiment retains dated evidence; current qualification records measured selections.

verify_bip340_batch derives weights from a complete ordered, length-framed transcript using tagged SHA256 and ChaCha20 rejection sampling, with a1=1 and remaining weights in 1..n-1. The explicit verify_bip340_batch_randomized variant mixes 32 fresh caller-CSPRNG bytes with that transcript after all inputs parse. The framed seed format and entropy augmentation are documented in the research contract. The RNG trait does not prove entropy quality; a fixed fixture seed is not fresh randomness.

ecdsa_explicit accepts SEC1 keys of 33 or 65 bytes, digest 32 and the separate compressed R33 || s32 format. It checks valid nonidentity curve points, r=x(R) mod n !=0, nonzero canonical s, and an explicit low-S policy. It preserves valid x(R)>=n cases. Its independent full-field coefficients aggregate sR-rQ-zG=identity, without S inversion. Both transcript-deterministic and fresh caller-entropy APIs exist. This format is not standard compact r||s, recoverable ECDSA, ECDSA_rec, or HSS-rand. Converting a compact signature with the existing secp producer performs individual verification and must be counted separately.

Both families' *_with_fallback functions return a BatchReport and fill a caller-supplied verdict slice. An accepted aggregate marks every row true with its normal probabilistic soundness. On aggregate failure or malformed records, all N records receive exact individual checks using the selected MSM backend; there is no random sampling or early exit. Worst case is one aggregate plus N single checks. Workspace, message/count and randomness errors propagate; ignore output after Err. Public scratch may contain intermediate values after failure; the next call validates and overwrites all used slots. No batch state is cached or persisted, and callers must keep the exact input bytes fixed through the call.

MSM retains validated affine inputs for mixed bucket additions and tracks public bucket occupancy to skip each first addition and empty bucket accumulations. It supports unsigned and signed Pippenger windows 2..8 and a binary Straus control. Signed windows retain the final carry and use half as many buckets. Scalar GLV reuses k256's established split into signed 128-bit components and derives public endomorphism images during the call. It uses two encoding slots per term and no saved key tables. Callers use algorithm.encodings(count) and algorithm.buckets() for that backend's scratch counts. SIMD uses the matching Config methods and its separate BatchWorkspace. The separate signed Jacobian candidates use opaque public accumulators and explicit identity/equal/opposite branches. Their final batch equation checks identity directly, without affine conversion. Backing sizes depend on the target and chosen algorithm. Benchmark receipts state whether storage is staged or constructed within the call; stack layout and actual Wasm page charges are separate from native backing counts. The library itself performs no allocation.

Tests cover all 19 official BIP vectors, arbitrary MSM controls at every window 2..8, full-width signed carries, long Jacobian chains, strict boundaries, coefficient sampling and cancellation. ECDSA tests check all 306 independent producer verdicts, both S policies and all four x>=n cases. Mixed cohorts and complete fallback are checked at 1/8/32/100/128/500. Provenance records source/vector/dependency hashes and the native integration test evidence; licensing records reuse terms. Research notes preserve the 2012/2026 paper access limits and the narrowly scoped 2025 precursor cancellation reproducer.

The native diagnostic cargo test --manifest-path benches/crypto/Cargo.toml -p cdk-rsx-crypto-bench-cases --offline --locked native_fresh_distinct_primary100_sweep -- --ignored --nocapture includes fresh parsing and coefficient generation in each run over 100 distinct signers. It reports host timing only; IC instructions, page charges and whole-message qualification require the canonical Wasm runner.