Comments (1)
Sorry for delay. I look into you post and everything in your example is ok. If you look futher into article you linked, you can see that in 4. point there is deterministic ECDSA signature and this output is exatly the same as your
30450220587ce0cf0252e2db3a7c3c91b355aa8f3385e128227cd8727c5f7777877ad772022100edc508b7c14891ed15ab38c687019d7ebaf5c12908cf21a83e8ae57e8c47e95c
In our lib all ECDSA signatures are generated in "deterministic" way by default. If you want to get not deterministic signature you should pass k option to sign method. K option is a function which should return BN number. If you generate signature in not determinsitic way, each signature will be different, but all these still will successfully validate. In article in 3. point there is a not deterministic signature which is almost imposible to regenerate because to achieve that you should generate the same k. Example how to generate not deterministic signature:
use Elliptic\EC;
use BN\BN;
$message = "30f10a6468b7d98257af63fb40dfcf2cefe991346fd37c67cf7b51ff8d4404d3";
$privKeyHex = "0ecd20654c2e2be708495853e8da35c664247040c00bd10b9b13e5e86e6a808d";
$pubKeyHex = "042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9";
$ec = new EC('secp256k1');
$privKey = $ec->keyFromPrivate($privKeyHex);
$pubKey = $ec->keyFromPublic($pubKeyHex, "hex");
$notDeterministicOptions = array(
"k" => function() {
return new BN(openssl_random_pseudo_bytes(32), 256);
}
);
$determinsiticSignature = $privKey->sign($message);
echo "Determinsitic signature: " . $determinsiticSignature->toDER("hex") . "\n";
echo "Validating determinisitic signature: " . ($pubKey->verify($message, $determinsiticSignature) ? "Success" : "Failure") . "\n";
$notDeterminsiticSignature1 = $privKey->sign($message, $notDeterministicOptions);
echo "Not determinsitic signature no. 1: " . $notDeterminsiticSignature1->toDER("hex") . "\n";
echo "Validating not determinisitic signature no. 1: " . ($pubKey->verify($message, $notDeterminsiticSignature1) ? "Success" : "Failure") . "\n";
$notDeterminsiticSignature2 = $privKey->sign($message, $notDeterministicOptions);
echo "Not determinsitic signature no. 2: " . $notDeterminsiticSignature2->toDER("hex") . "\n";
echo "Validating not determinisitic signature no. 2: " . ($pubKey->verify($message, $notDeterminsiticSignature2) ? "Success" : "Failure") . "\n";
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.