Comments (7)
It is possible to generate public key for a given private key - see the code snippet below:
$ec = new \Elliptic\EC('secp256k1');
$priv_hex = "751ce088f64404e5889bf7e9e5c280b200b2dc158461e96b921df39a1dbc6635";
$pub_hex = "03a319a1d10a91ada9a01ab121b81ae5f14580083a976e74945cdb014a4a52bae6";
$priv = $ec->keyFromPrivate($priv_hex);
if ($pub_hex == $priv->getPublic(true, "hex")) {
echo "Success\n";
} else {
echo "Fail\n";
}
We described API for ECDSA, EdDSA and ECDH but indeed forgot about basic EC interface :) - to be done.
from elliptic-php.
Thank you for the replay!
And I have another question, is this elliptic-php compatible with the secp256k1 used by BitCoin?
from elliptic-php.
This library provides implementation of general Elliptic Curve algorithms, but indeed one of the predefined curves in the library is curve secp256k1
(the one used in BitCoin, Ethereum, and some other cryptocurrencies).
You can use this library e.g. to verify bitcoin message signature as shown in example here:
https://github.com/simplito/elliptic-php#verifying-bitcoin-message-signature
from elliptic-php.
Got it. Thank you so much!
from elliptic-php.
@ssmyczynski
Hi ssmyczynski, I have noticed that the publicKey returned from $priv = $ec->keyFromPrivate($priv_hex);
is just a x value, how to get the public key as '04 + x + y'?
Thank you in advance!
from elliptic-php.
$priv = $ec->keyFromPrivate($priv_hex);
$pub_hex = $priv->getPublic("hex");
instead of $priv->getPublic(true, "hex")
in which case it returns compressed representation with '02' | '03' prefix.
from elliptic-php.
wow, thank you. I didn't find this from the code. I'll try it later.
from elliptic-php.
Related Issues (20)
- signature is not canonical HOT 3
- AdMob SSV in Php
- PHP Fatal error: Uncaught Error: Class 'Elliptic\EC' not found
- Error in _projDbl for ordinary Edwards curves
- Error in recoverPubKey: Cannot initialize
- Error in verify signature: Cannot initialize
- is it possible to get a 62 hex characters private key with this library ? HOT 1
- Javascript compatible library. HOT 1
- Collisions when generating addresses HOT 1
- simplito/elliptic-php[1.0.0, ..., 1.0.9] require ext-gmp * -> it is missing from your system. Install or enable PHP's gmp extension. HOT 1
- PubKey from RAW TX
- Ethereum Signature failing HOT 3
- about EOS
- with bip44,do mnemonic to address,Unable to get: uncompressed public key / address / Y coordinate HOT 2
- jsonSerialize - php 8.1 patch HOT 1
- Big Issue when recovering a signature of a hashed message HOT 3
- curve25519 is changing private key HOT 1
- How to use smaller s value in signature and recalculate recoveryParam HOT 2
- Modernize: use sensitive parameter for keys HOT 3
- feature request: import private key from pem format (SEC1/PEM or PKCS#8/PEM) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elliptic-php.