Cryptographic signature algorithms: ECDSA, Ed25519

Overview

RustCrypto: signatures Project Chat dependency status

Support for digital signatures, which provide authentication of data using public-key cryptography.

All algorithms reside in the separate crates and implemented using traits from the signature crate.

Crates are designed so they do not require the standard library (i.e. no_std) and can be easily used for bare-metal or lightweight WebAssembly programming.

Crates

Name Algorithm Crates.io Documentation Build
ecdsa ECDSA crates.io Documentation ecdsa build
ed25519 Ed25519 crates.io Documentation ed25519 build

Usage

Crates functionality is expressed in terms of traits defined in the signature crate.

License

All crates licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Comments
  • [WIP]Add dsa encryption and decryption algorithm

    [WIP]Add dsa encryption and decryption algorithm

    The rough outline of the algorithm is now completed. There is also a lack of test files and detailed modifications. Rust is too difficult. If there is something wrong, please point it out.

    opened by QiangHeisenberg 30
  • dsa: expose signing and verifying of prehashed hash value

    dsa: expose signing and verifying of prehashed hash value

    Expose the ability for the user to provide a prehashed hash-value for signing/verification. In rare cases, this is needed in other protocols. I have attempted to solve this with a custom Digest implementation, but eventually ran into (forced) finalization which affects the hash value.

    opened by cobratbq 22
  • RSA signature concerns

    RSA signature concerns

    In RSA, there are multiple schemes to sign/verify, mainly PKCS1 v1.5 and PSS (although others exists). I was looking at how to integrate signature into the RSA crate, and was a bit confused at the lack of a Padding argument or type in Signer/Verifier. Is the idea to implement Verifier on a type that is already aware of the padding scheme?

    opened by roblabla 20
  • Digestable signatures

    Digestable signatures

    Adds a marker trait for Signature types computable as S(H(m)) where:

    • S: signature algorithm
    • H: hash (a.k.a. digest) function
    • m: message

    For signature types that implement this trait, a blanket impl of Signer will be provided for all types that impl signature::digest::Signer.

    opened by tarcieri 19
  • DSA: `Verifier` trait not implemented

    DSA: `Verifier` trait not implemented

    Hi,

    I'm in a case where I need to verify a signature done on a whole &[u8] rather than a digest and I see that the relevant method is in the Verifier trait but it is not implemented anywhere in the dsa crate.

    Is that an oversight or it is something just waiting for a contribution? Or am I missing something?

    Regards,

    opened by Geobert 17
  • dsa: implement `Signer` and `Verifier` using SHA-256 as default

    dsa: implement `Signer` and `Verifier` using SHA-256 as default

    In follow-up of discussion in #520: a minimal implementation for Signer and Verifier using SHA-256 for digests. The issue discusses possible options of introducing the OID, however this is not part of this implementation.

    opened by cobratbq 14
  • Signing and verification traits

    Signing and verification traits

    This PR contains a number of commits adding a set of traits for creating and verifying digital signatures.

    I would suggest reviewing them commit-by-commit:

    • 1f7efa6: Sign trait
    • 9fd884c: Verify trait
    • c438c2c: SignDigest and VerifyDigest
    • f5e2db8: SignSha256, SignSha384, SignSha512, VerifySha256, VerifySha384, VerifySha512

    All traits are bounded by Send + Sync to ensure signers and verifiers are thread safe. Libraries which provide access to HSMs will need to e.g. Mutex guard access to the underlying device.

    opened by tarcieri 14
  • Change HmacDrbg to support variable output size

    Change HmacDrbg to support variable output size

    This is simply a matter of iterating the hashing of self.v until sufficient output bytes have been produced.

    This is necessary for the upcoming DSA implementation.

    opened by rvolgers 11
  • ecdsa: prehash must receive zero-pads on left

    ecdsa: prehash must receive zero-pads on left

    This is a fix for the issue I mentioned at https://github.com/RustCrypto/signatures/pull/534#discussion_r980613066. I believe the present implementation of prehash_to_field_bytes can't interop with OpenSSL (at least but should be the same for other crypto libraries)...

    Description

    prehash_to_field_bytes was zero-padding on the right of the byte sequence but this must be done on the left because the output is evaluated as a integer encoded in big-endian, and its integer representation should be stable regardless of sequence length.

    This behavior is defined on various documents including RFC6979 Section 2.3.2., SEC 1 Section 2.3.8., NIST FIPS 186-4 Appendix C.2.1.

    • https://datatracker.ietf.org/doc/html/rfc6979#section-2.3.2
    • https://www.secg.org/sec1-v2.pdf
    • https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.186-4.pdf

    Verification

    I used the following code to test signing with ecdsa crate and verify with OpenSSL:

    use digest::{Digest, FixedOutput};
    use ecdsa::signature::hazmat::PrehashSigner;
    use elliptic_curve::sec1::ToEncodedPoint;
    use openssl::nid::Nid;
    
    const DATA: &str = "data to sign";
    
    fn main() {
        let pkey = p384::SecretKey::random(&mut rand::thread_rng());
        let signing_key = ecdsa::SigningKey::from(&pkey);
    
        let digest = sha2::Sha256::digest(DATA);
        let signature = signing_key.sign_prehash(&digest).unwrap();
    
        //---------//
    
        let point_sec1 = pkey.public_key().to_encoded_point(false).to_bytes();
        let signature_der = signature.to_der().to_bytes();
    
        //---------//
    
        let mut ossl_bn_ctx = openssl::bn::BigNumContext::new().unwrap();
        let ossl_curve = openssl::ec::EcGroup::from_curve_name(Nid::SECP384R1).unwrap();
        let ossl_point =
            openssl::ec::EcPoint::from_bytes(&ossl_curve, &point_sec1, &mut ossl_bn_ctx).unwrap();
        let ossl_public_key = openssl::ec::EcKey::from_public_key(&ossl_curve, &ossl_point).unwrap();
    
        let ossl_signature = openssl::ecdsa::EcdsaSig::from_der(&signature_der).unwrap();
        assert!(ossl_signature.verify(&digest, &ossl_public_key).unwrap());
    }
    

    this patch fixes the crate not to fail the above code.

    opened by sorah 10
  • Bump `signature` to 2.0.0-pre

    Bump `signature` to 2.0.0-pre

    Implements the proposed breaking changes to the signature crate from https://github.com/RustCrypto/traits/pull/1141

    Most notably the Signature trait has been replaced with a SignatureEncoding trait which permits an internally structured signature representation.

    opened by tarcieri 9
  • Renaming `ecdsa::{SigningKey, VerifyKey}`

    Renaming `ecdsa::{SigningKey, VerifyKey}`

    Presently the signing and verification key types are named SigningKey and VerifyKey. These are a bit inconsistent with each other grammatically. Per a Twitter straw poll, in particular people seem to dislike the current names.

    Some potential alternatives:

    • ecdsa::{SignKey, VerifyKey}
    • ecdsa::{SigningKey, VerifyingKey}
    • ecdsa::key::{Sign, Verify}
    ecdsa 
    opened by tarcieri 8
  • Release tracking issue for `signature` 2.0-dependent crates

    Release tracking issue for `signature` 2.0-dependent crates

    We're getting close to ready to cut a final release of signature v2.0.0: https://github.com/RustCrypto/traits/issues/1171

    This is a tracking and discussion issue for any final changes before releasing the following:

    • [ ] dsa v0.5.0
    • [ ] ecdsa v0.15.0
    • [ ] ed25519 v2.0.0
    opened by tarcieri 0
  • ecdsa: `VerifyingKey::recover_*` should handle `R.x` overflowing curve's order

    ecdsa: `VerifyingKey::recover_*` should handle `R.x` overflowing curve's order

    The r scalar component of an ECDSA signature is computed by lifting the affine x-coordinate of the curve point 𝑹 = 𝑘×𝑮 into an integer and reducing it modulo the curve's order into an element of the scalar field.

    Though occurring infrequently (sometimes with a vanishingly small probability), this condition results in RecoveryId values of 2 or 3.

    Presently only RecoveryId values of 0 or 1 are supported, and the others will result in an error when recovering the verifying key.

    opened by tarcieri 0
  • ecdsa: compute `RecoveryId` in generic `SignPrimitive` implementation

    ecdsa: compute `RecoveryId` in generic `SignPrimitive` implementation

    The main thing needed to implement this is access to R.y so we can check whether or not it's odd when computing the RecoveryId.

    Related: https://github.com/zkcrypto/group/issues/30

    opened by tarcieri 0
Owner
Rust Crypto
Cryptographic algorithms written in pure Rust
Rust Crypto
ECDSA Signature Server

Simple REST API used for serving ECDSA signatures to prevent automation software from minting NFTs in bulk.

Jonathan 3 Nov 30, 2022
An ECDSA threshold signature algorithm implemented in Rust.

Open TSS This project is a Rust implementation of multi-party {t,n}-threshold signature scheme(TSS). The current version of this library supports ECDS

LatticeX Foundation 64 Dec 17, 2022
Lockstitch is an incremental, stateful cryptographic primitive for symmetric-key cryptographic operations in complex protocols.

Lockstitch is an incremental, stateful cryptographic primitive for symmetric-key cryptographic operations (e.g. hashing, encryption, message authentication codes, and authenticated encryption) in complex protocols.

Coda Hale 3 Dec 27, 2022
Fast and efficient ed25519 signing and verification in Rust.

ed25519-dalek Fast and efficient Rust implementation of ed25519 key generation, signing, and verification in Rust. Documentation Documentation is avai

dalek cryptography 563 Dec 26, 2022
A (mostly) pure-Rust implementation of various cryptographic algorithms.

Rust-Crypto A (mostly) pure-Rust implementation of various common cryptographic algorithms. Rust-Crypto seeks to create practical, auditable, pure-Rus

null 1.2k Dec 27, 2022
Multy-party threshold ECDSA Substrate node

Webb DKG ??️ The Webb DKG ??‍✈️ ⚠️ Beta Software ⚠️ Running the DKG Currently the easiest way to run the DKG is to use a 3-node local testnet using dk

webb 42 Dec 19, 2022
Two-party and multi-party ECDSA protocols based on class group with Rust

CG-MPC-ECDSA This project aims to implement two-party and multi-party ECDSA protocols based on class group with Rust. It currently includes schemes de

LatticeX Foundation 16 Mar 17, 2022
Pure Rust implementation of the Leighton Micali Signature scheme.

Leighton-Micali Hash-Based Signatures LMS implementation in Rust according to the IETF RFC 8554. This implementation is binary compatible with the ref

Fraunhofer AISEC 6 Jun 2, 2022
specs & benchmarks for the ZPrize 3 - High Throughput Signature Verification

Zprize: High Throughput Signature Verification How fast do you think you can verify our ECDSA signatures on Aleo? This year's Zprize is winner-take-al

null 6 Oct 21, 2023
dWallet Network, a composable modular signature network is the home of dWallets

Welcome to dWallet Network dWallet Network, a composable modular signature network is the home of dWallets. A dWallet is a noncollusive and massively

dWallet Labs 8 Feb 26, 2024
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Cossack Labs 1.6k Dec 30, 2022
Sodium Oxide: Fast cryptographic library for Rust (bindings to libsodium)

sodiumoxide |Crate|Documentation|Gitter| |:---:|:-----------:|:--------:|:-----:|:------:|:----:| |||| NaCl (pronounced "salt") is a new easy-to-use h

sodiumoxide 642 Dec 17, 2022
Collection of cryptographic hash functions written in pure Rust

RustCrypto: hashes Collection of cryptographic hash functions written in pure Rust. All algorithms reside in the separate crates and implemented using

Rust Crypto 1.2k Jan 8, 2023
Modern Cryptographic Firmware

Trussed® Modern Cryptographic Firmware Status Very much WIP. Actively developed. Unstable APIs.

Trussed® 300 Dec 16, 2022
The underlying cryptographic primitives for Manta Ecosystem

manta crypto The underlying cryptography that manta ecosystem relies on. It comes with the following traits: checksum: definitions for message digest.

Manta Network 10 Nov 10, 2021
Secure storage for cryptographic secrets in Rust

secrets secrets is a library to help Rust programmers safely held cryptographic secrets in memory. It is mostly an ergonomic wrapper around the memory

Stephen Touset 165 Dec 22, 2022
Pure Rust implementation of the RNCryptor cryptographic format by Rob Napier

rncryptor Rust Implementation of the RNCryptor spec This library implements the specification for the RNCryptor encrypted file format by Rob Napier. d

null 7 Jun 29, 2022
Pure-Rust traits and utilities for constant-time cryptographic implementations.

subtle Pure-Rust traits and utilities for constant-time cryptographic implementations. It consists of a Choice type, and a collection of traits using

dalek cryptography 196 Dec 13, 2022
Cryptographic Primitive Code Generation by Fiat

Fiat-Crypto: Synthesizing Correct-by-Construction Code for Cryptographic Primitives Building This repository requires Coq 8.11 or later. Note that if

Programming Languages and Verification Group at MIT CSAIL 538 Jan 7, 2023