orangecheck 2.5.0__tar.gz → 2.5.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {orangecheck-2.5.0 → orangecheck-2.5.2}/CHANGELOG.md +16 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/PKG-INFO +1 -1
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/__init__.py +1 -1
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/pledge/envelopes.py +18 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/pledge/state.py +17 -2
- {orangecheck-2.5.0 → orangecheck-2.5.2}/pyproject.toml +1 -1
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/pledge/test_authority.py +25 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/pledge/test_delegation.py +24 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/pledge/test_vectors.py +12 -1
- {orangecheck-2.5.0 → orangecheck-2.5.2}/.gitignore +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/README.md +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/__main__.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/address.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/bond.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/canonical.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/client.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/errors.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/integrator.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/pledge/__init__.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/pledge/bond.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/pledge/canonical.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/pledge/delegation.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/pledge/resolution.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/py.typed +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/top_level.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/types.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/orangecheck/verify_sig.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/fixtures/bip137-parity.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/fixtures/bip322-js-6.1.8.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/fixtures/bip322-official-basic.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/fixtures/bip322-official-generated.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/pledge/__init__.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/pledge/test_wrap.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/test_address.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/test_bip322_official.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/test_client.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/test_client_failure_modes.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/test_conformance.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/test_integrator_vectors.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/test_ripemd160.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/test_signature_parity.py +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/index.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv01.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv02.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv03.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv04.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv05.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv06.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv07.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv08.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv09.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv10.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv11.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv12.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv13.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv14.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv15.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv16.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv17.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv18.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv19.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv20.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv21.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv22.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv23.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv24.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv25.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv26.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv27.json +0 -0
- {orangecheck-2.5.0 → orangecheck-2.5.2}/tests/vectors/tv28.json +0 -0
|
@@ -4,6 +4,22 @@ All notable changes to the **`orangecheck`** Python package. Follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
|
|
5
5
|
[Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [2.5.2] — 2026-10-22
|
|
8
|
+
|
|
9
|
+
### Fixed — an agent pledge's agent is never its swearer
|
|
10
|
+
|
|
11
|
+
As `@orangecheck/pledge-core` 3.2.2 (SPEC §7.3). `verify_pledge` refuses an
|
|
12
|
+
envelope whose `agent_address` equals `swearer.address` (`E_PLEDGE_MALFORMED`).
|
|
13
|
+
Vector `v33`.
|
|
14
|
+
|
|
15
|
+
## [2.5.1] — 2026-10-22
|
|
16
|
+
|
|
17
|
+
### Fixed — a signed outcome dated after expires_at comes too late
|
|
18
|
+
|
|
19
|
+
As `@orangecheck/pledge-core` 3.2.1 (SPEC §3.4.2, §4.4). `verify_outcome`, given
|
|
20
|
+
the pledge, refuses a signed outcome dated at or after `expires_at`, and
|
|
21
|
+
`classify_state` leaves it out. Deterministic outcomes are exempt.
|
|
22
|
+
|
|
7
23
|
## [2.5.0] — 2026-10-22
|
|
8
24
|
|
|
9
25
|
### Fixed — legacy signatures, as @orangecheck/bip322 verifies them
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: orangecheck
|
|
3
|
-
Version: 2.5.
|
|
3
|
+
Version: 2.5.2
|
|
4
4
|
Summary: Python SDK for OrangeCheck — proof of Bitcoin stake, the OC Pledge primitive, and ochk.app sign-in for your backend.
|
|
5
5
|
Project-URL: Homepage, https://ochk.io
|
|
6
6
|
Project-URL: Documentation, https://ochk.io/docs
|
|
@@ -139,7 +139,7 @@ __all__ = [
|
|
|
139
139
|
"VerificationError",
|
|
140
140
|
]
|
|
141
141
|
|
|
142
|
-
__version__ = "2.5.
|
|
142
|
+
__version__ = "2.5.2"
|
|
143
143
|
|
|
144
144
|
# OC Pledge submodule — sibling primitive for forward-looking commitments
|
|
145
145
|
# bound to a Bitcoin address. Imported here so consumers can write:
|
|
@@ -511,6 +511,12 @@ def _check_pledge_shape(env: dict[str, Any]) -> Optional[VerifyErr]:
|
|
|
511
511
|
"E_PLEDGE_MALFORMED",
|
|
512
512
|
"envelope.agent_address required when via_delegation present",
|
|
513
513
|
)
|
|
514
|
+
# SPEC §7.3: the agent is never the swearer. Neither field is in the id.
|
|
515
|
+
if env.get("agent_address") == swearer.get("address"):
|
|
516
|
+
return _err(
|
|
517
|
+
"E_PLEDGE_MALFORMED",
|
|
518
|
+
"envelope.agent_address must differ from swearer.address (§7.3)",
|
|
519
|
+
)
|
|
514
520
|
# SPEC §3.6 vs §7.3 contradiction documented in pledge-core: under
|
|
515
521
|
# §7.3 the sig.pubkey is informational; the verifier uses
|
|
516
522
|
# agent_address as the BIP-322 key. We accept either reading.
|
|
@@ -752,6 +758,18 @@ def _check_resolver_authorized(
|
|
|
752
758
|
"E_OUTCOME_RESOLVER_UNAUTHORIZED",
|
|
753
759
|
f"resolved_by ({resolved_by}) is not the pledge's counterparty ({pledge.counterparty})",
|
|
754
760
|
)
|
|
761
|
+
# A signed outcome comes within the pledge's window (§3.4.2, §11.10).
|
|
762
|
+
# resolved_at is the counterparty's own claim, so this catches only an
|
|
763
|
+
# honestly dated late one.
|
|
764
|
+
try:
|
|
765
|
+
late = _parse_utc(env.get("resolved_at")) >= _parse_utc(pledge.expires_at) # type: ignore[arg-type]
|
|
766
|
+
except (TypeError, ValueError):
|
|
767
|
+
return _err("E_OUTCOME_MALFORMED", f"resolved_at ({env.get('resolved_at')}) is not ISO 8601 UTC")
|
|
768
|
+
if late:
|
|
769
|
+
return _err(
|
|
770
|
+
"E_OUTCOME_MALFORMED",
|
|
771
|
+
f"resolved_at ({env['resolved_at']}) is not before the pledge's expires_at ({pledge.expires_at})",
|
|
772
|
+
)
|
|
755
773
|
return None
|
|
756
774
|
|
|
757
775
|
# Every other mechanism resolves from public state, so the only legitimate
|
|
@@ -60,8 +60,16 @@ def classify_state(
|
|
|
60
60
|
swearer = (pledge.get("swearer") or {}).get("address")
|
|
61
61
|
# An outcome dated after `now` describes a resolution that has not happened
|
|
62
62
|
# yet, so it does not classify the pledge until then.
|
|
63
|
+
# A signed outcome dated at or after expires_at comes too late (§3.4.2);
|
|
64
|
+
# anyone can still compute a deterministic one after it.
|
|
65
|
+
expires_at_ms = _parse_utc(pledge["expires_at"])
|
|
66
|
+
|
|
63
67
|
def in_force(o: dict[str, Any]) -> bool:
|
|
64
|
-
return
|
|
68
|
+
return (
|
|
69
|
+
o.get("pledge_id") == pledge_id
|
|
70
|
+
and not _dated_after(o.get("resolved_at"), now_ms)
|
|
71
|
+
and (o.get("resolved_by") == "deterministic" or _dated_before(o.get("resolved_at"), expires_at_ms))
|
|
72
|
+
)
|
|
65
73
|
|
|
66
74
|
if outcome is not None and not in_force(outcome):
|
|
67
75
|
outcome = None
|
|
@@ -84,7 +92,6 @@ def classify_state(
|
|
|
84
92
|
if outcome is not None:
|
|
85
93
|
return outcome.get("outcome") # type: ignore[return-value]
|
|
86
94
|
|
|
87
|
-
expires_at_ms = _parse_utc(pledge["expires_at"])
|
|
88
95
|
if now_ms >= expires_at_ms:
|
|
89
96
|
return "expired_unresolved"
|
|
90
97
|
|
|
@@ -114,6 +121,14 @@ def _normalize_resolves_at(
|
|
|
114
121
|
return None
|
|
115
122
|
|
|
116
123
|
|
|
124
|
+
def _dated_before(iso: Any, ms: int) -> bool:
|
|
125
|
+
"""True when ``iso`` is a timestamp earlier than ``ms``."""
|
|
126
|
+
try:
|
|
127
|
+
return _parse_utc(iso) < ms
|
|
128
|
+
except (TypeError, ValueError):
|
|
129
|
+
return False
|
|
130
|
+
|
|
131
|
+
|
|
117
132
|
def _dated_after(iso: Any, now_ms: int) -> bool:
|
|
118
133
|
"""True when ``iso`` is later than ``now_ms``, or not a timestamp at all."""
|
|
119
134
|
try:
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "orangecheck"
|
|
7
|
-
version = "2.5.
|
|
7
|
+
version = "2.5.2"
|
|
8
8
|
description = "Python SDK for OrangeCheck — proof of Bitcoin stake, the OC Pledge primitive, and ochk.app sign-in for your backend."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
|
@@ -326,6 +326,31 @@ def test_state_ignores_a_future_dated_contradiction() -> None:
|
|
|
326
326
|
assert s == "kept"
|
|
327
327
|
|
|
328
328
|
|
|
329
|
+
def test_outcome_refuses_a_counterparty_outcome_dated_at_or_after_expiry() -> None:
|
|
330
|
+
for resolved_at in ("2026-06-15T00:00:00Z", "2026-10-21T00:00:00Z"):
|
|
331
|
+
env = _outcome(BILATERAL, outcome="broken", resolved_by=COUNTERPARTY, resolved_at=resolved_at)
|
|
332
|
+
r = verify_outcome(env, skip_signature_verification=True, pledge=pledge_input_from_dict(BILATERAL))
|
|
333
|
+
assert not r.ok and r.code == "E_OUTCOME_MALFORMED"
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
def test_outcome_still_accepts_a_deterministic_one_computed_after_expiry() -> None:
|
|
337
|
+
env = _outcome(BASE, outcome="broken", resolved_at="2026-10-21T00:00:00Z")
|
|
338
|
+
r = verify_outcome(env, skip_signature_verification=True, pledge=pledge_input_from_dict(BASE))
|
|
339
|
+
assert r.ok
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def test_state_leaves_out_a_signed_outcome_dated_after_expiry() -> None:
|
|
343
|
+
late = _outcome(BILATERAL, outcome="broken", resolved_by=COUNTERPARTY, resolved_at="2026-07-01T00:00:00Z")
|
|
344
|
+
s = classify_state(pledge=_envelope(BILATERAL), outcome=late, abandonment=None, now="2026-08-01T00:00:00Z")
|
|
345
|
+
assert s == "expired_unresolved"
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
def test_state_counts_a_deterministic_outcome_computed_after_expiry() -> None:
|
|
349
|
+
late = _outcome(BASE, outcome="broken", resolved_at="2026-07-01T00:00:00Z")
|
|
350
|
+
s = classify_state(pledge=_envelope(BASE), outcome=late, abandonment=None, now="2026-08-01T00:00:00Z")
|
|
351
|
+
assert s == "broken"
|
|
352
|
+
|
|
353
|
+
|
|
329
354
|
# ─── verify_pledge: an agent pledge needs its delegation (SPEC §7.3) ─────
|
|
330
355
|
|
|
331
356
|
|
|
@@ -183,6 +183,30 @@ def test_verify_passes_with_delegation():
|
|
|
183
183
|
assert r.ok
|
|
184
184
|
|
|
185
185
|
|
|
186
|
+
def test_verify_refuses_agent_address_equal_to_swearer():
|
|
187
|
+
# via_delegation and agent_address are outside the id, so anyone can add
|
|
188
|
+
# them to a copy of a pledge the swearer signed directly (SPEC §7.3).
|
|
189
|
+
copy = dict(_pledge(), agent_address="bc1qprincipal")
|
|
190
|
+
copy["sig"] = dict(copy["sig"], pubkey="bc1qprincipal")
|
|
191
|
+
self_delegation = _delegation({"agent": "bc1qprincipal"})
|
|
192
|
+
for kwargs in (
|
|
193
|
+
{"skip_delegation_verification": True},
|
|
194
|
+
{"delegation_lookup": lambda _id, _now: self_delegation},
|
|
195
|
+
):
|
|
196
|
+
r = verify_pledge(copy, skip_signature_verification=True, **kwargs)
|
|
197
|
+
assert not r.ok
|
|
198
|
+
assert (r.code, r.message) == (
|
|
199
|
+
"E_PLEDGE_MALFORMED",
|
|
200
|
+
"envelope.agent_address must differ from swearer.address (§7.3)",
|
|
201
|
+
)
|
|
202
|
+
audit = verify_pledge_as_of_sworn_at(
|
|
203
|
+
copy,
|
|
204
|
+
skip_signature_verification=True,
|
|
205
|
+
delegation_lookup=lambda _id, _now: self_delegation,
|
|
206
|
+
)
|
|
207
|
+
assert not audit.ok
|
|
208
|
+
|
|
209
|
+
|
|
186
210
|
def test_verify_e_delegation_not_found_when_lookup_returns_none():
|
|
187
211
|
r = verify_pledge(
|
|
188
212
|
_pledge(),
|
|
@@ -356,13 +356,24 @@ def _outcome_stub(pledge_id: str, outcome: str, resolved_at: str) -> dict[str, A
|
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
|
|
359
|
-
# ─── Shape C — malformed-input (v28)
|
|
359
|
+
# ─── Shape C — malformed-input (v28, v33) ──────────────────────────────────
|
|
360
360
|
|
|
361
361
|
|
|
362
362
|
def _run_malformed(vec: dict[str, Any]) -> None:
|
|
363
363
|
inputs = vec["inputs"]
|
|
364
364
|
expected_error = vec["expected"]["error"]
|
|
365
365
|
|
|
366
|
+
# v33: a whole envelope that verification MUST refuse.
|
|
367
|
+
if "envelope" in inputs:
|
|
368
|
+
r = verify_pledge(
|
|
369
|
+
inputs["envelope"],
|
|
370
|
+
skip_signature_verification=True,
|
|
371
|
+
skip_delegation_verification=True,
|
|
372
|
+
)
|
|
373
|
+
assert not r.ok
|
|
374
|
+
assert r.code == expected_error
|
|
375
|
+
return
|
|
376
|
+
|
|
366
377
|
class _NoopSigner:
|
|
367
378
|
def __init__(self, address: str) -> None:
|
|
368
379
|
self.address = address
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|