Align Go SDK Cascade Signatures with JS (Keplr) ADR-36 Format #233
+137
−33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR: Align Go SDK Cascade Signatures with JS (Keplr) ADR-36 Format
Summary
This PR updates the Go Cascade SDK to generate signatures and metadata identical to the JS SDK (Keplr). Previously, Cascade actions created via Go (
sn-api-server) produced signatures that did not match those produced by the JS SDK, even when using the same account and the same file. This caused mismatches when testing across Go and browser clients, and made it difficult to verify signatures in a unified way.Problem
The signature mismatch came from two root causes:
1. Go signed raw bytes while JS (Keplr) signed ADR-36 documents
Go used:
JS used:
which internally constructs:
{ "chain_id": "", "account_number": "0", "sequence": "0", "fee": {"gas":"0","amount":[]}, "msgs":[{"type":"sign/MsgSignData","value":{"signer": "<bech32>", "data": base64(messageBytes) }}], "memo":"" }This means:
[]byte(message)2. JS signs different message strings
Go previously signed:
layoutB64bytes (not ADR-36),indexB64,dataHashB64.So even if both sides used the same key, the signed payloads differed → signatures diverged.
What This PR Changes
✅ 1. Added full ADR-36 signing support in Go (
SignADR36String)Go now constructs ADR-36 canonical sign bytes identical to Keplr:
✅ 2. Reimplemented layout + index signature generation to match JS
Replaced raw signing with ADR-36 Keplr-compatible signing:
layoutB64using ADR-36This is now identical to JS’s
indexWithSignature.✅ 3.
GenerateStartCascadeSignatureFromFilenow matcheskeplr.signArbitrary(dataHash)Go now produces the same auth/start-cascade signature as JS for the same file and key.
✅ 4. Kept backward compatibility
Supernode validation (
VerifyIndex,VerifyLayout) already tries:So:
Result
After these changes:
Go and JS produce identical values for:
data_hashsignatures(indexSignatureFormat)authSignature(StartCascade signature)Cross-client Cascade actions work consistently.
Supernodes can process both legacy Go and modern JS signatures.