Skip to content

Commit

Permalink
sm2: recover public keys
Browse files Browse the repository at this point in the history
  • Loading branch information
emmansun authored Jun 1, 2024
1 parent 63affe5 commit 7bb7903
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions sm2/sm2.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,18 +747,11 @@ func RecoverPublicKeysFromSM2Signature(hash, sig []byte) ([]*ecdsa.PublicKey, er
}

// Rx = r - e
if r.CmpGeq(e) == 0 {
// If r < e, then Rx = N - e + r
n0 := bigmod.NewNat().Set(c.N.Nat())
n0.Sub(e, c.P)
r.Add(n0, c.P)
} else {
r.Sub(e, c.P)
}
r.Sub(e, c.N)
if r.IsZero() == 1 {
return nil, ErrInvalidSignature
}
rBytes = r.Bytes(c.P)
rBytes = r.Bytes(c.N)
tmp := make([]byte, len(rBytes)+1)
copy(tmp[1:], rBytes)
compressFlags := []byte{compressed02, compressed03}
Expand Down

1 comment on commit 7bb7903

@emmansun
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

关于Rx (n, p)的case(四个公钥),不好测试,要先设法产生这样的签名。

Please sign in to comment.