Skip to content

Commit

Permalink
added Equal() for public key comparision
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Jul 30, 2024
1 parent 162d3ea commit 04fc5fc
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions hppk.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ type KEM struct {
Q *big.Int
}

// Equal checks if two public keys are equal
func (pub *PublicKey) Equal(other *PublicKey) bool {
if len(pub.P) != len(other.P) || len(pub.Q) != len(other.Q) {
return false
}

for i := 0; i < len(pub.P); i++ {
if pub.P[i].Cmp(other.P[i]) != 0 {
return false
}
}

for i := 0; i < len(pub.Q); i++ {
if pub.Q[i].Cmp(other.Q[i]) != 0 {
return false
}
}

return true
}

// GenerateKey generates a new HPPK private key with the given order and default prime number.
func GenerateKey(order int) (*PrivateKey, error) {
// Ensure the order is at least 5
Expand Down

0 comments on commit 04fc5fc

Please sign in to comment.