Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
795da47
Upgrade `curv` interface (#120)
Jul 27, 2021
f70f8bc
Update badges (#123)
Jul 28, 2021
b53df44
Remove dependency on `ring_algorithm` crate (#125)
Aug 5, 2021
09c9f04
Update changelog (#126)
Aug 5, 2021
02d683d
Fix subtraction (#127)
Aug 7, 2021
dcbf092
Add `lagrange_basis` function to `Polynomial` (#130)
Aug 26, 2021
8e60f9b
Integrate KaTeX (#131)
Aug 11, 2021
b1ad34b
LDEI proof improvements (#133)
Aug 16, 2021
6ae642d
Update dependencies (#134)
Aug 26, 2021
fce3eab
Implement Try and Increment when converting hash to bigint (#128)
elichai Aug 26, 2021
1569c91
Make the commitments generic over the hash function and remove deprec…
elichai Sep 9, 2021
6126e62
Remove dependency on rust-crypto (#137)
Sep 14, 2021
5ee0400
Unify & optimise serialization (#139)
Sep 15, 2021
9892ca7
Update changelog & bump version
Sep 15, 2021
8be8949
Fix points/scalars deserialization via serde_json (#143)
Oct 8, 2021
f665388
Bump version
Oct 8, 2021
072300c
Add serde_json support for BigInt (de)serialization (#145)
Oct 10, 2021
646a946
Update CI badge
Oct 10, 2021
89de0e6
Add `generate_random_point` (#148)
tmpfs Oct 19, 2021
a22c481
Change Polynomial::degree to be represented using a special enum Poly…
MatanHamilis Oct 19, 2021
403e15a
Bump version & update changelog
Oct 19, 2021
9e32cef
Fix typos (#153)
rex4539 Nov 3, 2021
928149e
Update README.md
Nov 16, 2021
842941c
Add a cautionary assert to `share_at_indices` to prevent user from mi…
elichai Dec 20, 2021
7a539f6
Use github workflows
Dec 21, 2021
4665149
Cache dependencies
Dec 21, 2021
2817893
Remove unused files (old blake/sha implementations) (#161)
elichai Dec 28, 2021
44537a7
Improve (de)serialization (#159)
Dec 28, 2021
a4bfe72
Added a dlog proof to vss feldman to defend against the n-t+1 attack …
Rumata888 Aug 7, 2022
daebb16
Bump p256 to 0.11 (#168)
Be-P Aug 22, 2022
8b3b7a5
Implement AsRef for EncodedPoint (#163)
elichai Aug 22, 2022
bc626bb
Fix curv25519 coordinates (#162)
elichai Aug 22, 2022
3025dca
Fix a bug in HmacExt::verify_bigint, where if the first byte of the b…
elichai Aug 22, 2022
1a65411
rustfmt + cargo clippy fixes
elichai Aug 22, 2022
d733f37
Require Point/Scalar to be Send+Sync (#170)
survived Aug 31, 2022
665cc11
Fix scalar deserialization issue (#171)
survived Sep 5, 2022
78cac40
new release (#173)
leontiad Dec 15, 2022
6bfa167
Implement std::error::Error for the error types (#117)
elichai Mar 29, 2023
7bdad5a
fix tests
leontiadZen Mar 29, 2023
30e9380
Use curve25519-dalek instead of cryptoxide (#152)
elichai Mar 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
- cron: '0 5 * * *'
workflow_call:

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy -- -D clippy::all
19 changes: 19 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Publish

on:
push:
tags:
- v*.*.*

jobs:
build:
uses: ZenGo-X/curv/.github/workflows/build.yml@master
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Publish crate
env:
TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cargo publish --token "$TOKEN"
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

87 changes: 87 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Changelog

## v0.9.0
* Change `Polynomial::degree` to return a special enum `PolynomialDegree` [#147] \
`PolynomialDegree` correctly represent a degree of polynomial that can be either infinite (for polynomial `f(x) = 0`)
or finite (for all other sorts of polynomials)


[#147]: https://github.com/ZenGo-X/curv/pull/148

## v0.8.3
* Add `generate_random_point` function from `centipede`, `bulletproof` crates [#148] \
It takes uniformly distributed bytes and produces secp256k1 point with unknown logarithm.
Subject to change in near future.

[#148]: https://github.com/ZenGo-X/curv/pull/148

## v0.8.2
* Bugfix for BigInt deserialization via serde_json [#145]

[#145]: https://github.com/ZenGo-X/curv/pull/145

## v0.8.1
* Bugfix for points/scalars deserialization via serde_json [#143]

[#143]: https://github.com/ZenGo-X/curv/pull/143

## v0.8.0
* Implement Try and Increment when converting hash to scalar [#128] \
Improves performance and security of conversion 🔥
* Get rid of deprecated `rust-crypto` dependency [#137]
* Changed the crate providing merkle trees support: `merkle-sha3 v0.1` → `merkle-cbt v0.3`
* Merkle trees API has been slightly changed
* Merkle trees are generic over hash function (it used to work with keccak256 only)
* Merkle proofs built by previous versions of `curv` are incompatible with latest `curv`
* Make the commitments generic over the hash function [#129] \
Allows the user to choose their own hash function when using our hash and related commitments
* Unify and optimise bigint serialization [#139]
* Bigints are serialized as bytes (instead of converting to hex/decimal format), that should save communication size
(depends on serialization backend)
* Different backends serialize bigints in the same way, ie. number serialized via `rust-gmp` backend will be properly
deserialized via `num-bigint` backend and vice-versa
* Compatibility notes: bigints serialization format is changed, so numbers serialized with older curv are not compatible
with the newest version

[#128]: https://github.com/ZenGo-X/curv/pull/128
[#129]: https://github.com/ZenGo-X/curv/pull/129
[#137]: https://github.com/ZenGo-X/curv/pull/137
[#139]: https://github.com/ZenGo-X/curv/pull/139

## v0.8.0-rc3
* Fix point subtraction. Bug was introduced in `v0.8.0-rc1`. [#127]
* Add `Polynomial::lagrange_basis` function [#130]
* Katex <> Docs integration [#131] \
Allows using KaTeX in documentation comments. Math formulas will be properly rendered on docs.rs.
* LDEI proof minor improvements [#133] \
Adds missing implementations of Clone and serialization traits.
* Update `hmac`, `digest`, `sha2`,`sha3` dependencies [#134] \
`hmac`: `v0.7.1` → `v0.11` \
`digest`: `v0.8.1` → `v0.9` \
`sha2`: `v0.8.0` → `v0.9` \
`sha3`: `v0.8.2` → `v0.9`

[#127]: https://github.com/ZenGo-X/curv/pull/127
[#130]: https://github.com/ZenGo-X/curv/pull/130
[#131]: https://github.com/ZenGo-X/curv/pull/131
[#133]: https://github.com/ZenGo-X/curv/pull/133
[#134]: https://github.com/ZenGo-X/curv/pull/134

## v0.8.0-rc2
* Remove dependency on `ring_algorithm` crate [#125], [#124]

[#125]: https://github.com/ZenGo-X/curv/pull/125
[#124]: https://github.com/ZenGo-X/curv/issues/124

## v0.8.0-rc1
* Elliptic curve API has been significantly changed [#120]

In particular: ECPoint, ECScalar traits were redesigned. They remain,
but are not supposed to be used directly anymore. In replacement,
we introduce structures Point, Scalar representing elliptic point and
scalar. See curv::elliptic::curves module-level documentation to learn
more.
* Add low degree exponent interpolation proof [#119]

[#119]: https://github.com/ZenGo-X/curv/pull/119
[#120]: https://github.com/ZenGo-X/curv/pull/120
57 changes: 32 additions & 25 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,57 +1,64 @@
[package]
name = "curv"
version = "0.7.0"
name = "curv-kzen"
version = "0.10.0"
edition = "2018"
authors = ["Omer Shlomovits"]
authors = [
"Omer Shlomovits",
"Denis Varlakov",
]
license = "MIT"
description = "Curv contains an extremly simple interface to onboard new elliptic curves. Use this library for general purpose elliptic curve cryptography"
description = "Curv contains an extremely simple interface to onboard new elliptic curves. Use this library for general purpose elliptic curve cryptography"
repository = "https://github.com/ZenGo-X/curv"

[lib]
name = "curv"
crate-type = ["lib"]

[dependencies]
blake2b_simd = "0.5.7"
cryptoxide = "0.1.2"
curve25519-dalek = "1.2.3"
derivative = "2.2"
digest = "0.8.1"
ff-zeroize = "0.6.3"
funty = "=1.1.0"
curve25519-dalek = "3"
digest = "0.9"
generic-array = "0.14"
hex = "0.4"
hmac = "0.7.1"
merkle-sha3 = "^0.1"
lazy_static = "1.4.0"
typenum = "1.13"
ff-zeroize = "0.6.3"
hex = { version = "0.4", features = ["serde"] }
hmac = "0.11"
thiserror = "1"
lazy_static = "1.4"
num-traits = "0.2"
num-integer = "0.1"
pairing-plus = "0.19"
rand = "0.6"
ring-algorithm = "0.2.3"
rust-crypto = "^0.2"
rand = "0.7"
rand_legacy = { package = "rand", version = "0.6" }
serde = { version = "1.0", features = ["derive"] }
serde_bytes = "0.11"
serde_derive = "1.0"
sha2 = "0.8.0"
sha3 = "0.8.2"
sha2 = "0.9"
sha3 = "0.9"
old_sha2 = { package = "sha2", version = "0.8" }
zeroize = "1"
merkle-cbt = "0.3"

rust-gmp-kzen = { version = "0.5", features = ["serde_support"], optional = true }
num-bigint = { version = "0.4", features = ["serde"], optional = true }

[dependencies.secp256k1]
version = "0.20"
features = ["serde", "rand-std"]
features = ["serde", "rand-std", "global-context"]

[dependencies.p256]
version = "0.5"
features = ["ecdsa"]
version = "0.11.1"
features = ["ecdsa", "ecdsa-core"]

[dev-dependencies]
bincode = "1.1"
serde_json = "1.0"
serde_test = "1.0"
serde_json = "1"
paste = "1.0.2"
proptest = "0.10"
proptest-derive = "0.2"
blake2 = "0.9"

[features]
default = ["rust-gmp-kzen"]

[package.metadata.docs.rs]
rustdoc-args = [ "--html-in-header", "katex-header.html", "--cfg", "docsrs" ]
33 changes: 26 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.com/ZenGo-X/curv.svg?branch=master)](https://travis-ci.com/zengo-x/curv)
[![Build Status](https://app.travis-ci.com/ZenGo-X/curv.svg?branch=master)](https://app.travis-ci.com/ZenGo-X/curv)
[![Latest version](https://img.shields.io/crates/v/curv-kzen.svg)](https://crates.io/crates/curv-kzen)
[![Docs](https://docs.rs/curv-kzen/badge.svg)](https://docs.rs/curv-kzen)
[![License](https://img.shields.io/crates/l/curv-kzen)](LICENSE)
[![dependency status](https://deps.rs/repo/github/ZenGo-X/curv/status.svg)](https://deps.rs/repo/github/ZenGo-X/curv)

Curv
=====================================
Curv contains an extremly simple interface to onboard new elliptic curves.
Curv contains an extremely simple interface to onboard new elliptic curves.
Use this library for general purpose elliptic curve cryptography.

The library has a built in support for some useful operations/primitives such as verifiable secret sharing, commitment
schemes, zero knowledge proofs, and simple two party protocols such as ECDH and coin flip. The library comes with
serialize/deserialize support to be used in higher level code to implement networking.

### Usage

To use `curv` crate, add the following to your Cargo.toml:
```toml
[dependencies]
curv-kzen = "0.9"
```

The crate will be available under `curv` name, e.g.:
```rust
use curv::elliptic::curves::*;
```

### Currently Supported Elliptic Curves

| Curve | low level library | curve description |
Expand Down Expand Up @@ -43,9 +59,8 @@ You can choose any one which you prefer by specifying a feature:
* **rust-gmp-kzen**, uses GMP bindings, requires GMP to be installed on a machine. Used by default.
* **num-bigint**, Rust's pure implementation of big integer. In order to use it, put in Cargo.toml:
```toml
[dependencies.curv]
git = "https://github.com/ZenGo-X/curv"
tag = "v0.6.0"
[dependencies.curv-kzen]
version = "0.8"
default-features = false
features = ["num-bigint"]
```
Expand All @@ -59,7 +74,11 @@ The library includes some basic examples to get you going. To run them:
for example: `cargo run --example proof_of_knowledge_of_dlog -- secp256k1`

### Docs
To build docs, use `cargo doc --no-deps`.
To build docs, use:
```bash
cargo doc
RUSTDOCFLAGS="--html-in-header katex-header.html" cargo doc --no-deps --open
```

### License
Curv is released under the terms of the MIT license. See [LICENSE](LICENSE) for more information.
Expand Down
25 changes: 10 additions & 15 deletions examples/diffie_hellman_key_exchange.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::fmt::Debug;

use curv::elliptic::curves::traits::ECPoint;
use curv::elliptic::curves::*;

/// Diffie Hellman Key Exchange:
/// TO RUN:
Expand All @@ -11,17 +9,13 @@ use curv::elliptic::curves::traits::ECPoint;
/// notice: this library includes also a more involved ECDH scheme. see
/// dh_key_exchange_variant_with_pok_comm.rs

pub fn ecdh<P>()
where
P: ECPoint + Clone + Debug,
P::Scalar: Clone,
{
pub fn ecdh<E: Curve>() {
use curv::cryptographic_primitives::twoparty::dh_key_exchange::{
compute_pubkey, Party1FirstMessage, Party2FirstMessage,
};

let (kg_party_one_first_message, kg_ec_key_pair_party1) = Party1FirstMessage::<P>::first();
let (kg_party_two_first_message, kg_ec_key_pair_party2) = Party2FirstMessage::<P>::first();
let (kg_party_one_first_message, kg_ec_key_pair_party1) = Party1FirstMessage::<E>::first();
let (kg_party_two_first_message, kg_ec_key_pair_party2) = Party2FirstMessage::<E>::first();

assert_eq!(
compute_pubkey(
Expand All @@ -38,11 +32,12 @@ where
fn main() {
let curve_name = std::env::args().nth(1);
match curve_name.as_deref() {
Some("secp256k1") => ecdh::<curv::elliptic::curves::secp256_k1::GE>(),
Some("ristretto") => ecdh::<curv::elliptic::curves::curve_ristretto::GE>(),
Some("ed25519") => ecdh::<curv::elliptic::curves::ed25519::GE>(),
Some("bls12_381") => ecdh::<curv::elliptic::curves::bls12_381::g1::GE>(),
Some("p256") => ecdh::<curv::elliptic::curves::p256::GE>(),
Some("secp256k1") => ecdh::<Secp256k1>(),
Some("ristretto") => ecdh::<Ristretto>(),
Some("ed25519") => ecdh::<Ed25519>(),
Some("bls12_381_1") => ecdh::<Bls12_381_1>(),
Some("bls12_381_2") => ecdh::<Bls12_381_2>(),
Some("p256") => ecdh::<Secp256r1>(),
Some(unknown_curve) => eprintln!("Unknown curve: {}", unknown_curve),
None => eprintln!("Missing curve name"),
}
Expand Down
Loading