Ursa - Hyperledger Ursa is a shared cryptography library

Related tags

Cryptography ursa
Overview

HYPERLEDGER URSA

Ursa CI Build status CII Best Practices

Introduction

Ursa was created because people in the Hyperledger community realized that it would save time and effort and improve security if we all collaborated on our cryptographic code. Since cryptographic APIs are relatively straightforward to define, it would be possible for many different projects to utilize the same code without too much difficulty.

First and foremost, we hope in the long run that Ursa provides open-source blockchain developers with reliable, secure, easy-to-use, and pluggable cryptographic implementations.

Features

The major artifacts of Ursa are:

  • C-callable library interface
  • Rust crate

Ursa is divided into two sub libraries: libursa and libzmix.

Libursa

Designed for cryptographic primitives like simple digital signatures, encryption schemes, and key exchange.

Supported Signatures

  • ECDSA
    • Secp256k1
  • EdDSA
    • Ed25519 (Curve25519 in Twisted Edwards Form)
  • Boneh Lynn Shacham (BLS) Signature
    • Any Pairing friendly curves
  • Camenisch Lysyanskaya
    • RSA based
  • Shamir Secret Sharing

Supported Key Agreement

  • ECDH
    • Secp256k1
    • X25519 (Curve25519 in Montgomery Form)

Symmetric Encryption

  • AES-CBC
  • AES-GCM
  • XCHACHA20-POLY1305

Libzmix

A generic way to create zero-knowledge proofs, proving statements about multiple cryptographic building blocks, containing signatures, commitments, and verifiable encryption. Libzmix uses many of the building blocks found in Libursa.

Supported Zero Knowledge Proof capabilities

  • Signature Proofs of Knowledge
  • Bulletproofs
  • Range proofs
  • Set Membership

Supported Signatures

  • Boneh Boyen Shacham (BBS+)
    • Any Pairing friendly curves
  • Pointcheval Saunders
    • Any pairing friendly curves
  • Groth
    • Any Pairing friendly curves

Dependencies

Ursa uses the following external dependencies:

These dependencies are used when building in the default secure mode. These libraries are widely known. There is a goal to be able to compile Ursa from rust only code for portability reasons like generating web assemblies without the worry of compatibility issues from C code. For this reason, Ursa can be compiled with portable mode which replaces any external libraries with rust compatible code. Ursa developers take care when choosing suitable replacements that are cryptographically safe to use but may not have been audited and vetted in a similar manner to these external libraries. Ursa consumers should note this when using portable mode for their applications.

Building from Source

Libursa and Libzmix rely on libsodium for the default secure mode. Please see the following document for specific platform installations here.

Libursa

Libursa uses the rustc compiler with cargo. Go into the libursa folder where the Cargo.toml lives. Run the following commands to get the default secure mode:

cargo build --release

Run the following commands to build in portable mode:

cargo build --release --no-default-features --features=portable

If you wish to take advantage of assembly level features, you can build Ursa using the nightly compiler of rust.

cargo build --release --no-default-features --features=asm

The resulting artifact(s) can be found in the target/release folder. They include:

libursa.so (Linux)
libursa.dylib (Mac OS X)
libursa.a (Linux, Mac OS X)
libursa.dll (Windows)
libursa.lib (Windows)

Packaging

Libursa can be packaged for debian builds using cargo-deb. To create a debian package, run the following command with cargo-deb installed

cargo deb -p ursa

Libursa Documentation

Libursa API documentation is now available as rust doc in code. See:

Libzmix

Libzmix uses the rustc compiler with cargo. Go into the libzmix folder where the Cargo.toml lives. Run the following commands to get the default secure mode:

cargo build --release

Run the following commands to build in portable mode:

cargo build --release --no-default-features --features=portable

If you wish to take advantage of assembly level features, you can build ZMix using the nightly compiler of rust.

cargo build --release --no-default-features --features=asm

The resulting artifact(s) can be found in the target/release folder. They include:

libzmix.so (Linux)
libzmix.dylib (Mac OS X)
libzmix.a (Linux, Mac OS X)
libzmix.dll (Windows)
libzmix.lib (Windows)

Contributing

All bugs, stories, and backlog for this project are managed through Hyperledger's Jira in project IS (note that regular Ursa tickets are in the URSA project).

Also, join us on Hyperledger Rocket.Chat at #ursa to discuss.

The ursa group also meets biweekly on Wednesday's at 7 AM PST at https://zoom.us/my/hyperledger.community. The meeting notes are available here.

Major modifications to ursa are submitted as RFCs to the Ursa RFC repo.

For more details on contributing see CONTRIBUTING

Comments
  • remove libursa Cargo.lock

    remove libursa Cargo.lock

    Signed-off-by: Axel Nennker [email protected]

    I think that, in general, Cargo.lock should not be in version control of libraries like ursa.

    libindy uses ursa but ursa is using an older version of openssl-sys than libindy

    (Kind of hoping that using the same, newer versions help with libindy's CI-run failures on Ubuntu 18.04)

    opened by AxelNennker 17
  • replace libsecp256k1 with k256 crate

    replace libsecp256k1 with k256 crate

    @tarcieri mentions in #162 an alternative to libsecp256k1. I think the selection of the libsecp256k1 was for minimalist builds for e.g. mobile devices. Performance differential should be evaluated as well. Please discuss other criteria to evaluate. Current: https://crates.io/crates/libsecp256k1 Proposed: https://crates.io/crates/k256

    opened by dcmiddle 9
  • Add method to derive x25519 from an ed25519 private key

    Add method to derive x25519 from an ed25519 private key

    This method is compatible with libsodium's crypto_sign_ed25519_sk_to_curve25519.

    This PR also adds Ed25519Sha519::keypair_from_secret which is compatible with libsodium's crypto_sign_seed_keypair. @mikelodder7 I didn't add this as a separate KeyGenOption as it didn't seem to be generally applicable, but I'll let you be the judge.

    opened by andrewwhitehead 9
  • Upgrades version of ed25519-dalek

    Upgrades version of ed25519-dalek

    Description of changes

    Upgrade from 1.0.0-pre.2 to 1.0.0-pre.3 And corresponding fixes for other lib versions and src files

    Benefits

    There is an issue with the usage of latest ursa (0.3.2) with latest libp2p(0.16.2): they have incompatible versions of ed25519-dalek (ursa - 1.0.0-pre.2 and libp2p - 1.0.0-pre.3). It could be solved only by downgrading libp2p to version 0.13.1 which is rather old now.

    Therefore this PR is meant to fix that and make latest ursa and libp2p compatible, as they have rather intersecting user groups in my opinion.

    Signed-off-by: Egor Ivkov [email protected]

    opened by e-ivkov 7
  • Run libursa tests on Ubuntu 20.04

    Run libursa tests on Ubuntu 20.04

    This PR adds libursa-specific jobs to GH Actions (namely building libursa and running its tests).

    One thing I'm not sure about is the workaround for getting libursa to build on its own -- currently, running cargo build in the libursa directory on the main branch will yield this error:

    error: current package believes it's in a workspace when it's not:
    current:   ursa/libursa/Cargo.toml
    workspace: ursa/Cargo.toml
    
    this may be fixable by adding `libursa` to the `workspace.members` array of the manifest located at: ursa/Cargo.toml
    Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.
    

    I heeded the second suggestion and excluded libzmix and libursa from the workspace, but I'm not sure if this is the correct course of action. Feel free to request/make changes!

    As for the changes to libursa/src/kex/secp256k1.rs, the compatibility test was never updated after libsecp256k1 was replaced with k256 in #171, so this PR also fixes that.

    opened by nhwn 5
  • Implement compressed form

    Implement compressed form

    This PR updates to a newer version of amcl_wrapper as well as implements a compressed form for keys and proofs.

    For example, points can be stored as just the x-coordinates. Curve order elements can remove leading zero bytes.

    The result is that points in G1 drop to 48 bytes, G2 drop to 96 bytes, and elements in Zq drop to 32 bytes.

    The major gains come from proof sizes. A proof with 5 hidden messages is 933 bytes in uncompressed form and 530 in compressed form.

    Public Key sizes go down to 1/2.

    Signatures go from 193 bytes to 112 bytes.

    opened by mikelodder7 5
  • Resease a new version with updated ed25519-dalek

    Resease a new version with updated ed25519-dalek

    We have a dependency collision with cosmos_sdk=0.1.1 crate in our project.

    error: failed to select a version for `ed25519-dalek`.
        ... required by package `tendermint v0.19.0`
        ... which is depended on by `cosmos_sdk v0.1.1`
        ... which is depended on by `libindy v1.95.0 (.../libindy)`
    versions that meet the requirements `^1` are: 1.0.1, 1.0.0
    
    all possible versions conflict with previously selected packages.
    
      previously selected package `ed25519-dalek v1.0.0-pre.3`
        ... which is depended on by `ursa v0.3.5`
        ... which is depended on by `libindy v1.95.0 (.../libindy)`
    
    failed to select a version for `ed25519-dalek` which could resolve this conflict
    

    The version of ed25519-dalek is already updated in master. Could you please publish it to crates.io?

    opened by askolesov 4
  • Allow to pass pre-generated safe prime numbers to Credential Definition creation

    Allow to pass pre-generated safe prime numbers to Credential Definition creation

    To allow speeding up credential definition creation we wanted to create the safe prime numbers beforehand with ursa::helpers::generate_safe_prime and hold onto them until the actual credential definition is created.

    In our use case we have to create multiple credential definitions at a time and having a bunch of safe primes ready for this improves performance of this a lot. :)

    opened by wulfraem 4
  • Fix 'cl' feature, warnings

    Fix 'cl' feature, warnings

    Compilation currently fails when the cl feature is enabled due to the digest dependency being updated previously.

    Also fixed some warnings and skipped tests around the optional serde feature and non-existent serialization feature.

    opened by andrewwhitehead 3
  • Added Github Actions pipeline

    Added Github Actions pipeline

    • Runs a CI pipeline for incoming PRs and merges to main.
      • audit
      • build
      • check
      • clippy
      • docs
      • format
      • tests
    • Removed some files that I assumed are not used (please give this a careful review as I am not fully aware of the history of these files).
    • Does not include the release to crates.io just yet.
    • Moved the ursa_ packages to an Ursa folder to keep the root a bit cleaner. They kept the ursa_ prefix as we might want to release them as seperate packages, although some of them are empty.
    opened by blu3beri 0
  • About cross compile ursa

    About cross compile ursa

    According to the example of use of CL, i cross complie it with openwrt(arm) successfully, but when i make it on my router, i met the segment fault. I can't find the reason and don't konw how to fix it.

    opened by txq-bug 0
  • `ursa` crashes on seed lenght shorter than 32 bytes for `secp256k1`

    `ursa` crashes on seed lenght shorter than 32 bytes for `secp256k1`

    Ursa crashes if seed length is less than 32 bytes for secp256k1, but other algorithms work fine with this seed.

    The problem seems to be that in other cases the input seed is hashed before being passed to the rng generator.

    Minimal example that reproduce issue

    use ursa::{
        keys::KeyGenOption,
        signatures::{
            secp256k1::EcdsaSecp256k1Sha256,
            SignatureScheme,
        },
    };
    
    fn main() {
        let options = KeyGenOption::UseSeed(vec![1, 2, 3]);
        let key_pair = EcdsaSecp256k1Sha256::new().keypair(Some(options));
        println!("{:?}", key_pair);
    }
    
    opened by Erigara 0
  • Possible ED25519-dalek issue

    Possible ED25519-dalek issue

    According to ed25519-unsafe-libs the library that is used for signing, ed25519-dalek, possibly contains a security bug that allows for private key extraction (as explained in this stack overflow post.

    Now, the README mentions that it is not likely that libraries, like Ursa, using the "unsafe" library will also be "unsafe", but I thought I should mention it here.

    I am by no means an expert in this, so likely it is just nothing, but it never hurts to mention it.

    opened by blu3beri 0
Cryptography-oriented big integer library with constant-time, stack-allocated (no_std-friendly) implementations of modern formulas

RustCrypto: Cryptographic Big Integers Pure Rust implementation of a big integer library which has been designed from the ground-up for use in cryptog

Rust Crypto 88 Dec 31, 2022
Pairing cryptography library in Rust

bn This is a pairing cryptography library written in pure Rust. It makes use of the Barreto-Naehrig (BN) curve construction from [BCTV2015] to provide

Electric Coin Company Prototypes and Experiments 139 Dec 15, 2022
Pairing cryptography library in Rust

bn This is a pairing cryptography library written in pure Rust. It makes use of the Barreto-Naehrig (BN) curve construction from [BCTV2015] to provide

Parity Technologies 23 Apr 22, 2022
Example implementation for Biscuit tokens cryptography

example implementation for Biscuit token cryptography To aid in the implementation of Biscuit tokens in various languages, this repository contains an

Clever Cloud 6 May 25, 2021
Manage secret values in-repo via public key cryptography

amber Manage secret values in-repo via public key cryptography. See the announcement blog post for more motivation. Amber provides the ability to secu

FP Complete 82 Nov 10, 2022
Cryptography-related format encoders/decoders: PKCS, PKIX

RustCrypto: Formats Cryptography-related format encoders/decoders: PKCS, PKIX. Crates Name crates.io Docs Description base64ct Constant-time encoder a

Rust Crypto 112 Dec 20, 2022
Implementation of the Web Cryptography specification in Rust.

[wip] webcrypto Implementation of the Web Cryptography specification in Rust. This crate hopes to ease interoperability between WASM and native target

Divy Srivastava 5 Mar 7, 2022
BLS12-381 cryptography using Apache Milagro

BLS12-381 Aggregate Signatures in Rust using Apache Milagro WARNING: This library is a work in progress and has not been audited. Do NOT consider the

Sigma Prime 21 Apr 4, 2022
Traits - Collection of cryptography-related traits

RustCrypto: Traits Collection of traits which describe functionality of cryptographic primitives. Crates Name Algorithm Crates.io Docs MSRV aead Authe

Rust Crypto 401 Dec 27, 2022
Collect libraries and packages about cryptography in Rust.

Awesome Cryptography Rust Collect libraries and packages about cryptography in Rust. Collection Library Symmetric Public-key / Asymmetric One-way Hash

Rust Cryptography Community 282 Dec 25, 2022
A general solution for commonly used crypt in rust, collection of cryptography-related traits and algorithms.

Crypto-rs A general solution for commonly used crypt in rust, collection of cryptography-related traits and algorithms. This is a Rust implementation

houseme 4 Nov 28, 2022
A down-to-the-metal ongoing cryptography challenge designed by Radical Semiconductor.

woodpecker ?? [NOTE: scoreboard will now be updated weekends, starting the weekend of 12/10/2022--sorry for delays! I'll also be merging in pull reque

Radical Semiconductor 16 Dec 15, 2022
Elliptic curve cryptography on Soroban.

Elliptic Curve Cryptography on Soroban Contract examples and reusable primitives. Groth 16 verifier. This crate provides a SorobanGroth16Verifier obje

Xycloo Labs 5 Feb 10, 2023
A tool for secret-shared passphrases.

harpo harpo is a tool and library that provides the following functionality: It can generate a seed phrase. Given a seed phrase, it can generate any n

Thomas Locher 11 Jun 30, 2022
Simple shared types for multi-threaded Rust programs

Keep Calm (and call Clone) Simple shared types for multi-threaded Rust programs: keepcalm gives you permission to simplify your synchronization code i

Matt Mastracci 5 Mar 6, 2023
High-level networking library that extends the bevy_replicon library to allow snapshot interpolation and client-side prediction

bevy_replicon_snap A Snapshot Interpolation plugin for the networking solution bevy_replicon in the Bevy game engine. This library is a very rough pro

Ben 3 Oct 15, 2023
A Rust library for working with Bitcoin SV

Rust-SV A library to build Bitcoin SV applications in Rust. Documentation Features P2P protocol messages (construction and serialization) Address enco

Brenton Gunning 51 Oct 13, 2022
A Rust library for generating cryptocurrency wallets

Table of Contents 1. Overview 2. Build Guide 2.1 Install Rust 2.2a Build from Homebrew 2.2b Build from Crates.io 2.2c Build from Source Code 3. Usage

Aleo 552 Dec 29, 2022
A modern TLS library in Rust

Rustls is a modern TLS library written in Rust. It's pronounced 'rustles'. It uses ring for cryptography and libwebpki for certificate verification. S

ctz 4k Jan 9, 2023