From a49658f00067cdc05161243fa8a993e5c8af3f15 Mon Sep 17 00:00:00 2001 From: Marcin Gorzynski Date: Fri, 2 Feb 2024 09:26:49 +0100 Subject: [PATCH] Add support for Intent sessions built on secp256r1 - add prefix again --- intents/intent.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/intents/intent.go b/intents/intent.go index d4e1c50..cc18c4b 100644 --- a/intents/intent.go +++ b/intents/intent.go @@ -112,7 +112,7 @@ func (intent *Intent) IsValid() bool { } func (intent *Intent) isValidSECP256R1Session(session string, signature string) bool { - return len(session) == 65 && len(signature) == 64 + return strings.HasPrefix(session, "r1:") && strings.HasPrefix(signature, "r1:") } func (intent *Intent) isValidSignature(session string, signature string) bool { @@ -155,7 +155,7 @@ func (intent *Intent) isValidSignatureSPECP256K1(session string, signature strin // isValidSignatureSPECP256K1 checks if the signature is valid for the given secp256r1 session func (intent *Intent) isValidSignatureSECP256R1(session string, signature string) bool { // session - sessionBuff := common.FromHex(session) + sessionBuff := common.FromHex(session[3:]) // public key // TODO: check if can use ecdh instead of unmarshal @@ -176,7 +176,7 @@ func (intent *Intent) isValidSignatureSECP256R1(session string, signature string messageHash2 := sha256.Sum256(messageHash) // signature - signatureBytes := common.FromHex(signature) + signatureBytes := common.FromHex(signature[3:]) if len(signatureBytes) != 64 { return false }