mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-10 14:03:46 +00:00
Implement RIP-7212/EIP-7212 according to reference implementation at https://github.com/ulerdogan/go-ethereum/pull/1 Co-authored-by: Péter Garamvölgyi <peter@scroll.io>
21 lines
402 B
Go
21 lines
402 B
Go
package secp256r1
|
|
|
|
import (
|
|
"crypto/ecdsa"
|
|
"crypto/elliptic"
|
|
"math/big"
|
|
)
|
|
|
|
// Generates appropriate public key format from given coordinates
|
|
func newPublicKey(x, y *big.Int) *ecdsa.PublicKey {
|
|
// Check if the given coordinates are valid
|
|
if x == nil || y == nil || !elliptic.P256().IsOnCurve(x, y) {
|
|
return nil
|
|
}
|
|
|
|
return &ecdsa.PublicKey{
|
|
Curve: elliptic.P256(),
|
|
X: x,
|
|
Y: y,
|
|
}
|
|
}
|