mirror of
https://github.com/luxwallet/connect.git
synced 2026-10-30 19:32:42 +00:00
TS verifiers: EVM, Solana, TON (ton_proof), XRP (secp256k1+ed25519), Bitcoin
(legacy + BIP-322 simple P2WPKH/P2TR) — 61 tests green, typecheck clean.
Go port (go/walletconnect): EVM + Solana via github.com/luxfi/crypto (NO
go-ethereum/ava-labs), TON/XRP/Bitcoin stubs fail-closed — 23 tests green.
IAM integration plan + drafts (integrations/iam/): canonical /v1/iam/web3/
{nonce,verify}, single-use nonce store, multi-wallet WalletLink. Found current
IAM web3 login verifies NO signature (security hole this closes).
56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
package walletconnect
|
|
|
|
import (
|
|
"crypto/ed25519"
|
|
"crypto/rand"
|
|
"encoding/base64"
|
|
"testing"
|
|
|
|
"github.com/mr-tron/base58"
|
|
)
|
|
|
|
// solanaSign produces a real ed25519 proof (base64 signature, base58 address)
|
|
// the verifier must accept. Mirrors the TS solanaSign test helper.
|
|
func solanaSign(t *testing.T, message string) (address, signature string) {
|
|
t.Helper()
|
|
pub, priv, err := ed25519.GenerateKey(rand.Reader)
|
|
if err != nil {
|
|
t.Fatalf("GenerateKey: %v", err)
|
|
}
|
|
address = base58.Encode(pub)
|
|
signature = base64.StdEncoding.EncodeToString(ed25519.Sign(priv, []byte(message)))
|
|
return address, signature
|
|
}
|
|
|
|
func randSolanaAddress(t *testing.T) string {
|
|
t.Helper()
|
|
pub, _, err := ed25519.GenerateKey(rand.Reader)
|
|
if err != nil {
|
|
t.Fatalf("GenerateKey: %v", err)
|
|
}
|
|
return base58.Encode(pub)
|
|
}
|
|
|
|
func TestVerifySolana_AcceptsValidSignature(t *testing.T) {
|
|
message := "hello solana"
|
|
address, signature := solanaSign(t, message)
|
|
if !VerifySolana(message, signature, address) {
|
|
t.Fatal("expected valid signature to verify")
|
|
}
|
|
}
|
|
|
|
func TestVerifySolana_RejectsTamperedMessage(t *testing.T) {
|
|
address, signature := solanaSign(t, "original")
|
|
if VerifySolana("tampered", signature, address) {
|
|
t.Fatal("expected tampered message to be rejected")
|
|
}
|
|
}
|
|
|
|
func TestVerifySolana_RejectsWrongAddress(t *testing.T) {
|
|
_, signature := solanaSign(t, "m")
|
|
other := randSolanaAddress(t)
|
|
if VerifySolana("m", signature, other) {
|
|
t.Fatal("expected wrong address to be rejected")
|
|
}
|
|
}
|