Comments (6)
Although you seem to have different values, both are legal results
if (s > HIGH_NUMBER && canonical) {
adjustedS = CURVE.n - s;
recovery ^= 1;
}
https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki#Low_S_values_in_signatures
Line 975 in 57cdd6d
from noble-secp256k1.
Yeah, maybe switch canonical
flag of sign
from noble-secp256k1.
Instead of using Message from slice in rust, can you try this:
let message = Message::from_hashed_data::sha256::Hash("madoka".as_bytes());
from noble-secp256k1.
Thank you for reply.
Still can't match the value.
let secp = Secp256k1::new();
let secret_key = SecretKey::from_str("f7ea2341e4b1f1dc438c43725e8bebdb8d3815a47651d2312f431793b66f6994").unwrap();
let message = Message::from_hashed_data::<sha256::Hash>("madoka".as_bytes());
let js_public_key = PublicKey::from_str("04458eb1d8af007f821f7f50405d844171c0c55c389a87a3944ddda5dbe4d51b62d8cb182e2243750458a42894abb2e6f91bff6415523650adf45fadf2e01543c3").unwrap();
let js_sig = Signature::from_str("30450220617dd27ff185e0b8d0904e3ccb4215a4ba2e22d165439365a4a3516b400e8a3a022100e20c366399e11322a1e56b897c339e6d764fca5c9cee9f3fc0370d597c8eb680").expect("compact signatures are 64 bytes; DER signatures are 68-72 bytes");
let rust_public_key = PublicKey::from_secret_key(&secp, &secret_key);
let rust_sig = secp.sign(&message, &secret_key);
println!("{:?}", message);
println!("{:?}", secret_key);
println!("{:?}", js_public_key);
println!("{:?}", js_sig);
println!("-------");
println!("{:?}", rust_public_key);
println!("{:?}", rust_sig);
output:
Message(9e71e1c1f3f5d45d42669dc0c191d58ee5c90ff69a8011fc34c66f375ba46a7e)
SecretKey(f7ea2341e4b1f1dc438c43725e8bebdb8d3815a47651d2312f431793b66f6994)
PublicKey(621bd5e4dba5dd4d94a3879a385cc5c07141845d40507f1f827f00afd8b18e45c34315e0f2ad5ff4ad5036521564ff1bf9e6b2ab9428a458047543222e18cbd8)
30450220617dd27ff185e0b8d0904e3ccb4215a4ba2e22d165439365a4a3516b400e8a3a022100e20c366399e11322a1e56b897c339e6d764fca5c9cee9f3fc0370d597c8eb680
-------
PublicKey(621bd5e4dba5dd4d94a3879a385cc5c07141845d40507f1f827f00afd8b18e45c34315e0f2ad5ff4ad5036521564ff1bf9e6b2ab9428a458047543222e18cbd8)
30440220617dd27ff185e0b8d0904e3ccb4215a4ba2e22d165439365a4a3516b400e8a3a02201df3c99c661eecdd5e1a947683cc6191445f128a125a00fbff9b513353a78ac1
from noble-secp256k1.
Noble-secp is tested through tons of test vectors from different libraries, so my guess is that somewhere you're doing something differently between node.js and Rust.
from noble-secp256k1.
Switching to the canonical flag was successful.
Thank you for your warm help.
from noble-secp256k1.
Related Issues (20)
- Hex private keys should be more permissive. HOT 3
- Need a new function for a recovery(v) for HSM
- Upgrade to v2 causes etc.hmacSha256Sync not set HOT 1
- How do I initialize a Signature with the v2? HOT 3
- Non-https website don't have subtle property in window.crypto HOT 1
- 33bytes PK? (Migrating from curves => secp256k1) HOT 4
- Got Error [ERR_REQUIRE_ESM] on import HOT 1
- why secp256k1.utils.randomPrivateKey() produce a 32 bytes key? HOT 1
- Is it possible to use sha3_256 for secp256k1 HOT 2
- SyntaxError with @noble/secp256k1 in React Native 0.67.4 HOT 1
- What `xOnlyPointFromPoint()` equivalent would look like? HOT 1
- Signatures will randomly return as invalid. HOT 1
- nodeCrypto is truthy when disabled HOT 6
- Backwards compatbility with secp256k1-node HOT 3
- 1.7.1: `Point.add` is not throwing for "1 + -1 == 0/Infinity" HOT 3
- Removed v2 code snippets HOT 4
- Is this compatible with the elliptic package? HOT 4
- [doc] privateKeyTweakAdd and publicKeyTweakAdd for HD Wallets HOT 3
- Suggestion: Use globalThis.crypto instead of node crypto for cross-platform compatibility. HOT 2
- Generate seed phrase from private key 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 noble-secp256k1.