Skip to content

Commit

Permalink
remove debugs
Browse files Browse the repository at this point in the history
  • Loading branch information
marino39 committed Feb 2, 2024
1 parent 2437f34 commit d84f281
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
8 changes: 0 additions & 8 deletions intents/intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,8 @@ func (intent *Intent) isValidSECP256R1Session(session string, signature string)

func (intent *Intent) isValidSignature(session string, signature string) bool {
if intent.isValidSECP256R1Session(session, signature) {
fmt.Println("isValidSignatureSECP256R1")
return intent.isValidSignatureSECP256R1(session, signature)
} else {
fmt.Println("isValidSignatureSECP256R1")
return intent.isValidSignatureSPECP256K1(session, signature)
}
}
Expand Down Expand Up @@ -168,9 +166,6 @@ 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 {
fmt.Println("session: ", session)
fmt.Println("signature: ", signature)

// session
sessionBuff := common.FromHex(session[3:])

Expand All @@ -179,7 +174,6 @@ func (intent *Intent) isValidSignatureSECP256R1(session string, signature string
// NOTE: no way to convert ecdh pub key into elliptic pub key?
x, y := elliptic.Unmarshal(elliptic.P256(), sessionBuff)
if x == nil || y == nil {
fmt.Println("not valid x,y")
return false
}

Expand All @@ -191,13 +185,11 @@ func (intent *Intent) isValidSignatureSECP256R1(session string, signature string

// message hash
messageHash, _ := intent.Hash()
fmt.Println("messageHash: ", messageHash)
messageHash2 := sha256.Sum256(messageHash)

// signature
signatureBytes := common.FromHex(signature[3:])
if len(signatureBytes) != 64 {
fmt.Println("not valid signature bytes")
return false
}

Expand Down
4 changes: 2 additions & 2 deletions intents/packets/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"time"
)

// allowedTimeDrift is the amount of time in seconds that a packet can be
// issued in the future or expired in the past and still be considered valid.
const allowedTimeDrift = 5

var (
Expand All @@ -24,10 +26,8 @@ func (p *BasePacket) IsValid() (bool, error) {
if p.Code == "" {
return false, ErrInvalidPacketCode
} else if p.Issued > now+allowedTimeDrift {
fmt.Println("issued err", p.Issued, now+allowedTimeDrift)
return false, ErrorPackedIssuedInFuture
} else if p.Expires < now-allowedTimeDrift {
fmt.Println("expired err", p.Issued, now+allowedTimeDrift)
return false, ErrorPacketExpired
}
return true, nil
Expand Down

0 comments on commit d84f281

Please sign in to comment.