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:
Luke Parker
2025-08-19 23:40:01 -04:00
parent 17c1d5cd6b
commit 900a6612d7
8 changed files with 15 additions and 34 deletions

View File

@@ -2,6 +2,9 @@
#![doc = include_str!("../README.md")]
#![no_std]
#[allow(unused_imports)]
use std_shims::prelude::*;
use zeroize::Zeroize;
use digest::{
@@ -159,35 +162,12 @@ where
// These writes may be optimized out if they're never read
// Attempt to get them marked as read
#[rustversion::since(1.66)]
fn mark_read<D: Send + Clone + SecureDigest>(transcript: &DigestTranscript<D>) {
// Just get a challenge from the state
let mut challenge = core::hint::black_box(transcript.0.clone().finalize());
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)
}
}

View File

@@ -1,6 +1,8 @@
use crate::Transcript;
/// Test the sanity of a transcript.
///
/// This will panic if sanity checks fail.
pub fn test_transcript<T: Transcript<Challenge: PartialEq>>() {
// Ensure distinct names cause distinct challenges
{