Skip to content

Commit

Permalink
Merge pull request #167 from LLFourn/bincode-unfinished-business
Browse files Browse the repository at this point in the history
More bincode derives
  • Loading branch information
LLFourn authored Jul 12, 2023
2 parents bfdcbf9 + c1cba8a commit 6489de8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 5 deletions.
1 change: 0 additions & 1 deletion ecdsa_fun/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ default = ["std"]
libsecp_compat = ["secp256kfun/libsecp_compat", "libsecp_compat_0_27"]
libsecp_compat_0_27 = ["secp256kfun/libsecp_compat_0_27"]
std = ["alloc"]
bincode = ["secp256kfun/bincode" ]
alloc = ["secp256kfun/alloc", "sigma_fun?/alloc" ]
serde = ["secp256kfun/serde","sigma_fun?/serde"]
adaptor = ["dep:sigma_fun", "dep:bincode", "dep:rand_chacha"]
Expand Down
5 changes: 5 additions & 0 deletions schnorr_fun/src/adaptor/encrypted_signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ use secp256kfun::{marker::*, Point, Scalar};
derive(crate::fun::serde::Deserialize, crate::fun::serde::Serialize),
serde(crate = "crate::fun::serde")
)]
#[cfg_attr(
feature = "bincode",
derive(crate::fun::bincode::Encode, crate::fun::bincode::Decode),
bincode(crate = "crate::fun::bincode")
)]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
pub struct EncryptedSignature<S = Public> {
/// The `R` point in the signature
Expand Down
10 changes: 10 additions & 0 deletions schnorr_fun/src/frost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,16 @@ impl std::error::Error for FinishKeyGenError {}
derive(crate::fun::serde::Deserialize, crate::fun::serde::Serialize),
serde(crate = "crate::fun::serde")
)]
#[cfg_attr(
feature = "bincode",
derive(crate::fun::bincode::Encode, crate::fun::bincode::Decode),
bincode(
crate = "crate::fun::bincode",
encode_bounds = "Point<T>: crate::fun::bincode::Encode",
decode_bounds = "Point<T>: crate::fun::bincode::Decode",
borrow_decode_bounds = "Point<T>: crate::fun::bincode::BorrowDecode<'__de>"
)
)]
pub struct FrostKey<T: PointType> {
/// The joint public key of the frost multisignature.
#[cfg_attr(
Expand Down
15 changes: 15 additions & 0 deletions schnorr_fun/src/musig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,11 @@ where
derive(crate::fun::serde::Deserialize, crate::fun::serde::Serialize),
serde(crate = "crate::fun::serde")
)]
#[cfg_attr(
feature = "bincode",
derive(crate::fun::bincode::Encode, crate::fun::bincode::Decode),
bincode(crate = "crate::fun::bincode")
)]
pub struct Ordinary;

/// Marks the [`SignSession`] as being used to create an adaptor (a.k.a. one-time encrypted)
Expand All @@ -396,6 +401,11 @@ pub struct Ordinary;
derive(crate::fun::serde::Deserialize, crate::fun::serde::Serialize),
serde(crate = "crate::fun::serde")
)]
#[cfg_attr(
feature = "bincode",
derive(crate::fun::bincode::Encode, crate::fun::bincode::Decode),
bincode(crate = "crate::fun::bincode")
)]
pub struct Adaptor {
y_needs_negation: bool,
}
Expand All @@ -414,6 +424,11 @@ pub struct Adaptor {
derive(crate::fun::serde::Deserialize, crate::fun::serde::Serialize),
serde(crate = "crate::fun::serde")
)]
#[cfg_attr(
feature = "bincode",
derive(crate::fun::bincode::Encode, crate::fun::bincode::Decode),
bincode(crate = "crate::fun::bincode")
)]
pub struct SignSession<T = Ordinary> {
b: Scalar<Public, Zero>,
c: Scalar<Public, Zero>,
Expand Down
6 changes: 3 additions & 3 deletions secp256kfun/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ rand_core = { version = "0.6", default-features = false }
serde = { version = "1.0", optional = true, default-features = false, features = ["derive"] }
secp256k1_0_27 = { package = "secp256k1", version = "0.27", optional = true, default-features = false }
proptest = { version = "1", optional = true }
bincode = { version = "2.0.0-rc.3", optional = true }
bincode = { version = "2.0.0-rc.3", optional = true, default-features = false, features = ["derive"] }

[dev-dependencies]
serde_json = "1"
Expand All @@ -38,10 +38,10 @@ wasm-bindgen-test = "0.3"

[features]
default = ["std"]
alloc = ["serde?/alloc", "digest/alloc", "secp256k1_0_27?/alloc"]
std = ["alloc", "subtle/std", "digest/std"]
libsecp_compat_0_27 = [ "dep:secp256k1_0_27" ]
libsecp_compat = ["libsecp_compat_0_27"]
alloc = ["serde?/alloc", "digest/alloc", "secp256k1_0_27?/alloc", "bincode?/alloc"]
std = ["alloc", "subtle/std", "digest/std", "bincode?/std", "secp256k1_0_27?/std"]
serde = [ "dep:serde", "secp256k1_0_27?/serde", "bincode?/serde" ]

[[bench]]
Expand Down
2 changes: 1 addition & 1 deletion sigma_fun/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ default = ["alloc", "secp256k1"]
alloc = ["serde?/alloc", "secp256kfun/alloc"]
secp256k1 = ["secp256kfun"]
ed25519 = ["curve25519-dalek"]
serde = ["dep:serde", "secp256kfun/serde", "curve25519-dalek/serde", "generic-array/serde"]
serde = ["dep:serde", "secp256kfun?/serde", "curve25519-dalek?/serde", "generic-array/serde"]

[package.metadata.docs.rs]
all-features = true
Expand Down

0 comments on commit 6489de8

Please sign in to comment.