mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 04:09:23 +00:00
Use std-shims to reduce flexible-transcript MSRV to 1.66
flexible-transcript already had a shim to support <1.66. This was irrelevant since flexible-transcript had a MSRV of 1.73. Due to how clunky it was, it has been removed despite theoretically enabling an even lower MSRV.
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -2698,13 +2698,13 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flexible-transcript"
|
name = "flexible-transcript"
|
||||||
version = "0.3.3"
|
version = "0.3.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"blake2",
|
"blake2",
|
||||||
"digest 0.10.7",
|
"digest 0.10.7",
|
||||||
"merlin",
|
"merlin",
|
||||||
"rustversion",
|
|
||||||
"sha2",
|
"sha2",
|
||||||
|
"std-shims",
|
||||||
"subtle",
|
"subtle",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/crypto/ciphersuite
|
|||||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
keywords = ["ciphersuite", "ff", "group"]
|
keywords = ["ciphersuite", "ff", "group"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.73"
|
rust-version = "1.66"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/crypto/dkg"
|
|||||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
keywords = ["dkg", "multisig", "threshold", "ff", "group"]
|
keywords = ["dkg", "multisig", "threshold", "ff", "group"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.73"
|
rust-version = "1.66"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/crypto/dkg/dealer"
|
|||||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
keywords = ["dkg", "multisig", "threshold", "ff", "group"]
|
keywords = ["dkg", "multisig", "threshold", "ff", "group"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.73"
|
rust-version = "1.66"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ repository = "https://github.com/serai-dex/serai/tree/develop/crypto/dkg/recover
|
|||||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
keywords = ["dkg", "multisig", "threshold", "ff", "group"]
|
keywords = ["dkg", "multisig", "threshold", "ff", "group"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.73"
|
rust-version = "1.66"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "flexible-transcript"
|
name = "flexible-transcript"
|
||||||
version = "0.3.3"
|
version = "0.3.4"
|
||||||
description = "A simple transcript trait definition, along with viable options"
|
description = "A simple transcript trait definition, along with viable options"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/serai-dex/serai/tree/develop/crypto/transcript"
|
repository = "https://github.com/serai-dex/serai/tree/develop/crypto/transcript"
|
||||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
keywords = ["transcript"]
|
keywords = ["transcript"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.73"
|
rust-version = "1.66"
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
@@ -17,7 +17,7 @@ rustdoc-args = ["--cfg", "docsrs"]
|
|||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustversion = "1"
|
std-shims = { path = "../../common/std-shims", version = "0.1.4", default-features = false }
|
||||||
|
|
||||||
subtle = { version = "^2.4", default-features = false }
|
subtle = { version = "^2.4", default-features = false }
|
||||||
zeroize = { version = "^1.5", default-features = false }
|
zeroize = { version = "^1.5", default-features = false }
|
||||||
@@ -32,8 +32,7 @@ sha2 = { version = "0.10", default-features = false }
|
|||||||
blake2 = { version = "0.10", default-features = false }
|
blake2 = { version = "0.10", default-features = false }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
std = ["subtle/std", "zeroize/std", "digest/std", "blake2?/std", "merlin?/std"]
|
std = ["std-shims/std", "subtle/std", "zeroize/std", "digest/std", "blake2?/std", "merlin?/std"]
|
||||||
recommended = ["blake2"]
|
recommended = ["blake2"]
|
||||||
merlin = ["dep:merlin"]
|
|
||||||
tests = []
|
tests = []
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
|
#[allow(unused_imports)]
|
||||||
|
use std_shims::prelude::*;
|
||||||
|
|
||||||
use zeroize::Zeroize;
|
use zeroize::Zeroize;
|
||||||
|
|
||||||
use digest::{
|
use digest::{
|
||||||
@@ -159,35 +162,12 @@ where
|
|||||||
// These writes may be optimized out if they're never read
|
// These writes may be optimized out if they're never read
|
||||||
// Attempt to get them marked as read
|
// Attempt to get them marked as read
|
||||||
|
|
||||||
#[rustversion::since(1.66)]
|
|
||||||
fn mark_read<D: Send + Clone + SecureDigest>(transcript: &DigestTranscript<D>) {
|
fn mark_read<D: Send + Clone + SecureDigest>(transcript: &DigestTranscript<D>) {
|
||||||
// Just get a challenge from the state
|
// Just get a challenge from the state
|
||||||
let mut challenge = core::hint::black_box(transcript.0.clone().finalize());
|
let mut challenge = core::hint::black_box(transcript.0.clone().finalize());
|
||||||
challenge.as_mut().zeroize();
|
challenge.as_mut().zeroize();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rustversion::before(1.66)]
|
|
||||||
fn mark_read<D: Send + Clone + SecureDigest>(transcript: &mut DigestTranscript<D>) {
|
|
||||||
// Get a challenge
|
|
||||||
let challenge = transcript.0.clone().finalize();
|
|
||||||
|
|
||||||
// Attempt to use subtle's, non-exposed black_box function, by creating a Choice from this
|
|
||||||
// challenge
|
|
||||||
|
|
||||||
let mut read = 0;
|
|
||||||
for byte in challenge.as_ref() {
|
|
||||||
read ^= byte;
|
|
||||||
}
|
|
||||||
challenge.as_mut().zeroize();
|
|
||||||
|
|
||||||
// Since this Choice isn't further read, its creation may be optimized out, including its
|
|
||||||
// internal black_box
|
|
||||||
// This remains our best attempt
|
|
||||||
let mut choice = bool::from(subtle::Choice::from(read >> 7));
|
|
||||||
read.zeroize();
|
|
||||||
choice.zeroize();
|
|
||||||
}
|
|
||||||
|
|
||||||
mark_read(self)
|
mark_read(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
use crate::Transcript;
|
use crate::Transcript;
|
||||||
|
|
||||||
/// Test the sanity of a transcript.
|
/// Test the sanity of a transcript.
|
||||||
|
///
|
||||||
|
/// This will panic if sanity checks fail.
|
||||||
pub fn test_transcript<T: Transcript<Challenge: PartialEq>>() {
|
pub fn test_transcript<T: Transcript<Challenge: PartialEq>>() {
|
||||||
// Ensure distinct names cause distinct challenges
|
// Ensure distinct names cause distinct challenges
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user