Skip to content

K0 Fix C: SC-auth via verify_sig — owner auth at ringsize>=4 (fixes #97, stacks on #84) - #98

Closed
liqdmetal wants to merge 3 commits into
DEROFDN:community-devfrom
liqdmetal:feature/k0-fix-c
Closed

K0 Fix C: SC-auth via verify_sig — owner auth at ringsize>=4 (fixes #97, stacks on #84)#98
liqdmetal wants to merge 3 commits into
DEROFDN:community-devfrom
liqdmetal:feature/k0-fix-c

Conversation

@liqdmetal

Copy link
Copy Markdown

Summary

The last piece of the K0 sequence: once verify_sig (DVM v9, PR #84) lets a contract verify Ed25519 signatures in encrypted SCDATA, owner-gated entrypoints no longer need ringsize 2 — the signer is authorized by signature, not by ringsize-2 ring exposure. This PR is the wallet-side half plus the end-to-end demo.

Why it completes K0

The ringsize-2 ring exposes the signer by design. The K0 package removes every legitimate use:

PR Fix Effect
#80 A wallet warns on ringsize 2 (non-consensus)
#82 B1 consensus min-ring-4 for NORMAL/BURN
#91 B2 ringsize-2 SC_TX only for contracts that declare SIGNER()
#84 C (intrinsic) verify_sig — signature verification in the VM
this C (wallet+demo) owner auth by signature at ringsize ≥ 4

After this, ringsize 2 has no legitimate remaining use — the last reason it existed (owner-gated contracts needing SIGNER() at ringsize 2) is gone.

The implementation

walletapi/sc_auth.go — the wallet-side helper:

  • SCAuthKey: app-level Ed25519 keypair. DERO spend keys are bn256 scalars, so SC-auth is a separate key, persisted by the wallet.
  • SignSCData: builds + signs the call message domain:scid:entrypoint:args, bound to the call context so a signature can't be replayed onto another entrypoint or contract.
  • VerifySCData: client-side mirror of the contract's verify_sig check (self-check before broadcast).

dvm/fixc_auth_test.go — the full Fix C flow in the simulator:

  • install an owner-gated contract with the owner's Ed25519 pubkey
  • wallet signs the call message
  • the contract's verify_sig authorizes at ringsize ≥ 4
  • attacker key rejected · tampered signature rejected · state transition verified

walletapi/sc_auth_test.go — direct unit tests for the helper (round-trip, tamper/wrong-key/malformed rejection, message convention + domain binding) that the dvm simulator test cannot reach due to the dvm↔walletapi import cycle.

How a contract uses it

Function OwnerAction(nonce String, pubkey String, sig String) Uint64
	5 version("9.0.0")
	10 LET msg = "relayos:" + SCID() + ":OwnerAction:" + nonce
	20 IF verify_sig(pubkey, msg, sig) != 1 THEN GOTO 900
	30 IF pubkey != LOAD("owner") THEN GOTO 900
	40 STORE("authorized", 1)
	50 RETURN 0
	900 RETURN 1
End Function

The caller signs domain:scid:entrypoint:nonce with the owner's Ed25519 key at ringsize ≥ 4 — no SIGNER(), no ringsize-2 exposure, and the caller stays anonymous (only the signature proves authorization).

Relationship


Branch: feature/k0-fix-c in the fork liqdmetal/derohe-improvements-by-liqdmetal (stacked on feature/dvm-v9-intrinsics). Carries the build-manifest fix (go.mod/go.sum).

…ives + ec_mul + verify_adaptor

One reviewable package replacing three stacked PRs (DEROFDN#84 v9, DEROFDN#105 ec_mul,
DEROFDN#113 verify_adaptor):

v9 (>=9.0.0): verify_sig (Ed25519 auth in SCDATA), hash_to_point,
pedersen_commit / verify_commit (confidential settlement), asset_balance
(SC reads own balance), ec_add (homomorphic accumulation).

ec_mul (>=9.0.0, I3): bn256 G1 scalar multiplication — homomorphic pair
of ec_add; strict x<p decode (rejects off-curve encodings).

verify_adaptor (>=10.0.0, I4): Schnorr adaptor-signature verification —
the cross-chain atomic primitive; strict point decode + low-s scalar
(non-malleable).

Tests: verify_sig (unit + version gate), ec_mul (homomorphic pair,
composition, identity), verify_adaptor (valid/wrong-key/tamper/malformed),
pedersen, hash_to_point, asset_balance, ec_add, + 2 wargame (scalar
malleability, non-canonical point).
…ics)

Ed25519 SC-auth keypair + SignSCData (domain:scid:entrypoint:args) +
VerifySCData. Gated contracts authorize via signature at ringsize>=4 —
removes the last legitimate use of ringsize-2 / SIGNER().
@liqdmetal

Copy link
Copy Markdown
Author

Superseded by PR #128 — Fix C (SC-auth via verify_sig) is now folded into the consolidated intrinsics package, since it builds directly on the verify_sig intrinsic.

@liqdmetal liqdmetal closed this Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant