Comments (2)
@alistair23 please reopen if you think thereโs still an issue
from elliptic-curves.
Note that the implementation in the p256
crate passes this test vector from RFC6979:
https://tools.ietf.org/html/rfc6979#appendix-A.2.5
curve: NIST P-256
private key:
x = C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721
With SHA-256, message = "sample":
k = A6E3C57DD01ABE90086538398355DD4C3B17AA873382B0F24D6129493D8AAD60
r = EFD48B2AACB6A8FD1140DD9CD45E81D69D2C877B56AAF991C34D0EA84EAF3716
s = F7CB1C942D657C41D436C7A1B6E29F65F3E900DBB9AFF4064DC4AB2F843ACDA8
You can find the test for this vector against the p256
implementation here:
https://github.com/RustCrypto/elliptic-curves/blob/cf65586/p256/src/ecdsa.rs#L146-L158
The signature from Python cryptography
does not match this test vector:
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import ec, utils
from cryptography.hazmat.primitives import hashes
attest = ec.derive_private_key(0xc9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721, ec.SECP256R1(), default_backend())
data = bytes([115, 97, 109, 112, 108, 101])
sig = attest.sign(data, ec.ECDSA(hashes.SHA256()))
output = utils.decode_dss_signature(sig)
print("Signature: r: " + str(hex(output[0])) + " s: " + str(hex(output[1])))
Prints:
r: 0xcfed9cfefbd61caf24b3d04f56c94c215af3597be11d27cd646786bb5360512c
s: 0x295c05ecf488ac7df05ca71bd332f868a663793aa749b622f470cc401b5f0b0f
(it's possible I adapted the example incorrectly, please double check me on that)
ECDSA signing implementations are free to choose k
as they please. You might want to check if cryptography
implements RFC6979. Whatever they're doing appears to be deterministic, but may not necessarily match RFC6979.
from elliptic-curves.
Related Issues (20)
- Update crates to the newtype `fiat-crypto` codegen
- Why are ECDSA P-384 signatures not different for the same message? HOT 1
- bign256: WideFieldElement HOT 11
- Expose `lincomb_generic` (or: Generic Linear Combination) HOT 31
- BIP-0340 Schnorr-compatible signature invalidly uses NonZeroScalar HOT 1
- RustCrypto hardening recommendation HOT 1
- RustCrypto misuse resistance recommendation HOT 2
- Expose `ProjectivePoint` value HOT 13
- Generalizing MulByGenerator for other points HOT 1
- Surprisingly slow constant time selection HOT 6
- Batch Conversion of Projective -> Affine Points HOT 19
- p521: field arithmetic implementation not working correctly HOT 8
- 256 bit Field Operation: 64 bit * 4 vs 52 bit * 5 HOT 4
- P521 `FieldElement` conversions can panic HOT 3
- k256: Linear Combanation over Dynamically Allocated Slices
- primeorder 0.13.4 update breaks p384 0.13.0 builds HOT 4
- k256 disrepency in secp256k1 key recover HOT 12
- How to convert a VerifyingKey of type FieldElement10x26 to a FieldElement5x52 type
- k256: v0.13.2 breaking verification HOT 9
- Bitwise operations for scalars HOT 5
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-curves.