Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

frost-rs

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

frost-rs

  • 1.0.0
  • PyPI
  • Socket score

Maintainers
1

Frost.rs Python Bindings

This library is a port of frost.rs written by the Zcash Foundation for Python 3.8-12. It provides bindings to the Rust library for performing various cryptographic operations, including distributed key generation (DKG), nonce generation, and signing signature blazingly fast.

Installation

To install the library, run the following command:

$ pip install frost_rs
  • it's recommended to run the command in a virtual environment

Supported Platforms

If you could not install the library due to unsupported Operating System , you can install the Rust compiler on your device by running:

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

After installing Rust, you can install the package using the same pip command

It will download the source distribution and build it for your platform.

For more information on installing Rust, visit the official Rust website.

Features

This library supports the following elliptic curves:

  • secp256k1
  • ed448
  • ed25519
  • p256
  • ristretto255

All of the outputs are base64url encoded strings and not encrypted!! Note: In version 0.1.3 and above, the output of Dkg:round 2 will be automatically encrypted. Therefore, any output that is not marked as a secret can be broadcasted.

guide

here is a example of how to use the library to make a signature and verify it

# put utility_ before elliptic curves
from frost_rs import utility_secp256k1 as frost

min_signers = 7
max_signers = 10
message = "hello Frost_rs"
# get an identifier (chance of collision is low) you can provide a string to get_id to get the same id each time
identifiers: str = [frost.get_id() for _ in range(max_signers)]

# run the three round protocol to get the key

round1_secret_packages: dict[str:str] = {}
round1_public_packages: dict[str:str] = {}
# every one sends their round public package to each other and use it in round 2
for id in identifiers:
    (round1_secret_packages[id], round1_public_packages[id]) = frost.round1(
        id, min_signers, max_signers)

round2_secret_packages: dict[str:str] = {}
round2_public_packages: dict[str:dict[str:str]] = {}


# in round 2 every one make a dict (identifier to package) and each sends the package to each user with help of identifier
for id in identifiers:
    round1_received_packages = {
        key: value for key, value in round1_public_packages.items() if key != id}
    (round2_secret_packages[id], round2_public_packages[id]) = frost.round2(
        round1_secret_packages[id], round1_received_packages)

key_packages: dict[str:str] = {}
pubkey_packages: dict[str:str] = {}

# every one will get their key package and the group public key
for id in identifiers:
    round1_received_packages = {
        key: value for key, value in round1_public_packages.items() if key != id}
    round2_received_packages = {
        k: v[id] for k, v in round2_public_packages.items() if id in v}
    (key_packages[id], pubkey_packages[id]) = frost.round3(
        round2_secret_packages[id], round1_received_packages, round2_received_packages)
nonces: dict[str:str] = {}
commitments: dict[str:str] = {}

# nonce generation can be preprocessed
# commitment should be sent to others
for id in identifiers:
    (nonces[id], commitments[id]) = frost.preprocess(key_packages[id])
# in this example no participant leaves so it acts as normal multi sig
signature_shares: dict[str:str] = {}
# every one sign the message and send the result to the person who aggregated the signature
for id in identifiers:
    signature_shares[id] = frost.sign(
        message, commitments, nonces[id], key_packages[id])
# after reciveing the shares aggregator will make the signature and serialize it
group_signature = frost.aggregate(
    message, commitments, signature_shares, pubkey_packages[identifiers[0]])

# verify(message[bytes] - pubkey[string] - signature[string])-> bool
# any one can now verify the signature if they have the access to the parameters
verification_result = frost.verify(
    message, pubkey_packages[identifiers[0]], group_signature)

Benchmarks

The following benchmarks show the performance of the library for different values of T (number of parties) and N (number of nodes) on local machine with AMD 5600x.

T=7, N=10

LibraryDKG (sec)Nonce Gen (sec/node)Sign (sec)
utility_secp256k10.1100160.0001000.005999
utility_ed4480.9960420.0013010.086805
utility_ed255190.1097490.0002000.010864
utility_p2560.2470940.0002880.010576
utility_ristretto2550.0661600.0001000.005664

T=15, N=20

LibraryDKG (sec)Nonce Gen (sec/node)Sign (sec)
utility_secp256k10.8190980.0001500.021002
utility_ed4487.7809450.0011880.316400
utility_ed255190.8289220.0001500.042004
utility_p2561.8253270.0002970.039655
utility_ristretto2550.4910670.0001000.016765

T=25, N=30

LibraryDKG (sec)Nonce Gen (sec/node)Sign (sec)
utility_secp256k12.9310580.0001620.046715
utility_ed44827.8823550.0012250.679499
utility_ed255193.0505860.0001330.083511
utility_p2566.4872190.0003170.083003
utility_ristretto2551.8037850.0001000.037506

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc