Hi all,
I’m posting from x39Matrix (canister a6ynb-biaaa-aaaao-ba4gq-cai,
mainnet). What follows is a technical pattern + anti-pattern that
I’d like to see discussed openly here. No tokens, no fundraising,
no roadmap promises — just code, signatures, and verification.
THE ANTI-PATTERN
I keep seeing canisters expose a query endpoint that returns
hardcoded multi-line strings like:
“ECDSA: 75621f3e… TPS: 400 Compute: 0ms Sign: 0ms Status: SEALED”
These are not signatures. They are descriptions of signatures.
The function is free, deterministic, and never invokes
sign_with_ecdsa. Calling it ten thousand times costs the
canister nothing and tells the auditor nothing.
The damage is reputational, not technical: when newcomers see
“0ms ECDSA” repeated everywhere, they assume that’s what
sign_with_ecdsa does on the IC. It isn’t.
THE PATTERN
Three explicit tiers:
-
audit_b27_local(n: u64) -> AuditReport(query)
Real Merkle tree of n leaves (capped at 64), canonical SHA-256
over canonical state, exposes internal counters. Reproducible:
same n → same merkle_root_hex; different n → different output.
Fields are explicitly named:
ecdsa_local_hex // SHA-256, NOT a signature
ed25519_local_hex // SHA-256, NOT a signature
clock_logical_ns // ic_cdk::api::time(), real ns -
clock_physical_ns() -> u64(query)
Justic_cdk::api::time(). Two calls + sleep gives a real
nanosecond delta. Demonstrates that subnet time is measured,
not a logical counter that always reads 0. -
audit_full(n: u64) -> Result<SealedReport, String>(update)
Caller principal must be in a sovereign whitelist. Builds
a canonical SHA-256 message and callssign_with_ecdsa
against the management canister with the canister’s own
key_1. Returned struct exposes:
ecdsa_threshold_ic_hex // 64-byte secp256k1 sig
pubkey_hex // 33-byte compressed pubkey
message_signed_hex // 32-byte SHA-256 digest
clock_threshold_*_ns // real timing of the IC signMainnet latency: ~5–7 seconds per call. That’s the right
order of magnitude for a threshold-ECDSA round on the IC.
EXTERNAL VERIFICATION (the actual proof)
Anyone can verify offline with python-ecdsa, no IC tooling required:
from ecdsa import VerifyingKey, SECP256k1
from ecdsa.util import sigdecode_string
PUBKEY = "<pubkey_hex>"
MSG = "<message_signed_hex>"
SIG = "<ecdsa_threshold_ic_hex>"
vk = VerifyingKey.from_string(bytes.fromhex(PUBKEY), curve=SECP256k1)
vk.verify_digest(bytes.fromhex(SIG), bytes.fromhex(MSG),
sigdecode=sigdecode_string)
# silent on success, BadSignatureError on failure
Concrete sample from a real call today:
pubkey = 03989da02dad76682c8f9ed7d8d4bec81f956c64fd174532f6fb6aaefa5de6c3e4
msg = 1b68a4c06b0ac4be8e52c0aef4f44d358d1fd3046fcdba6282e6e3ac8f80b25b
sig = 52963f7c1376e62cd6318474220e98f11ca2b09c34b433b8f1680c394eac09f3
128147e2813f859c976c662324de19c116cd95eb66bc6d5647165008b43f3a06
delta = 5_768_591_055 ns (≈ 5.77 s)
Verifies VALID against secp256k1 + RFC 6979.
TWO NAMING CONVENTIONS THAT HELP
• suffix _local for canonical SHA-256 hashes
• suffix _threshold for actual sign_with_ecdsa results
Mixing them in Candid types is, in my view, the easiest way to
erode trust in sign_with_ecdsa itself.
A CLOSING REMARK
This is the third time I try to share a technical post on this
forum. The two previous ones were removed without explanation.
If this one disappears too, I’d like to know — publicly — which
forum guideline a post about threshold-ECDSA verification, with
no advertising, no token sales, no canister-id promotion, and
externally reproducible cryptographic evidence, manages to break.
If it stays up, I’m happy to share the Rust module (~250 lines,
no rust-bitcoin dep) as a reference for anyone copying the
pattern. Stress-tests on the verification snippet welcome.
-– x39Matrix