cosmos / cosmos-sdk

:chains: A Framework for Building High Value Public Blockchains :sparkles:
https://cosmos.network/
Apache License 2.0
6.3k stars 3.64k forks source link

Schnorr signatures for privacy and storage improvements #7315

Closed robert-zaremba closed 1 month ago

robert-zaremba commented 4 years ago

Summary

Schnorr Signatures is are extremely well researched improve the privacy of users whilst also helping with issues of scaling at the same time. Currently, Cosmos SDK supports only ECDSA signatures. We started a work for adding ed25519. However it's not specified and lacking in depth analysis for batch verification, aggregation and specification for strickness for validation rules intended for consensus-critical contexts (--> tendermint issue for fixing it to provide guaranteess for cross-implementation consensus)

Background

Many Bitcoin derived blockchains use ECDSA for digital signatures. Schnorr Signatures algorithm patent was about to expire by the time Bitcoin paper was released. Now Schnorr is coming back to Bitocin with the MuSig update allowing better privacy and efficiency.

Problem Definition

ECDSA has a number of downsides compared to Schnorr signatures:

Advantages of advanced Schnorr signatures

Proposal

Support Schnorr signatures for every use-case:

Schnorr is extremely powerful for the privacy because we can make complex multi-sig transactions and even complex coinjoin transactions look like everyday normal transactions. This makes it difficult for chain analysis companies to analyse the transaction flows. In genera, aggregated signature scheme like Schnorr MuSig allows users to make a multisig output look like a standard user’s single sig output. This is a huge improvement compared to a normal multisig, where the users need to broadcast all of their public keys and signatures (requiring blockchain to validate and store it indefinitely. Instead, with a this proposal, the users do the enforcement themselves by constructing signatures between themselves resulting in a single final signature. Benefits:

Drawbacks:

How (proposal)

Alternative:

Notes:

Note about BLS

BLS is another elegant solution for private signatures and aggregation. It's more optimal for scenarios where we need to aggregate thousands than signatures (for smaller use-cases Schnorr is faster). The Achilles' heel of BLS is pairing function are complicated, and it can become our foe if we are not careful enough. There is an attack on elliptic curve crypto systems, called MOV attack (named after Menezes, Okamoto, and Vanstone), that allows to reduce security of the system by using pairing functions.

TL;DR: if not needed, it's safer to use well researched Schnorr Signatures rather than BLS.


For Admin Use

robert-zaremba commented 4 years ago

/cc @aaronc , @clevinson -- this could be very useful for many use cases.

ValarDragon commented 4 years ago

I mean we have Ed25519, which is ~basically Shnorr signatures restricted to one curve (some differences in how you hash things from the original Shnorr paper, but doesn't affect anything I'd see being used here). Aggregation techniques explicitly for Ed25519 look ~the same as for Shnorr, and have been specified for several years now. All usecases you listed can be done using Ed25519.

I don't see the benefit of adding direct Shnorr signatures, unless you explicitly want Shnorr secp256k1 for taproot compatability.

There is an attack on elliptic curve crypto systems, called MOV attack (named after Menezes, Okamoto, and Vanstone), that allows to reduce security of the system by using pairing functions.

All elliptic curves for use in cryptography are parameterized such that the MOV attack is infeasible. In the case of a pairing based curve, this (well really tower NFS attacks) is the central thing you parameterize security against.

robert-zaremba commented 4 years ago

The idea is to implement the BIP-340 for compatibility with secp256k1 keys AND appropriate aggregation schema. As you noticed, Ed25519 doesn't specify aggregation schema. Many SDK users are using secp256k1. We can reuse MuSig, or some other protocol for aggregation. In fact this is what Polkadot is using. W3F developed shnorrkel which implements a schema combining all features from BIP-340 with curve25519.

IFAICT, today there is no full support for ed25519 in SDK.

robert-zaremba commented 4 years ago

BTW, it seams that Tendermint is using Ed25519 directly. Does it implement measures against small-cofactor problems?

Implementation-defined behavior.Some systems, such as Ed25519 [7], do notspecify behavior when the inputs have a nonzeroh-torsion component. In par-ticular, Ed25519 signature verification can be different for batched vs singletonsignatures, or between different implementations. This can cause disruption inprotocols where all parties must agree on whether a signature is valid, such asa blockchain or Byzantine agreement. In other cases, it may make it easier tofingerprint implementations.

tac0turtle commented 4 years ago

BTW, it seams that Tendermint is using Ed25519 directly. Does it implement measures against small-cofactor problems?

See https://github.com/tendermint/spec/pull/144.

We are working on this.

tac0turtle commented 4 years ago

Note: sr25519 is supported in tendermint's crypto package. And is being used by a sdk based chain.

hxrts commented 4 years ago

Zcash Schnorr construction that enables concurrent signing. Maybe too early for our consideration, but linking anyway https://www.zfnd.org/blog/frost-update/

robert-zaremba commented 4 years ago

It seams that Bitcoin research is advancing as well. Recently they published MuSig2.

MuSig2 doesn't need interaction between the signers any more, which was a common hurdle in MuSig1 discussions.

tac0turtle commented 3 years ago

What is the status here? There isn't anything blocking this, right?

aaronc commented 3 years ago

5694/ADR 028 is blocking, but hopefully we can resolve that soon.

tac0turtle commented 3 years ago

WEN schnorr? 😄

robert-zaremba commented 3 years ago

when ready :D
Nobody expressed a need, so it's still in a backlog.

robert-zaremba commented 2 years ago

Added Two-Round Threshold Schnorr Signatures with FROST to alternatives

alexanderbez commented 2 years ago

I haven't seen concrete points made on what this buys us from a user perspective? I can only assume the main benefit is for multi-sigs, but apart from that, what else?

robert-zaremba commented 2 years ago

Updated the description by making it more explicit, added Advantages of advanced Schnorr signatures section.

odeke-em commented 1 year ago

Something up your alley and interests @elias-orijtech

tac0turtle commented 1 year ago

no need to work on this right now. Zondax is working on some cryptography things

robert-zaremba commented 1 year ago

Zondax is working on some cryptography things

Are there any details about it? Could you share a link?

bizk commented 1 year ago

We (@zondax) started working on this implementation following these specs https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki , we are also preparing a plan for improving the whole crypto module as well, once we have a draft we will be sharing it so we can all discuss it :)

bizk commented 1 year ago

I was thinking of usiing Kyber package implementation of schnor algorithm since it is a well known repository from a university, taking a look at the code, seems it satisfies the implementation. Any concerns with this approach?

bizk commented 1 year ago

Closing this issue since ed25519 is already implemented which is a pretty good algorithm. I played around with other variatns of schnorr but these ended up being more complex or less performant. Unless we want pure schnorr implementation.

We are putting our efforts on enabling ed25519, working over this issue

@tac0turtle

tac0turtle commented 1 year ago

i dont quite follow, why not add schnoor as an alternative here?

robert-zaremba commented 1 year ago

I second @tac0turtle . The goal of using Schnorr is to:

Let's reopen.

bizk commented 1 year ago

It was an assumption on my side that since ed25519 is an efficient variant of schnorr it wouldn't make sense to implement something less performant. After the discussion we had in the call, I realized that I was not having other aspects in mind as the ones both of you mentioned

tac0turtle commented 1 month ago

with the account module users are free to design custom accounts with different keys or authorisations