Skip to content

feat: gemini-2.5-pro #313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 31 additions & 0 deletions tss-lib-rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "tss-lib-rust"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
num-bigint = { version = "0.4", features = ["rand"] }
log = "0.4"
rand = "0.8"
num-integer = "0.1"
num-traits = "0.2" # Often needed with num crates
jacobi = "0.2"
once_cell = "1.19" # For static lazy initialization
num-prime = "0.4" # For primality testing
bytes = "1"
prost = "0.12"
tokio = { version = "1", features = ["full"] } # Async runtime
k256 = { version = "0.13", features = ["arithmetic"] } # SECP256k1 curve
p256 = { version = "0.13", features = ["arithmetic"] } # NIST P-256 curve
ed25519-dalek = "2.1" # Ed25519 signatures
sha2 = "0.10" # SHA-2 hashing algorithms
thiserror = "1.0" # Error handling
# Dependencies will be added here as needed during translation.

[build-dependencies]
prost-build = "0.12"

[dev-dependencies]
# num-prime = "0.4" # No longer needed here, moved to regular dependencies
43 changes: 43 additions & 0 deletions tss-lib-rust/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use std::{io::Result, path::Path};

fn main() -> Result<()> {
let proto_dir = "proto";
let out_dir = "src/protob";

println!("cargo:rerun-if-changed={}", proto_dir); // Rerun build script if proto files change

// Ensure the output directory exists
std::fs::create_dir_all(out_dir)?;

// Find all .proto files in the proto directory
let proto_files: Vec<_> = std::fs::read_dir(proto_dir)?
.filter_map(|entry| {
entry.ok().and_then(|e| {
let path = e.path();
if path.is_file() && path.extension() == Some("proto".as_ref()) {
Some(path)
} else {
None
}
})
})
.collect();

if proto_files.is_empty() {
eprintln!("Warning: No .proto files found in {}", proto_dir);
return Ok(());
}

// Convert pathbufs to string slices for prost_build
let proto_file_paths: Vec<&str> = proto_files
.iter()
.map(|p| p.to_str().expect("Proto path is not valid UTF-8"))
.collect();

prost_build::Config::new()
.out_dir(out_dir) // Output generated Rust files here
.compile_protos(&proto_file_paths, // Input proto files
&[proto_dir])?; // Include path for imports

Ok(())
}
20 changes: 20 additions & 0 deletions tss-lib-rust/prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Prompt for Rewriting tss-lib-go to tss-lib-rust

**Goal:** Rewrite the Go library located in the `tss-lib-go` directory into an equivalent Rust library in the `tss-lib-rust` directory.

**Source Directory:** `./tss-lib-go`
**Target Directory:** `./tss-lib-rust`

**Key Constraints & Requirements:**

1. **Maintain Directory Structure:** Replicate the directory and file structure from `tss-lib-go` within `tss-lib-rust`. For each `.go` file, create a corresponding `.rs` file (or `mod.rs` as appropriate for Rust modules) in the same relative path.
2. **Idiomatic Rust:** Translate Go code, concepts, and patterns into safe, performant, and idiomatic Rust. Pay attention to error handling (Result/panic), memory management (ownership, borrowing), concurrency (async/await, threads), and data structures.
3. **Functional Equivalence:** The resulting Rust library must provide the same core functionality and APIs as the original Go library. Public interfaces should be preserved where possible, adapting to Rust conventions.
4. **Minimal Dependencies:** Do NOT introduce external Rust crates unless absolutely necessary and clearly justified. Prioritize using the Rust standard library. If a crate is needed, explain why the standard library is insufficient.
5. **Self-Sufficiency & Role-Play:** You must handle the entire process autonomously. If you encounter ambiguity in the Go code or face a choice in Rust implementation (e.g., "How should this Go interface be represented in Rust?", "What's the idiomatic Rust way to handle this error pattern?", "Is this global state necessary or can it be refactored?"), follow these steps:
* Clearly state the question or ambiguity you've identified.
* Immediately provide a reasoned answer or decision, justifying it based on Rust best practices and the inferred intent of the Go code. Act as both the question-asker (analyzing Go) and the expert Rust developer (providing the solution).
* Proceed with the implementation based on your reasoned answer.
6. **Process:** Work through the Go codebase systematically, **one file or module at a time**. Start with the root directory or a logical entry point. After processing one file/module, clearly state which one you completed and which one you intend to process next. **Wait for a "continue" instruction before proceeding to the next file/module.**

**Output:** For the **current** file/module being processed, generate the corresponding Rust code in the `tss-lib-rust` directory. Ensure the generated code is complete and ready for compilation (including necessary `use` statements, module declarations, etc.). State the full path of the Rust file you just generated and the full path of the Go file you will process next.
45 changes: 45 additions & 0 deletions tss-lib-rust/proto/ecdsa-keygen.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright © 2019 Binance
//
// This file is part of Binance. The full Binance copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

syntax = "proto3";
package binance.tsslib.ecdsa.keygen;
option go_package = "ecdsa/keygen";

/*
* Represents a BROADCAST message sent during Round 1 of the ECDSA TSS keygen protocol.
*/
message KGRound1Message {
bytes commitment = 1;
bytes paillier_n = 2;
bytes n_tilde = 3;
bytes h1 = 4;
bytes h2 = 5;
repeated bytes dlnproof_1 = 6;
repeated bytes dlnproof_2 = 7;
}

/*
* Represents a P2P message sent to each party during Round 2 of the ECDSA TSS keygen protocol.
*/
message KGRound2Message1 {
bytes share = 1;
repeated bytes facProof = 2;
}

/*
* Represents a BROADCAST message sent to each party during Round 2 of the ECDSA TSS keygen protocol.
*/
message KGRound2Message2 {
repeated bytes de_commitment = 1;
repeated bytes modProof = 2;
}

/*
* Represents a BROADCAST message sent to each party during Round 3 of the ECDSA TSS keygen protocol.
*/
message KGRound3Message {
repeated bytes paillier_proof = 1;
}
65 changes: 65 additions & 0 deletions tss-lib-rust/proto/ecdsa-resharing.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright © 2019 Binance
//
// This file is part of Binance. The full Binance copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

syntax = "proto3";
package binance.tsslib.ecdsa.resharing;
option go_package = "ecdsa/resharing";

/*
* The Round 1 data is broadcast to peers of the New Committee in this message.
*/
message DGRound1Message {
bytes ecdsa_pub_x = 1;
bytes ecdsa_pub_y = 2;
bytes v_commitment = 3;
bytes ssid = 4;
}

/*
* The Round 2 data is broadcast to other peers of the New Committee in this message.
*/
message DGRound2Message1 {
bytes paillier_n = 1;
repeated bytes modProof = 2;
bytes n_tilde = 3;
bytes h1 = 4;
bytes h2 = 5;
repeated bytes dlnproof_1 = 6;
repeated bytes dlnproof_2 = 7;
}

/*
* The Round 2 "ACK" is broadcast to peers of the Old Committee in this message.
*/
message DGRound2Message2 {
}

/*
* The Round 3 data is sent to peers of the New Committee in this message.
*/
message DGRound3Message1 {
bytes share = 1;
}

/*
* The Round 3 data is broadcast to peers of the New Committee in this message.
*/
message DGRound3Message2 {
repeated bytes v_decommitment = 1;
}

/*
* The Round 4 "ACK" is broadcast to peers of the Old and New Committees from the New Committee in this message.
*/
message DGRound4Message2 {
}

/*
* The Round 4 message to peers of New Committees from the New Committee in this message.
*/
message DGRound4Message1 {
repeated bytes facProof = 1;
}
93 changes: 93 additions & 0 deletions tss-lib-rust/proto/ecdsa-signing.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Copyright © 2019 Binance
//
// This file is part of Binance. The full Binance copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

syntax = "proto3";
package binance.tsslib.ecdsa.signing;
option go_package = "ecdsa/signing";

/*
* Represents a P2P message sent to each party during Round 1 of the ECDSA TSS signing protocol.
*/
message SignRound1Message1 {
bytes c = 1;
repeated bytes range_proof_alice = 2;
}

/*
* Represents a BROADCAST message sent to all parties during Round 1 of the ECDSA TSS signing protocol.
*/
message SignRound1Message2 {
bytes commitment = 1;
}

/*
* Represents a P2P message sent to each party during Round 2 of the ECDSA TSS signing protocol.
*/
message SignRound2Message {
bytes c1 = 1;
bytes c2 = 2;
repeated bytes proof_bob = 3;
repeated bytes proof_bob_wc = 4;
}

/*
* Represents a BROADCAST message sent to all parties during Round 3 of the ECDSA TSS signing protocol.
*/
message SignRound3Message {
bytes theta = 1;
}

/*
* Represents a BROADCAST message sent to all parties during Round 4 of the ECDSA TSS signing protocol.
*/
message SignRound4Message {
repeated bytes de_commitment = 1;
bytes proof_alpha_x = 2;
bytes proof_alpha_y = 3;
bytes proof_t = 4;
}

/*
* Represents a BROADCAST message sent to all parties during Round 5 of the ECDSA TSS signing protocol.
*/
message SignRound5Message {
bytes commitment = 1;
}

/*
* Represents a BROADCAST message sent to all parties during Round 6 of the ECDSA TSS signing protocol.
*/
message SignRound6Message {
repeated bytes de_commitment = 1;
bytes proof_alpha_x = 2;
bytes proof_alpha_y = 3;
bytes proof_t = 4;
bytes v_proof_alpha_x = 5;
bytes v_proof_alpha_y = 6;
bytes v_proof_t = 7;
bytes v_proof_u = 8;
}

/*
* Represents a BROADCAST message sent to all parties during Round 7 of the ECDSA TSS signing protocol.
*/
message SignRound7Message {
bytes commitment = 1;
}

/*
* Represents a BROADCAST message sent to all parties during Round 8 of the ECDSA TSS signing protocol.
*/
message SignRound8Message {
repeated bytes de_commitment = 1;
}

/*
* Represents a BROADCAST message sent to all parties during Round 9 of the ECDSA TSS signing protocol.
*/
message SignRound9Message {
bytes s = 1;
}
33 changes: 33 additions & 0 deletions tss-lib-rust/proto/eddsa-keygen.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright © 2019 Binance
//
// This file is part of Binance. The full Binance copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

syntax = "proto3";
package binance.tsslib.eddsa.keygen;
option go_package = "eddsa/keygen";

/*
* Represents a BROADCAST message sent during Round 1 of the EDDSA TSS keygen protocol.
*/
message KGRound1Message {
bytes commitment = 1;
}

/*
* Represents a P2P message sent to each party during Round 2 of the EDDSA TSS keygen protocol.
*/
message KGRound2Message1 {
bytes share = 1;
}

/*
* Represents a BROADCAST message sent to each party during Round 2 of the EDDSA TSS keygen protocol.
*/
message KGRound2Message2 {
repeated bytes de_commitment = 1;
bytes proof_alpha_x = 2;
bytes proof_alpha_y = 3;
bytes proof_t = 4;
}
44 changes: 44 additions & 0 deletions tss-lib-rust/proto/eddsa-resharing.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright © 2019 Binance
//
// This file is part of Binance. The full Binance copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

syntax = "proto3";
package binance.tsslib.eddsa.resharing;
option go_package = "eddsa/resharing";

/*
* The Round 1 data is broadcast to peers of the New Committee in this message.
*/
message DGRound1Message {
bytes eddsa_pub_x = 1;
bytes eddsa_pub_y = 2;
bytes v_commitment = 3;
}

/*
* The Round 2 "ACK" is broadcast to peers of the Old Committee in this message.
*/
message DGRound2Message {
}

/*
* The Round 3 data is sent to peers of the New Committee in this message.
*/
message DGRound3Message1 {
bytes share = 1;
}

/*
* The Round 3 data is broadcast to peers of the New Committee in this message.
*/
message DGRound3Message2 {
repeated bytes v_decommitment = 1;
}

/*
* The Round 4 "ACK" is broadcast to peers of the Old and New Committees from the New Committee in this message.
*/
message DGRound4Message {
}
Loading