mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-14 06:59:24 +00:00
Explicitly ban the identity point as an Ethereum Schnorr public key (002)
This doesn't have a well-defined affine representation. k256's behavior, mapping it to (0, 0), means this would've been rejected anyways (so this isn't a change of any current behavior), but it's best not to rely on such an implementation detail.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use subtle::Choice;
|
||||
use group::ff::PrimeField;
|
||||
use group::{ff::PrimeField, Group};
|
||||
use k256::{
|
||||
elliptic_curve::{
|
||||
ops::Reduce,
|
||||
@@ -22,6 +22,10 @@ impl PublicKey {
|
||||
/// bounds such as parity).
|
||||
#[must_use]
|
||||
pub fn new(A: ProjectivePoint) -> Option<PublicKey> {
|
||||
if bool::from(A.is_identity()) {
|
||||
None?;
|
||||
}
|
||||
|
||||
let affine = A.to_affine();
|
||||
|
||||
// Only allow even keys to save a word within Ethereum
|
||||
|
||||
Reference in New Issue
Block a user