Skip to content

fix(tests,verkle,schema-gen): resolve issues #267 #268 #269 #274 - #329

Open
Iceeyyou2 wants to merge 1 commit into
hartz0:mainfrom
Iceeyyou2:fix/issues-267-268-269-274
Open

Iceeyyou2 wants to merge 1 commit into
hartz0:mainfrom
Iceeyyou2:fix/issues-267-268-269-274

Conversation

@Iceeyyou2

Copy link
Copy Markdown

closes #267 – Differential arithmetic test suite for fixed-point decay math Add contracts/scoregate-score/src/test_decay_differential.rs with 8 parameterised tests that compare decay_fixed() against a libm f64 reference across the full documented parameter space (t ∈ [0,365 days], λ ∈ [0.0001, 0.5]). Covers: zero-lambda short-circuit, per-axis sweeps, an 11×12 full 2-D grid, horizon-clamping invariant, strict monotonicity in age, zero-age boundary (must return SCALE exactly), Taylor/saturation boundary at x=5, and bounded truncation error (±0.15 % of SCALE).

closes #268 – Canonical BLS12-381 scalar field validation in decode_proof In contracts/scoregate-score/src/verkle.rs, add the scalar field modulus r as BLS12_381_SCALAR_MODULUS_R and an is_canonical_field_element() predicate. decode_proof now returns None if any of the three extracted field elements (z, v, witness) are ≥ r, closing the proof-malleability window where two distinct byte encodings represent the same mathematical value.

closes #269 – Exhaustive negative test vectors for Bulletproof inner-product argument Append 29 new #[test] functions to test_zk_range_proof.rs organised into 9 categories: corrupted L[i]/R[i] curve points (all 3 rounds, x and y), zeroed-out identity substitutions, L↔R round-level swaps, truncated and extended transcripts (empty / 256 B / 752 B / 801 B), non-canonical Fiat-Shamir challenge injection via high-bit flips on L[0]/R[0], zero and swapped terminal scalars a/b, all four outer polynomial commitments A/S/T1/T2, and all three inner scalars tx/taux/mu. A local macro replaces the previous unsafe-transmute fixture helper.

closes #274 – AggregateRiskScore, ScoreSubmission, BatchAttestation in schema-gen tools/schema-gen/src/lib.rs:

  • Export AGGREGATE_RISK_SCORE_NAME, SCORE_SUBMISSION_NAME, BATCH_ATTESTATION_NAME constants and *_SCHEMA_FILE / *_TYPESCRIPT_FILE / *_PYTHON_FILE filename constants for each new type.
  • Add native_aggregate_risk_score_struct(), native_score_submission_struct(), native_batch_attestation_struct() extraction functions (native + WASM paths) backed by a shared wasm_named_struct() / into_named_struct() helper that replaces the single-type into_risk_score_struct().
  • Extend risk_domain_range() to cover aggregate_score and max_pair_score on AggregateRiskScore (same [0,100] domain as RiskScore fields).
  • Add tests_extended module: 20 new tests verifying field lists, bounded-field constraints, unbounded fields, JSON Schema / TypeScript / Python output, cross-type provenance headers, and WASM error paths for all three new types. tools/schema-gen/src/main.rs:
  • Load all four structs from native or WASM source.
  • Emit 4×3 = 12 artifact files (schema + ts + py per type).
  • Update --help text and success message.

…rtz0#269 hartz0#274

hartz0#267 – Differential arithmetic test suite for fixed-point decay math
Add contracts/scoregate-score/src/test_decay_differential.rs with 8
parameterised tests that compare decay_fixed() against a libm f64
reference across the full documented parameter space (t ∈ [0,365 days],
λ ∈ [0.0001, 0.5]). Covers: zero-lambda short-circuit, per-axis sweeps,
an 11×12 full 2-D grid, horizon-clamping invariant, strict monotonicity
in age, zero-age boundary (must return SCALE exactly), Taylor/saturation
boundary at x=5, and bounded truncation error (±0.15 % of SCALE).

hartz0#268 – Canonical BLS12-381 scalar field validation in decode_proof
In contracts/scoregate-score/src/verkle.rs, add the scalar field modulus
r as BLS12_381_SCALAR_MODULUS_R and an is_canonical_field_element() predicate.
decode_proof now returns None if any of the three extracted field elements
(z, v, witness) are ≥ r, closing the proof-malleability window where two
distinct byte encodings represent the same mathematical value.

hartz0#269 – Exhaustive negative test vectors for Bulletproof inner-product argument
Append 29 new #[test] functions to test_zk_range_proof.rs organised into
9 categories: corrupted L[i]/R[i] curve points (all 3 rounds, x and y),
zeroed-out identity substitutions, L↔R round-level swaps, truncated and
extended transcripts (empty / 256 B / 752 B / 801 B), non-canonical
Fiat-Shamir challenge injection via high-bit flips on L[0]/R[0], zero and
swapped terminal scalars a/b, all four outer polynomial commitments
A/S/T1/T2, and all three inner scalars tx/taux/mu. A local macro replaces
the previous unsafe-transmute fixture helper.

hartz0#274 – AggregateRiskScore, ScoreSubmission, BatchAttestation in schema-gen
tools/schema-gen/src/lib.rs:
- Export AGGREGATE_RISK_SCORE_NAME, SCORE_SUBMISSION_NAME, BATCH_ATTESTATION_NAME
  constants and *_SCHEMA_FILE / *_TYPESCRIPT_FILE / *_PYTHON_FILE filename
  constants for each new type.
- Add native_aggregate_risk_score_struct(), native_score_submission_struct(),
  native_batch_attestation_struct() extraction functions (native + WASM paths)
  backed by a shared wasm_named_struct() / into_named_struct() helper that
  replaces the single-type into_risk_score_struct().
- Extend risk_domain_range() to cover aggregate_score and max_pair_score on
  AggregateRiskScore (same [0,100] domain as RiskScore fields).
- Add tests_extended module: 20 new tests verifying field lists, bounded-field
  constraints, unbounded fields, JSON Schema / TypeScript / Python output,
  cross-type provenance headers, and WASM error paths for all three new types.
tools/schema-gen/src/main.rs:
- Load all four structs from native or WASM source.
- Emit 4×3 = 12 artifact files (schema + ts + py per type).
- Update --help text and success message.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants